using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils.Collections; using HarmonyLib; using HookDOTS.API; using HookDOTS.API.Attributes; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.CastleBuilding.Placement; using ProjectM.CastleBuilding.Rebuilding; using ProjectM.Gameplay.Systems; using ProjectM.Network; using ProjectM.Physics; using ProjectM.Scripting; using ProjectM.Shared; using ProjectM.Shared.Systems; using ProjectM.Terrain; using Satisvampory.Commands.Converters; using Satisvampory.Services; using Stunlock.Core; using Stunlock.Localization; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Physics; using Unity.Scenes; using Unity.Transforms; using UnityEngine; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Satisvampory")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Server QOL for V Rising: logistics, named dest, ClanShare, treasury lend, and ground scoop.")] [assembly: AssemblyFileVersion("1.0.85.0")] [assembly: AssemblyInformationalVersion("1.0.85+382291b71fc070ee9ce1bb689818733829931c30")] [assembly: AssemblyProduct("Satisvampory")] [assembly: AssemblyTitle("Satisvampory")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.85.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Satisvampory { internal class Buffs { public delegate void BuffCreated(Entity buffEntity); public static bool AddBuff(Entity User, Entity Character, PrefabGUID buffPrefab, float duration = 0f, bool immortal = true) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return FindBuff.TryApply(User, Character, buffPrefab, duration, immortal); } public static void RemoveBuff(Entity Character, PrefabGUID buffPrefab) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) FindBuff.Clear(Character, buffPrefab); } public static void RemoveAndAddBuff(Entity userEntity, Entity targetEntity, PrefabGUID buffPrefab, float duration = -1f, BuffCreated callback = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) FindBuff.Refresh(userEntity, targetEntity, buffPrefab, duration, callback); } } internal static class Const { public static readonly PrefabGUID Buff_InCombat_PvPVampire = new PrefabGUID(697095869); } internal static class Core { private static bool booted; public const int MaxChatReply = 509; internal static bool HasInitialized => booted; public static World Server { get; } = ServerHost.Find("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?"); public static EntityManager EntityManager => Server.EntityManager; public static GameDataSystem GameDataSystem => Server.GetExistingSystemManaged(); public static PrefabCollectionSystem PrefabCollectionSystem { get; set; } public static ServerGameSettingsSystem ServerGameSettingsSystem { get; set; } public static ServerScriptMapper ServerScriptMapper { get; set; } public static DebugEventsSystem DebugEventsSystem { get; set; } public static double ServerTime => ServerGameManager.ServerTime; public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager(); public static ManualLogSource Log => Plugin.LogInstance; public static ConveyorService ConveyorService { get; set; } public static LocalizationService Localization { get; } = new LocalizationService(); public static PlayerSettingsService PlayerSettings { get; } = new PlayerSettingsService(); public static RefinementStationsService RefinementStations { get; set; } public static RegionService RegionService { get; set; } public static SalvageService SalvageService { get; set; } public static StashService Stash { get; } = new StashService(); public static TrashService Trash { get; } = new TrashService(); public static TerritoryService TerritoryService { get; set; } public static UnitSpawnerstationService UnitSpawnerstationService { get; set; } public static BrazierService BrazierService { get; set; } public static WorkQueueService WorkQueue { get; set; } internal static void MarkBooted() { booted = true; } public static void StartCoroutine(IEnumerator routine) { ServerHost.Start(routine); } public static void LogException(Exception e, [CallerMemberName] string caller = null) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ManualLogSource log = Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(51, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failure in "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(caller); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nMessage: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner:"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.InnerException?.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\nStack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.StackTrace); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nInner Stack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.InnerException?.StackTrace); } log.LogError(val); } public static bool TryGetEntityFromNetworkId(NetworkId networkId, out Entity entity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) entity = default(Entity); if (booted) { Singleton singleton = ((ComponentSystemBase)ServerScriptMapper).GetSingleton(); return ((NetworkIdLookupMap)(ref singleton._NetworkIdLookupMap)).TryGetValue(networkId, ref entity); } return false; } public static void Initialize() { if (!booted) { ServerHost.Boot(); } } } public static class ECSExtensions { public static void Write(this Entity entity, T componentData) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Il2CppEntity.Write(entity, componentData); } public static T Read(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Il2CppEntity.Read(entity); } public static DynamicBuffer ReadBuffer(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Il2CppEntity.Buffer(entity); } public static bool Has(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Il2CppEntity.Has(entity); } public static void Add(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Il2CppEntity.Add(entity); } public static void Remove(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Il2CppEntity.Remove(entity); } public static string LookupName(this PrefabGUID prefabGuid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Il2CppEntity.LookupName(prefabGuid); } public static string PrefabName(this PrefabGUID prefabGuid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Il2CppEntity.PrefabName(prefabGuid); } public static string EntityName(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Il2CppEntity.EntityName(entity); } } [BepInPlugin("Satisvampory", "Satisvampory", "1.0.85")] [BepInProcess("VRisingServer.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { public HookDOTS hookDOTS; public static Plugin Instance { get; internal set; } public static Harmony Harmony { get; internal set; } public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log; public override void Load() { Boot(); } public override bool Unload() { return TearDown(); } private void Boot() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown Instance = this; if (Application.productName != "VRisingServer") { ((BasePlugin)this).Log.LogWarning((object)("Satisvampory is a dedicated-server plugin; refusing to load on product '" + Application.productName + "'.")); return; } ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Satisvampory "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.0.85"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("Satisvampory"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") ready."); } log.LogInfo(val); DestDebugLog.Init(); Harmony = new Harmony("Satisvampory"); Harmony.PatchAll(typeof(Plugin).Assembly); CommandRegistry.RegisterAll(typeof(Plugin).Assembly); hookDOTS = new HookDOTS("Satisvampory", ((BasePlugin)this).Log); hookDOTS.RegisterAnnotatedHooks(); } private bool TearDown() { HuntLoginNote.FlushLogouts(); Core.PlayerSettings?.FlushSettings(force: true); DestDebugLog.Close(); CommandRegistry.UnregisterAssembly(); Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } public class Utilities { public static void StashServantInventory(Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (servant == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; Entity val = default(Entity); if (((EntityManager)(ref entityManager)).Exists(servant) && InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, servant, ref val, 0) && !(val == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val)) { Core.Stash.StashServantLoot(servant); } } } public static Dictionary> GetItemStashesOnTerritory(int territoryId) { return InventoryMove.CollectOccupiedChests(territoryId); } public static void StashInventoryEntity(Entity inventory, Dictionary> itemInventories, List overflows) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) InventoryMove.DrainInventoryToMatches(inventory, itemInventories, overflows); } public static void StashInventoryEntity(Entity entityWithTerritory, Entity inventory, string overflowStashName) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) InventoryMove.DrainInventoryByName(entityWithTerritory, inventory, overflowStashName); } public static bool TerritoryCheck(Entity character, Entity target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (character == Entity.Null || target == Entity.Null) { return false; } if (!target.Has() || !character.Has()) { return false; } CastleHeartConnection val = target.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.CastleHeartEntity)).GetEntityOnServer(); if (entityOnServer == Entity.Null || !entityOnServer.Has()) { return false; } int2 tile = character.Read().Tile; Entity castleTerritoryEntity = entityOnServer.Read().CastleTerritoryEntity; CastleTerritory val2 = default(CastleTerritory); return CastleTerritoryExtensions.IsTileInTerritory(Core.EntityManager, tile, ref castleTerritoryEntity, ref val2); } public static bool SharedHeartConnection(Entity input, Entity output) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (input == Entity.Null || output == Entity.Null) { return false; } if (!input.Has() || !output.Has()) { return false; } Entity entity = input.Read().CastleHeartEntity._Entity; Entity entity2 = output.Read().CastleHeartEntity._Entity; if (entity != Entity.Null) { return ((Entity)(ref entity)).Equals(entity2); } return false; } public static bool TransferItemEntities(Entity outputInventory, Entity inputInventory, PrefabGUID itemPrefab, int transferAmount, ref int startInputSlot, out int amountTransferred) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (transferAmount <= 0) { amountTransferred = 0; return false; } amountTransferred = InventoryMove.RelocateEntities(outputInventory, inputInventory, itemPrefab, transferAmount, ref startInputSlot); if (startInputSlot >= inputInventory.ReadBuffer().Length) { return amountTransferred < transferAmount; } return false; } public static int TransferItems(ServerGameManager serverGameManager, Entity outputInventory, Entity inputInventory, PrefabGUID itemGuid, int transferAmount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return InventoryMove.CopyStacks(serverGameManager, outputInventory, inputInventory, itemGuid, transferAmount); } public static AddItemSettings GetAddItemSettings() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return InventoryMove.BuildAddSettings(); } public static void SendSystemMessageToClient(EntityManager entityManager, User user, string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) InventoryMove.Tell(entityManager, user, message); } public static bool IsRoomOfType(Entity roomEntity, CastleFloorTypes floorType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return InventoryMove.EnclosedFloorsMatch(roomEntity, floorType); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Satisvampory"; public const string PLUGIN_NAME = "Satisvampory"; public const string PLUGIN_VERSION = "1.0.85"; } } namespace Satisvampory.Services { internal static class AdminGive { public static void IntoPlot(Entity character, PrefabGUID item, int amount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) if (character == Entity.Null || !character.Has()) { return; } User val = character.Read().UserEntity.Read(); int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(character); if (standingTerritoryId < 0) { PlayerActionGate.Deny(val, "Unable to stash outside territories!"); return; } if (Core.TerritoryService.GetCastleHeart(standingTerritoryId) == Entity.Null) { PlayerActionGate.Deny(val, "There is no heart on this territory!"); return; } ServerGameManager serverGameManager = Core.ServerGameManager; int num = amount; Dictionary dictionary = new Dictionary(); Entity key; foreach (Entity item2 in Core.Stash.ChestsOnPlot(standingTerritoryId)) { string name = StashRouting.RawName(item2); if (StashRouting.IsSpecialName(name) || StashRouting.IsOverflowName(name) || !StashRouting.TryGetExternalInventory(item2, out key)) { continue; } try { AddItemResponse val2 = ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(item2, item, num); if (((AddItemResponse)(ref val2)).Success) { int num2 = num - val2.RemainingAmount; num = val2.RemainingAmount; dictionary.TryGetValue(item2, out var value); dictionary[item2] = value + num2; if (num <= 0) { break; } } } catch (Exception e) { Core.LogException(e, "AdminGive"); } } if (num > 0) { foreach (Entity item3 in Core.Stash.OverflowChests(standingTerritoryId)) { try { AddItemResponse val3 = ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(item3, item, num); if (((AddItemResponse)(ref val3)).Success) { int num3 = num - val3.RemainingAmount; num = val3.RemainingAmount; dictionary.TryGetValue(item3, out var value2); dictionary[item3] = value2 + num3; if (num <= 0) { break; } } } catch (Exception e2) { Core.LogException(e2, "AdminGive overflow"); } } } if (dictionary.Count == 0) { PlayerActionGate.Deny(val, "No items were able to admin stash!"); } else { PlayerActionGate.Deny(val, "Admin stashed items to the current territory!"); } if (Core.PlayerSettings.IsSilentStashEnabled(val.PlatformId)) { return; } foreach (KeyValuePair item4 in dictionary) { item4.Deconstruct(out key, out var value3); Entity entity = key; int value4 = value3; Utilities.SendSystemMessageToClient(Core.EntityManager, val, $"Admin Stashed {value4}x {item.PrefabName()} to {entity.EntityName()}"); } if (num > 0) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, $"Unable to admin stash {num}x {item.PrefabName()} due to insufficient space in stashes!"); } } } internal struct BeltSink { public Entity Inventory; public PrefabGUID Item; public int Wanted; public bool Chest; public bool Unlimited => Wanted < 0; public bool StillOpen => Wanted != 0; public BeltSink(Entity inventory, PrefabGUID item, int wanted, bool chest) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Inventory = inventory; Item = item; Wanted = wanted; Chest = chest; } } internal sealed class BeltBook { private readonly Dictionary<(int group, int hash), List> grouped = new Dictionary<(int, int), List>(); public int Count => grouped.Count; public void Want(int group, PrefabGUID item, Entity inventory, int amount, bool chest) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!(inventory == Entity.Null) && ((PrefabGUID)(ref item)).GuidHash != 0) { (int, int) key = (group, ((PrefabGUID)(ref item)).GuidHash); if (!grouped.TryGetValue(key, out var value)) { value = new List(); grouped[key] = value; } value.Add(new BeltSink(inventory, item, amount, chest)); } } public bool TryGrouped(int group, PrefabGUID item, out List sinks) { return grouped.TryGetValue((group, ((PrefabGUID)(ref item)).GuidHash), out sinks); } public Dictionary>> FlattenByItem() { Dictionary>> dictionary = new Dictionary>>(); foreach (KeyValuePair<(int, int), List> item2 in grouped) { int item = item2.Key.Item2; if (!dictionary.TryGetValue(item, out var value)) { value = (dictionary[item] = new List>()); } value.Add(item2.Value); } return dictionary; } } internal static class BeltOwner { public static bool TryPlatform(Entity castleHeart, out ulong platformId) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) platformId = 0uL; if (castleHeart == Entity.Null || !castleHeart.Has()) { return false; } UserOwner val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer == Entity.Null || !entityOnServer.Has()) { return false; } platformId = entityOnServer.Read().PlatformId; return true; } public static bool ConveyorOn(ulong platformId) { if (Core.PlayerSettings.IsConveyorEnabled(0uL)) { return Core.PlayerSettings.IsConveyorEnabled(platformId); } return false; } } internal static class BeltInspect { private const int FeedBurst = 5; public static List Product(int standingTerritoryId, PrefabGUID product) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) List list = new List(); string text = StashRouting.ItemLabel(product); if (standingTerritoryId < 0) { list.Add("You must stand on a castle plot to troubleshoot conveyors."); return list; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(standingTerritoryId); if (logisticsTerritoryIds == null || logisticsTerritoryIds.Count == 0) { list.Add("You must stand on a castle plot to troubleshoot conveyors."); return list; } Entity castleHeart = Core.TerritoryService.GetCastleHeart(standingTerritoryId); ulong num = 0uL; EntityManager entityManager; if (castleHeart != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { UserOwner val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has()) { num = entityOnServer.Read().PlatformId; } } } } bool flag = Core.PlayerSettings.IsConveyorEnabled(0uL) && (num == 0L || Core.PlayerSettings.IsConveyorEnabled(num)); BeltCounts.OfPlots(logisticsTerritoryIds).TryGetValue(product, out var value); int cap; bool hasPlotCap = Core.PlayerSettings.TryGetItemCap(num, product, out cap); List list2 = new List(); HashSet hashSet = new HashSet(); foreach (int item13 in logisticsTerritoryIds) { foreach (Entity item14 in Core.RefinementStations.BenchesOnPlot(item13)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(item14) && !item14.Has() && item14.Has() && item14.Has() && hashSet.Add(item14)) { list2.Add(item14); } } } List<(Entity, string, HashSet, bool, bool, bool, int?, List, Dictionary, Dictionary)> list3 = new List<(Entity, string, HashSet, bool, bool, bool, int?, List, Dictionary, Dictionary)>(); foreach (Entity item15 in list2) { if (TryDescribeStationRecipe(item15, product, num, value, hasPlotCap, cap, out var recipeOn, out var plotCap, out var outputFull, out var capNumber, out var inputs, out var inputAtFeedCap, out var stationHave)) { string item = item15.EntityName(); HashSet item2 = CollectReceiverGroups(item15); list3.Add((item15, item, item2, recipeOn, plotCap, outputFull, capNumber, inputs, inputAtFeedCap, stationHave)); } } if (list3.Count == 0) { list.Add("No fabricator/station on these plots is set up to make " + text + "."); return list; } for (int i = 0; i < 2; i++) { foreach (var item16 in list3) { Entity item3 = item16.Item1; string item4 = item16.Item2; HashSet item5 = item16.Item3; bool item6 = item16.Item4; bool item7 = item16.Item5; bool item8 = item16.Item6; int? item9 = item16.Item7; List item10 = item16.Rest.Item1; Dictionary item11 = item16.Rest.Item2; Dictionary item12 = item16.Rest.Item3; if ((i == 0 && !item6) || (i == 1 && item6)) { continue; } if (!item6) { list.Add(item4 + " is not making " + text + ". Recipe is off."); } else if (item7) { if (item9.HasValue) { list.Add($"{item4} is making {text}. Not taking more, plot cap {item9.Value}."); } else { list.Add(item4 + " is making " + text + ". Not taking more, plot cap."); } } else if (item8) { list.Add(item4 + " is making " + text + ". Not taking more, output full."); } else { list.Add(item4 + " is making " + text + "."); } if (item5.Count == 0) { continue; } List<(Entity, string, int)> list4 = CollectMatchingSenders(logisticsTerritoryIds, item5); Refinementstation val2 = item3.Read(); Entity entityOnServer2 = ((NetworkedEntity)(ref val2.InputInventoryEntity)).GetEntityOnServer(); foreach (PrefabGUID item17 in item10) { string value2 = StashRouting.ItemLabel(item17); bool value3; bool flag2 = item11.TryGetValue(item17, out value3) && value3; bool flag3 = InventoryCanAccept(entityOnServer2, item17); foreach (var (stash, value4, territoryId) in list4) { SnapshotStashItem(stash, item17, out var have, out var stackableHave); if (have > 0) { if (!Core.TerritoryService.TryGetTerritoryOwnerPlatformId(territoryId, out var platformId)) { platformId = num; } int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, item17); int num2 = Math.Max(0, have - pullReserve); bool flag4 = stackableHave <= 0; string value5; if (!item6) { value5 = "Not moving, recipe off."; } else if (item7) { value5 = "Not moving, plot cap."; } else if (item8) { value5 = "Not moving, output full."; } else if (!flag2) { value5 = ((num2 <= 0) ? $"Not moving, reserve {pullReserve}." : ((!flag) ? "Not moving, conveyor off." : (flag4 ? "Not moving, unique." : (flag3 ? ("Sending to " + item4 + ".") : "Not moving, no room.")))); } else { item12.TryGetValue(item17, out var value6); value5 = $"Ready to move more, station already has {value6}."; } list.Add($"{value2}: {value4} has {have}. {value5}"); } } } } } return list; } private static bool TryDescribeStationRecipe(Entity station, PrefabGUID product, ulong platformID, int haveProduct, bool hasPlotCap, int plotCapAmt, out bool recipeOn, out bool plotCap, out bool outputFull, out int? capNumber, out List inputs, out Dictionary inputAtFeedCap, out Dictionary stationHave) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) recipeOn = false; plotCap = false; outputFull = false; capNumber = null; inputs = new List(); inputAtFeedCap = new Dictionary(); stationHave = new Dictionary(); DynamicBuffer val = station.ReadBuffer(); float num = 1f; if (station.Has()) { CastleWorkstation val2 = station.Read(); if (((Enum)val2.WorkstationLevel).HasFlag((Enum)(object)(WorkstationLevel)2)) { num = 0.75f; } } Refinementstation val3 = station.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val3.InputInventoryEntity)).GetEntityOnServer(); Entity entityOnServer2 = ((NetworkedEntity)(ref val3.OutputInventoryEntity)).GetEntityOnServer(); DynamicBuffer val4 = default(DynamicBuffer); EntityManager entityManager = Core.EntityManager; int num2; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { ServerGameManager serverGameManager = Core.ServerGameManager; num2 = (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(entityOnServer, ref val4) ? 1 : 0); } else { num2 = 0; } bool flag = (byte)num2 != 0; List list = new List(); List list2 = new List(); HashSet seen = new HashSet(); HashSet seen2 = new HashSet(); bool flag2 = false; bool flag3 = false; bool flag4 = false; Dictionary dictionary = new Dictionary(); Enumerator enumerator = val.GetEnumerator(); Entity val5 = default(Entity); PrefabGUID itemType; while (enumerator.MoveNext()) { RefinementstationRecipesBuffer current = enumerator.Current; if (!current.Unlocked || !Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(current.RecipeGuid, ref val5) || val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has()) { continue; } DynamicBuffer val6 = val5.ReadBuffer(); bool flag5 = false; int num3 = 1; for (int i = 0; i < val6.Length; i++) { RecipeOutputBuffer val7 = val6[i]; if (((PrefabGUID)(ref val7.Guid)).Equals(product)) { flag5 = true; num3 = val7.Amount; if (num3 <= 0) { num3 = 1; } break; } } if (!flag5) { continue; } if (current.Disabled) { flag4 = true; CollectRequirements(val5, list2, seen2); continue; } recipeOn = true; CollectRequirements(val5, list, seen); int num4 = int.MaxValue; bool flag6 = false; if (hasPlotCap) { if (haveProduct >= plotCapAmt) { flag3 = true; continue; } num4 = plotCapAmt - haveProduct; flag6 = true; } flag2 = true; if (!val5.Has()) { continue; } Enumerator enumerator2 = val5.ReadBuffer().GetEnumerator(); while (enumerator2.MoveNext()) { RecipeRequirementBuffer current2 = enumerator2.Current; int num5 = Mathf.RoundToInt((float)current2.Amount * num); int num6 = 5 * num5; if (flag6) { int num7 = num4 * num5 / num3; if (num7 < num6) { num6 = num7; } } if (flag) { Enumerator enumerator3 = val4.GetEnumerator(); while (enumerator3.MoveNext()) { InventoryBuffer current3 = enumerator3.Current; itemType = current3.ItemType; if (((PrefabGUID)(ref itemType)).Equals(current2.Guid)) { num6 -= current3.Amount; } } } dictionary.TryGetValue(current2.Guid, out var value); if (num6 > value) { dictionary[current2.Guid] = num6; } } } if (!recipeOn && !flag4) { return false; } inputs = (recipeOn ? list : list2); foreach (PrefabGUID input in inputs) { dictionary.TryGetValue(input, out var value2); inputAtFeedCap[input] = recipeOn && value2 <= 0; int num8 = 0; if (flag) { Enumerator enumerator3 = val4.GetEnumerator(); while (enumerator3.MoveNext()) { InventoryBuffer current5 = enumerator3.Current; itemType = current5.ItemType; if (((PrefabGUID)(ref itemType)).Equals(input)) { num8 += current5.Amount; } } } stationHave[input] = num8; } outputFull = recipeOn && !InventoryCanAccept(entityOnServer2, product); bool flag7 = hasPlotCap && haveProduct >= plotCapAmt; plotCap = recipeOn && (flag7 || (flag3 && !flag2)); if (plotCap && hasPlotCap) { capNumber = plotCapAmt; } return true; } private static void CollectRequirements(Entity recipeEntity, List inputs, HashSet seen) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (!recipeEntity.Has()) { return; } Enumerator enumerator = recipeEntity.ReadBuffer().GetEnumerator(); while (enumerator.MoveNext()) { RecipeRequirementBuffer current = enumerator.Current; PrefabGUID guid = current.Guid; if (((PrefabGUID)(ref guid)).GuidHash != 0) { guid = current.Guid; if (seen.Add(((PrefabGUID)(ref guid)).GuidHash)) { inputs.Add(current.Guid); } } } } private static HashSet CollectReceiverGroups(Entity station) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); string text = StashRouting.RawName(station); if (string.IsNullOrEmpty(text) || Core.Stash?.ReceiveToken == null) { return hashSet; } foreach (Match item in Core.Stash.ReceiveToken.Matches(text.ToLower())) { if (int.TryParse(item.Groups[1].Value, out var result)) { hashSet.Add(result); } } return hashSet; } private static List<(Entity stash, string name, int territoryId)> CollectMatchingSenders(IReadOnlyList logisticsIds, HashSet receiverGroups) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) List<(Entity, string, int)> list = new List<(Entity, string, int)>(); HashSet hashSet = new HashSet(); foreach (int logisticsId in logisticsIds) { foreach (var (item, val) in Core.Stash.SendChests(logisticsId)) { if (receiverGroups.Contains(item)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val) && hashSet.Add(val)) { list.Add((val, val.EntityName(), logisticsId)); } } } } return list; } private unsafe static void SnapshotStashItem(Entity stash, PrefabGUID item, out int have, out int stackableHave) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) have = 0; stackableHave = 0; ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(stash, ref val)) { return; } Enumerator enumerator = val.GetEnumerator(); DynamicBuffer val3 = default(DynamicBuffer); while (enumerator.MoveNext()) { Entity entity = enumerator.Current.Entity; if (!entity.Has()) { continue; } PrefabGUID val2 = entity.Read(); if (!((PrefabGUID)(ref val2)).Equals(StashService.ChestBagGuid)) { continue; } serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(entity, ref val3)) { continue; } Enumerator enumerator2 = val3.GetEnumerator(); while (enumerator2.MoveNext()) { InventoryBuffer current = enumerator2.Current; val2 = current.ItemType; if (!((PrefabGUID)(ref val2)).Equals(item)) { continue; } have += current.Amount; NetworkedEntity itemEntity = current.ItemEntity; if (!((object)(*(NetworkedEntity*)(&itemEntity))/*cast due to .constrained prefix*/).Equals((object?)NetworkedEntity.Empty)) { val2 = current.ItemType; if (!((PrefabGUID)(ref val2)).Equals(BeltSplit.SiegeGolemT02)) { continue; } } stackableHave += current.Amount; } } } private unsafe static bool InventoryCanAccept(Entity inventory, PrefabGUID item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (!((Entity)(ref inventory)).Equals(Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inventory)) { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val)) { return false; } Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { InventoryBuffer current = enumerator.Current; PrefabGUID itemType = current.ItemType; if (((PrefabGUID)(ref itemType)).GuidHash == 0) { return true; } itemType = current.ItemType; if (((PrefabGUID)(ref itemType)).Equals(item)) { NetworkedEntity itemEntity = current.ItemEntity; if (((object)(*(NetworkedEntity*)(&itemEntity))/*cast due to .constrained prefix*/).Equals((object?)NetworkedEntity.Empty)) { return true; } } } return false; } } return false; } public static List Need(int standingTerritoryId, int topN = 10) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: Unknown result type (might be due to invalid IL or missing references) //IL_07b5: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (standingTerritoryId < 0) { list.Add("You must stand on a castle plot to list conveyor need."); return list; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(standingTerritoryId); if (logisticsTerritoryIds == null || logisticsTerritoryIds.Count == 0) { list.Add("You must stand on a castle plot to list conveyor need."); return list; } Entity castleHeart = Core.TerritoryService.GetCastleHeart(standingTerritoryId); ulong num = 0uL; EntityManager entityManager; if (castleHeart != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { UserOwner val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has()) { num = entityOnServer.Read().PlatformId; } } } } Dictionary dictionary = new Dictionary(); Dictionary dictionary2 = new Dictionary(); List<(PrefabGUID, List)> list2 = new List<(PrefabGUID, List)>(); Dictionary> dictionary3 = new Dictionary>(); foreach (int item6 in logisticsTerritoryIds) { dictionary3[item6] = BeltCounts.OfPlot(item6); } Dictionary dictionary4 = BeltCounts.OfPlots(logisticsTerritoryIds); Entity val5 = default(Entity); foreach (int item7 in logisticsTerritoryIds) { foreach (var item8 in Core.RefinementStations.ReceiveBenches(item7)) { Entity item = item8.station; entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(item) || item.Has() || !item.Has() || !item.Has() || !item.Has()) { continue; } Refinementstation val2 = item.Read(); CastleWorkstation val3 = item.Read(); float num2 = (((Enum)val3.WorkstationLevel).HasFlag((Enum)(object)(WorkstationLevel)2) ? 0.75f : 1f); Entity entityOnServer2 = ((NetworkedEntity)(ref val2.InputInventoryEntity)).GetEntityOnServer(); int num3; if (entityOnServer2 != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer2)) { num3 = (entityOnServer2.Has() ? 1 : 0); goto IL_020c; } } num3 = 0; goto IL_020c; IL_020c: bool flag = (byte)num3 != 0; NativeArray val4 = default(NativeArray); if (flag) { val4 = entityOnServer2.ReadBuffer().ToNativeArray(AllocatorHandle.op_Implicit((Allocator)2)); } try { Enumerator enumerator3 = item.ReadBuffer().GetEnumerator(); while (enumerator3.MoveNext()) { RefinementstationRecipesBuffer current3 = enumerator3.Current; if (!current3.Unlocked || current3.Disabled || !Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(current3.RecipeGuid, ref val5) || val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5)) { continue; } int num4 = int.MaxValue; int num5 = 1; bool flag2 = false; PrefabGUID val6 = default(PrefabGUID); if (val5.Has()) { DynamicBuffer val7 = val5.ReadBuffer(); if (val7.Length > 0) { RecipeOutputBuffer val8 = val7[0]; val6 = val8.Guid; num5 = ((val8.Amount <= 0) ? 1 : val8.Amount); if (((PrefabGUID)(ref val6)).GuidHash != 0 && Core.PlayerSettings.TryGetItemCap(num, val6, out var cap)) { dictionary4.TryGetValue(val6, out var value); if (value >= cap) { continue; } num4 = cap - value; flag2 = true; } } } List list3 = new List(); if (!val5.Has()) { continue; } Enumerator enumerator4 = val5.ReadBuffer().GetEnumerator(); while (enumerator4.MoveNext()) { RecipeRequirementBuffer current4 = enumerator4.Current; PrefabGUID guid = current4.Guid; if (((PrefabGUID)(ref guid)).GuidHash == 0) { continue; } list3.Add(current4.Guid); int num6 = Mathf.RoundToInt((float)current4.Amount * num2); int num7 = 5 * num6; if (flag2) { int num8 = num4 * num6 / num5; if (num8 < num7) { num7 = num8; } } if (flag) { for (int i = 0; i < val4.Length; i++) { InventoryBuffer val9 = val4[i]; if (((PrefabGUID)(ref val9.ItemType)).Equals(current4.Guid)) { num7 -= val4[i].Amount; } } } if (num7 > 0) { guid = current4.Guid; dictionary.TryGetValue(((PrefabGUID)(ref guid)).GuidHash, out var value2); guid = current4.Guid; dictionary[((PrefabGUID)(ref guid)).GuidHash] = value2 + num7; } } if (((PrefabGUID)(ref val6)).GuidHash != 0) { list2.Add((val6, list3)); } } } finally { if (val4.IsCreated) { val4.Dispose(); } } } } if (dictionary.Count == 0) { list.Add("No hungry receiving stations (name them r# with unlocked recipes, or they are already fed / capped)."); return list; } for (int j = 0; j < 8; j++) { bool flag3 = false; foreach (var item9 in list2) { PrefabGUID item2 = item9.Item1; List item3 = item9.Item2; int num9 = 0; foreach (PrefabGUID item10 in item3) { PrefabGUID current6 = item10; dictionary2.TryGetValue(((PrefabGUID)(ref current6)).GuidHash, out var value3); if (value3 > num9) { num9 = value3; } } int num10 = num9 + 1; dictionary2.TryGetValue(((PrefabGUID)(ref item2)).GuidHash, out var value4); if (num10 > value4) { dictionary2[((PrefabGUID)(ref item2)).GuidHash] = num10; flag3 = true; } } if (!flag3) { break; } } List<(int, int, int, int, int, int, float)> list4 = new List<(int, int, int, int, int, int, float)>(); PrefabGUID val10 = default(PrefabGUID); ItemData val11 = default(ItemData); foreach (KeyValuePair item11 in dictionary) { ((PrefabGUID)(ref val10))..ctor(item11.Key); int num11 = 0; int num12 = 0; int item4 = 0; foreach (int item12 in logisticsTerritoryIds) { Core.TerritoryService.TryGetTerritoryOwnerPlatformId(item12, out var platformId); if (platformId == 0L) { platformId = num; } int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, val10); if (item12 == standingTerritoryId) { item4 = pullReserve; } dictionary3.TryGetValue(item12, out var value5); int value6 = 0; value5?.TryGetValue(val10, out value6); num11 += value6; int num13 = value6 - pullReserve; if (num13 > 0) { num12 += num13; } } dictionary2.TryGetValue(item11.Key, out var value7); float item5 = 0f; try { if (Core.GameDataSystem.ItemHashLookupMap.TryGetValue(val10, ref val11)) { item5 = val11.SilverValue; } } catch { } list4.Add((item11.Key, item11.Value, num11, num12, item4, value7, item5)); } list4.Sort(delegate((int guid, int want, int have, int takeable, int reserve, int depth, float silver) a, (int guid, int want, int have, int takeable, int reserve, int depth, float silver) b) { int num16 = b.depth.CompareTo(a.depth); if (num16 != 0) { return num16; } num16 = b.silver.CompareTo(a.silver); if (num16 != 0) { return num16; } num16 = a.takeable.CompareTo(b.takeable); return (num16 != 0) ? num16 : b.want.CompareTo(a.want); }); string value8 = ((logisticsTerritoryIds.Count > 1) ? "clan island" : "this plot"); int num14 = ((list4.Count < topN) ? list4.Count : topN); list.Add($"Top {num14} conveyor need on {value8} (higher tier, then lowest stock after reserve):"); for (int num15 = 0; num15 < num14; num15++) { (int, int, int, int, int, int, float) tuple = list4[num15]; string value9 = StashRouting.ItemLabel(new PrefabGUID(tuple.Item1)); list.Add($"{num15 + 1}. {value9} T{tuple.Item6} demand {tuple.Item2} total {tuple.Item3} reserve {tuple.Item5}"); } return list; } } internal static class BeltRun { private const int StationFeedMul = 5; private const int SpawnerFeedMul = 2; private const int BrazierMin = 10; private static readonly HashSet clanConsumed = new HashSet(); private static int clanGeneration = -1; private static readonly HashSet salvagerFull = new HashSet(); private static readonly HashSet<(Entity entity, PrefabGUID item)> salvagerFullOfItem = new HashSet<(Entity, PrefabGUID)>(); private static readonly Dictionary salvageDiagAt = new Dictionary(); private const float SalvageDiagCooldown = 30f; private static bool SkipClanPlot(int territoryId) { int num = ((Core.WorkQueue != null) ? Core.WorkQueue.DrainGeneration : 0); if (num != clanGeneration) { clanConsumed.Clear(); clanGeneration = num; return false; } return clanConsumed.Contains(territoryId); } private static void MarkClanSiblings(int territoryId, IReadOnlyList plots) { int num = ((Core.WorkQueue != null) ? Core.WorkQueue.DrainGeneration : 0); if (num != clanGeneration) { clanConsumed.Clear(); clanGeneration = num; } if (plots == null || plots.Count <= 1) { return; } for (int i = 0; i < plots.Count; i++) { if (plots[i] != territoryId) { clanConsumed.Add(plots[i]); } } } public static IEnumerator Stations(int territoryId, Entity castleHeart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!BeltOwner.TryPlatform(castleHeart, out var ownerId) || !BeltOwner.ConveyorOn(ownerId) || SkipClanPlot(territoryId)) { yield break; } IReadOnlyList plots = Core.TerritoryService.GetLogisticsTerritoryIds(territoryId); MarkClanSiblings(territoryId, plots); ServerGameManager sgm = Core.ServerGameManager; Dictionary counts = Core.ConveyorService.CountTerritoryItems(plots); BeltBook book = new BeltBook(); CollectStationWants(plots, ownerId, counts, book); CollectChestWants(plots, ownerId, counts, book, sgm); if (book.Count == 0) { yield break; } Dictionary>> ungrouped = null; Entity[] overflow = CollectOverflow(plots); EntityManager entityManager; foreach (Entity val in overflow) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val) && !ClanTreasuryLend.HoldKitOverflow(Core.TerritoryService.GetTerritoryId(val)) && StashRouting.TryGetExternalInventory(val, out var inventory)) { BeltSplit.FromOverflow(book, sgm, inventory, ref ungrouped); if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; } } } foreach (int item5 in plots) { foreach (var item6 in Core.RefinementStations.SendBenches(item5)) { int item = item6.group; Entity item2 = item6.station; entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(item2) || !item2.Has()) { continue; } Refinementstation val2 = item2.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val2.OutputInventoryEntity)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { BeltSplit.FromGroup(book, sgm, item, entityOnServer, overflow, ownerId, chest: false, applyReserve: false, default(Entity)); if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; } } } } Entity[] none = Array.Empty(); foreach (int item7 in plots) { if (!Core.TerritoryService.TryGetTerritoryOwnerPlatformId(item7, out var sourceOwner)) { sourceOwner = ownerId; } foreach (var item8 in Core.Stash.SendChests(item7)) { int item3 = item8.group; Entity item4 = item8.station; entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(item4) && !item4.Has() && StashRouting.TryGetExternalInventory(item4, out var inventory2)) { BeltSplit.FromGroup(book, sgm, item3, inventory2, none, sourceOwner, chest: true, applyReserve: true, item4); if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; } } } } } private static void CollectStationWants(IReadOnlyList plots, ulong ownerId, Dictionary counts, BeltBook book) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) DynamicBuffer val2 = default(DynamicBuffer); Entity entity2 = default(Entity); foreach (int plot in plots) { foreach (var (num, entity) in Core.RefinementStations.ReceiveBenches(plot)) { if (!entity.Has() || !entity.Has() || !entity.Has()) { continue; } Refinementstation val = entity.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.InputInventoryEntity)).GetEntityOnServer(); if (entityOnServer == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entityOnServer)) { continue; } float num2 = (((Enum)entity.Read().WorkstationLevel).HasFlag((Enum)(object)(WorkstationLevel)2) ? 0.75f : 1f); ServerGameManager serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(entityOnServer, ref val2)) { continue; } DynamicBuffer val3 = entity.ReadBuffer(); for (int i = 0; i < val3.Length; i++) { RefinementstationRecipesBuffer val4 = val3[i]; if (!val4.Unlocked || val4.Disabled || !Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(val4.RecipeGuid, ref entity2)) { continue; } int num3 = int.MaxValue; int num4 = 1; bool flag = false; if (entity2.Has()) { DynamicBuffer val5 = entity2.ReadBuffer(); if (val5.Length > 0) { RecipeOutputBuffer val6 = val5[0]; if (((PrefabGUID)(ref val6.Guid)).GuidHash != 0 && Core.PlayerSettings.TryGetItemCap(ownerId, val5[0].Guid, out var cap)) { counts.TryGetValue(val5[0].Guid, out var value); if (value >= cap) { continue; } num3 = cap - value; num4 = ((val5[0].Amount <= 0) ? 1 : val5[0].Amount); flag = true; } } } if (!entity2.Has()) { continue; } DynamicBuffer val7 = entity2.ReadBuffer(); for (int j = 0; j < val7.Length; j++) { RecipeRequirementBuffer val8 = val7[j]; int num5 = Mathf.RoundToInt((float)val8.Amount * num2); int num6 = 5 * num5; if (flag) { int num7 = num3 * num5 / num4; if (num7 < num6) { num6 = num7; } } for (int k = 0; k < val2.Length; k++) { InventoryBuffer val9 = val2[k]; if (((PrefabGUID)(ref val9.ItemType)).Equals(val8.Guid)) { num6 -= val2[k].Amount; } } if (num6 > 0) { book.Want(num, val8.Guid, entityOnServer, num6, chest: false); } } } } } } private static void CollectChestWants(IReadOnlyList plots, ulong ownerId, Dictionary counts, BeltBook book, ServerGameManager sgm) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); DynamicBuffer val = default(DynamicBuffer); foreach (int plot in plots) { foreach (var item in Core.Stash.ReceiveChests(plot)) { var (num, _) = item; if (!StashRouting.TryGetExternalInventory(item.station, out var inventory) || !((ServerGameManager)(ref sgm)).TryGetBuffer(inventory, ref val)) { continue; } hashSet.Clear(); for (int i = 0; i < val.Length; i++) { PrefabGUID itemType = val[i].ItemType; if (((PrefabGUID)(ref itemType)).GuidHash == 0 || !hashSet.Add(itemType)) { continue; } if (Core.PlayerSettings.TryGetItemCap(ownerId, itemType, out var cap)) { counts.TryGetValue(itemType, out var value); if (value < cap) { book.Want(num, itemType, inventory, cap - value, chest: true); } } else { book.Want(num, itemType, inventory, -1, chest: true); } } } } } private static Entity[] CollectOverflow(IReadOnlyList plots) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (int plot in plots) { foreach (Entity item in Core.Stash.OverflowChests(plot)) { list.Add(item); } } return list.ToArray(); } private static bool SalvageEligible(Entity prefab) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 if (prefab == Entity.Null) { return false; } if (prefab.Has()) { return true; } if (prefab.Has()) { return (int)prefab.Read().ItemType == 5; } return false; } private static void LogSalvage(int territoryId, string message) { float realtimeSinceStartup = Time.realtimeSinceStartup; if (!salvageDiagAt.TryGetValue(territoryId, out var value) || !(realtimeSinceStartup - value < 30f)) { salvageDiagAt[territoryId] = realtimeSinceStartup; Core.Log.LogInfo((object)message); } } public unsafe static IEnumerator Salvagers(int territoryId, Entity castleHeart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!BeltOwner.TryPlatform(castleHeart, out var platformId) || !Core.PlayerSettings.IsGlobalSalvageEnabled() || !Core.PlayerSettings.GetPlotSalvageFlag(platformId, territoryId)) { yield break; } List suppliers = new List(Core.Stash.SalvageChests(territoryId)); List<(Entity entity, Salvagestation station, int index)> stations = new List<(Entity, Salvagestation, int)>(); int num = 0; foreach (Entity allSalvageStation in Core.SalvageService.GetAllSalvageStations(territoryId)) { stations.Add((allSalvageStation, allSalvageStation.Read(), num)); num++; } if (suppliers.Count == 0 && stations.Count == 0) { yield break; } Dictionary> itemStashes = Utilities.GetItemStashesOnTerritory(territoryId); List overflows = new List(Core.Stash.OverflowChests(territoryId)); EntityManager entityManager; for (int i = 0; i < stations.Count; i++) { Entity item = stations[i].entity; entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(item)) { continue; } (Entity, Salvagestation, int) tuple = stations[i]; Entity entityOnServer = ((NetworkedEntity)(ref tuple.Item2.OutputInventoryEntity)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { Utilities.StashInventoryEntity(entityOnServer, itemStashes, overflows); if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; } } } salvagerFull.Clear(); salvagerFullOfItem.Clear(); Dictionary pending = new Dictionary(); DynamicBuffer val3 = default(DynamicBuffer); Entity prefab = default(Entity); for (int i = 0; i < suppliers.Count; i++) { Entity val = suppliers[i]; if (!StashRouting.TryGetExternalInventory(val, out var inv)) { continue; } object obj; if (!val.Has()) { obj = ""; } else { NameableInteractable val2 = val.Read(); obj = ((object)(*(FixedString64Bytes*)(&val2.Name))/*cast due to .constrained prefix*/).ToString(); } string text = (string)obj; bool flag = !string.IsNullOrEmpty(text) && Core.Stash.ReceiveToken.IsMatch(text.ToLowerInvariant()); pending.Clear(); ServerGameManager serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inv, ref val3)) { continue; } for (int j = 0; j < val3.Length; j++) { InventoryBuffer val4 = val3[j]; if (((PrefabGUID)(ref val4.ItemType)).GuidHash != 0 && val4.Amount > 0 && Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(val4.ItemType, ref prefab) && SalvageEligible(prefab)) { pending.TryGetValue(val4.ItemType, out (bool, int) value); int num2 = value.Item2; if (num2 == 0 && flag) { num2 = -1; } PrefabGUID itemType = val4.ItemType; ref NetworkedEntity itemEntity = ref val4.ItemEntity; object obj2 = NetworkedEntity.Empty; pending[itemType] = (!((object)Unsafe.As(ref itemEntity)/*cast due to .constrained prefix*/).Equals(obj2), num2 + val4.Amount); } } foreach (KeyValuePair item4 in pending) { item4.Deconstruct(out var key, out var value2); PrefabGUID item2 = key; (bool itemEntity, int amount) entry = value2; int left = entry.amount; if (left <= 0) { continue; } int hungry = stations.Count - salvagerFull.Count; if (hungry == 0) { break; } int i2 = stations.Count - 1; while (i2 >= 0 && left > 0) { if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(inv)) { break; } (Entity, Salvagestation, int) tuple2 = stations[i2]; if (!salvagerFull.Contains(tuple2.Item1)) { if (salvagerFullOfItem.Contains((tuple2.Item1, item2))) { hungry--; } else { entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(tuple2.Item1)) { hungry--; } else { Entity entityOnServer2 = ((NetworkedEntity)(ref tuple2.Item2.InputInventoryEntity)).GetEntityOnServer(); int startInputSlot = 0; int num3 = (left + ((!tuple2.Item2.IsWorking) ? (hungry - 1) : (Time.frameCount % hungry))) / hungry; if (num3 != 0) { int amountTransferred; if (entry.itemEntity) { Utilities.TransferItemEntities(inv, entityOnServer2, item2, num3, ref startInputSlot, out amountTransferred); } else { amountTransferred = Utilities.TransferItems(Core.ServerGameManager, inv, entityOnServer2, item2, num3); } hungry--; if (amountTransferred < num3) { serverGameManager = Core.ServerGameManager; if (((ServerGameManager)(ref serverGameManager)).HasFullInventory(entityOnServer2)) { stations.RemoveAt(i2); } else { salvagerFullOfItem.Add((tuple2.Item1, item2)); } } if (amountTransferred != 0) { left -= amountTransferred; if (!tuple2.Item2.IsWorking) { Salvagestation item3 = tuple2.Item2; item3.IsWorking = true; tuple2.Item1.Write(item3); stations[tuple2.Item3] = (tuple2.Item1, item3, tuple2.Item3); } } } } } } i2--; } } if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; } inv = default(Entity); } } public static IEnumerator Spawners(int territoryId, Entity castleHeart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!Core.PlayerSettings.IsUnitSpawnerEnabled(0uL) || !BeltOwner.TryPlatform(castleHeart, out var ownerId) || !Core.PlayerSettings.IsUnitSpawnerEnabled(ownerId)) { yield break; } ServerGameManager sgm = Core.ServerGameManager; Dictionary> wants = new Dictionary>(); DynamicBuffer val = default(DynamicBuffer); Entity entity = default(Entity); foreach (Entity allUnitSpawner in Core.UnitSpawnerstationService.GetAllUnitSpawners(territoryId)) { if (!allUnitSpawner.Has() || !allUnitSpawner.Has()) { continue; } float num = (((Enum)allUnitSpawner.Read().WorkstationLevel).HasFlag((Enum)(object)(WorkstationLevel)2) ? 0.75f : 1f); if (!StashRouting.TryGetExternalInventory(allUnitSpawner, out var inventory) || !((ServerGameManager)(ref sgm)).TryGetBuffer(inventory, ref val)) { continue; } Enumerator enumerator2 = allUnitSpawner.ReadBuffer().GetEnumerator(); while (enumerator2.MoveNext()) { RefinementstationRecipesBuffer current2 = enumerator2.Current; if (!current2.Unlocked || current2.Disabled || !Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(current2.RecipeGuid, ref entity) || !entity.Has()) { continue; } Enumerator enumerator3 = entity.ReadBuffer().GetEnumerator(); while (enumerator3.MoveNext()) { RecipeRequirementBuffer current3 = enumerator3.Current; int num2 = 2 * Mathf.RoundToInt((float)current3.Amount * num); for (int i = 0; i < val.Length; i++) { InventoryBuffer val2 = val[i]; if (((PrefabGUID)(ref val2.ItemType)).Equals(current3.Guid)) { num2 -= val[i].Amount; } } if (num2 > 0) { if (!wants.TryGetValue(current3.Guid, out List<(Entity, int)> value)) { value = new List<(Entity, int)>(); wants[current3.Guid] = value; } value.Add((inventory, num2)); } } } } if (wants.Count == 0) { yield break; } foreach (Entity item in Core.Stash.SpawnerChests(territoryId)) { if (StashRouting.TryGetExternalInventory(item, out var inventory2)) { BeltSplit.Ungrouped(wants, sgm, inventory2, ownerId, applyReserve: true); if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; } } } } public static IEnumerator Braziers(int territoryId, Entity castleHeart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!Core.PlayerSettings.IsBrazierEnabled(0uL) || !BeltOwner.TryPlatform(castleHeart, out var ownerId) || !Core.PlayerSettings.IsBrazierEnabled(ownerId)) { yield break; } ServerGameManager sgm = Core.ServerGameManager; Dictionary> wants = new Dictionary>(); DynamicBuffer val = default(DynamicBuffer); foreach (Entity allBrazier in Core.BrazierService.GetAllBraziers(territoryId)) { if (!allBrazier.Has() || !allBrazier.Has() || !allBrazier.Read().Enabled || !StashRouting.TryGetExternalInventory(allBrazier, out var inventory) || !((ServerGameManager)(ref sgm)).TryGetBuffer(inventory, ref val)) { continue; } PrefabGUID inputItem = allBrazier.Read().InputItem; int num = 0; for (int i = 0; i < val.Length; i++) { InventoryBuffer val2 = val[i]; if (((PrefabGUID)(ref val2.ItemType)).Equals(inputItem)) { num += val[i].Amount; } } if (num <= 10) { if (!wants.TryGetValue(inputItem, out List<(Entity, int)> value)) { value = (wants[inputItem] = new List<(Entity, int)>()); } value.Add((inventory, 10 - num)); } } if (wants.Count == 0) { yield break; } foreach (Entity item in Core.Stash.BrazierChests(territoryId)) { if (StashRouting.TryGetExternalInventory(item, out var inventory2)) { BeltSplit.Ungrouped(wants, sgm, inventory2, ownerId, applyReserve: true); if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; } } } } } internal static class BeltCounts { private static readonly Dictionary> plotCache = new Dictionary>(); private static int cacheGeneration = int.MinValue; private static void EnsureGeneration() { int num = ((Core.WorkQueue != null) ? Core.WorkQueue.DrainGeneration : 0); if (num != cacheGeneration) { plotCache.Clear(); cacheGeneration = num; } } public static Dictionary OfPlot(int territoryId) { EnsureGeneration(); if (plotCache.TryGetValue(territoryId, out var value)) { return value; } Dictionary dictionary = ScanPlot(territoryId); plotCache[territoryId] = dictionary; return dictionary; } private static Dictionary ScanPlot(int territoryId) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); foreach (Entity item in Core.Stash.ChestsOnPlot(territoryId)) { if (StashRouting.TryGetExternalInventory(item, out var inventory)) { Add(inventory, dictionary); } } if (Core.RefinementStations == null) { return dictionary; } foreach (Entity item2 in Core.RefinementStations.BenchesOnPlot(territoryId)) { if (item2.Has()) { Refinementstation val = item2.Read(); Add(((NetworkedEntity)(ref val.InputInventoryEntity)).GetEntityOnServer(), dictionary); Add(((NetworkedEntity)(ref val.OutputInventoryEntity)).GetEntityOnServer(), dictionary); } } return dictionary; } public static Dictionary OfPlots(IReadOnlyList plots) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); if (plots == null) { return dictionary; } for (int i = 0; i < plots.Count; i++) { foreach (KeyValuePair item in OfPlot(plots[i])) { dictionary.TryGetValue(item.Key, out var value); dictionary[item.Key] = value + item.Value; } } return dictionary; } private static void Add(Entity inventory, Dictionary counts) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (inventory == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(inventory)) { return; } ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val)) { return; } for (int i = 0; i < val.Length; i++) { PrefabGUID itemType = val[i].ItemType; if (((PrefabGUID)(ref itemType)).GuidHash != 0) { counts.TryGetValue(itemType, out var value); counts[itemType] = value + val[i].Amount; } } } } internal static class BeltSplit { internal static readonly PrefabGUID SiegeGolemT02 = new PrefabGUID(-1461326411); public static Dictionary CountStackable(Entity inventory) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); if (!(inventory == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inventory)) { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val)) { return dictionary; } for (int i = 0; i < val.Length; i++) { InventoryBuffer val2 = val[i]; if (((PrefabGUID)(ref val2.ItemType)).GuidHash != 0) { ref NetworkedEntity itemEntity = ref val2.ItemEntity; object obj = NetworkedEntity.Empty; if (((object)Unsafe.As(ref itemEntity)/*cast due to .constrained prefix*/).Equals(obj) || ((PrefabGUID)(ref val2.ItemType)).Equals(SiegeGolemT02)) { dictionary.TryGetValue(val2.ItemType, out var value); dictionary[val2.ItemType] = value + val2.Amount; } } } return dictionary; } } return dictionary; } public static void HonorReserve(Dictionary amounts, ulong ownerId, bool apply) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (apply && amounts.Count != 0) { List list = new List(amounts.Keys); for (int i = 0; i < list.Count; i++) { PrefabGUID val = list[i]; int num = ((ownerId != 0L) ? Core.PlayerSettings.GetPullReserve(ownerId, val) : 0); amounts[val] = Math.Max(0, amounts[val] - num); } } } private static int Slice(int wanted, int available, int totalWanted, ref int remainder) { if (wanted <= 0 || available <= 0 || totalWanted <= 0) { return 0; } long num = (long)wanted * (long)available; int num2 = (int)(num / totalWanted); remainder += (int)(num % totalWanted); if (remainder >= totalWanted && num2 < wanted) { num2++; remainder -= totalWanted; } return num2; } private static int Move(ServerGameManager sgm, Entity from, Entity to, PrefabGUID item, int amount) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (amount <= 0 || from == Entity.Null || to == Entity.Null) { return 0; } return Utilities.TransferItems(sgm, from, to, item, amount); } private static void DumpToOverflow(ServerGameManager sgm, Entity from, PrefabGUID item, int leftover, Entity[] overflow) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (leftover <= 0 || overflow == null) { return; } for (int i = 0; i < overflow.Length; i++) { if (leftover <= 0) { break; } if (StashRouting.TryGetExternalInventory(overflow[i], out var inventory)) { leftover -= Move(sgm, from, inventory, item, leftover); } } } public static void FromOverflow(BeltBook book, ServerGameManager sgm, Entity inventory, ref Dictionary>> ungrouped) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = CountStackable(inventory); if (dictionary.Count == 0) { return; } if (ungrouped == null) { ungrouped = book.FlattenByItem(); } foreach (KeyValuePair item5 in dictionary) { var (item, num2) = (KeyValuePair)(ref item5); if (!ungrouped.TryGetValue(((PrefabGUID)(ref item)).GuidHash, out var value)) { continue; } List<(int, int, BeltSink)> list = new List<(int, int, BeltSink)>(); for (int i = 0; i < value.Count; i++) { List list2 = value[i]; for (int num3 = list2.Count - 1; num3 >= 0; num3--) { list.Add((i, num3, list2[num3])); } } int num4 = 0; for (int j = 0; j < list.Count; j++) { if (list[j].Item3.Wanted > 0) { num4 += list[j].Item3.Wanted; } } EntityManager entityManager; if (num4 <= num2) { int num5 = num2 - num4; for (int k = 0; k < list.Count; k++) { (int, int, BeltSink) tuple = list[k]; int item2 = tuple.Item1; int item3 = tuple.Item2; BeltSink item4 = tuple.Item3; entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(item4.Inventory)) { value[item2].RemoveAt(item3); } else if (item4.Wanted > 0) { Move(sgm, inventory, item4.Inventory, item, item4.Wanted); value[item2].RemoveAt(item3); } else if (num5 > 0) { int num6 = Move(sgm, inventory, item4.Inventory, item, num5); if (num6 < num5) { value[item2].RemoveAt(item3); } num5 -= num6; } } continue; } int remainder = 0; for (int l = 0; l < list.Count; l++) { var (index, index2, value2) = list[l]; if (value2.Wanted <= 0) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(value2.Inventory)) { num4 -= value2.Wanted; value[index].RemoveAt(index2); continue; } int num7 = Slice(value2.Wanted, num2, num4, ref remainder); int num8 = Move(sgm, inventory, value2.Inventory, item, num7); if (num8 < num7) { remainder += (num7 - num8) * num4; value[index].RemoveAt(index2); } else if (num8 >= value2.Wanted) { value[index].RemoveAt(index2); } else { value2.Wanted -= num8; value[index][index2] = value2; } } } } public static void FromGroup(BeltBook book, ServerGameManager sgm, int group, Entity inventory, Entity[] overflow, ulong ownerId, bool chest, bool applyReserve, Entity sendingStash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = CountStackable(inventory); HonorReserve(dictionary, ownerId, applyReserve); foreach (var (item, num2) in dictionary) { if (num2 <= 0) { continue; } if (!book.TryGrouped(group, item, out var sinks) || sinks == null) { if (!chest) { DumpToOverflow(sgm, inventory, item, num2, overflow); } continue; } int num3 = 0; for (int i = 0; i < sinks.Count; i++) { BeltSink beltSink = sinks[i]; if ((!chest || !beltSink.Chest) && beltSink.Wanted > 0) { num3 += beltSink.Wanted; } } EntityManager entityManager; if (num3 <= num2) { int num4 = ((!chest) ? (num2 - num3) : 0); for (int num5 = sinks.Count - 1; num5 >= 0; num5--) { BeltSink beltSink2 = sinks[num5]; if (!chest || !beltSink2.Chest) { entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(beltSink2.Inventory)) { sinks.RemoveAt(num5); } else if (beltSink2.Wanted > 0) { int num6 = Move(sgm, inventory, beltSink2.Inventory, item, beltSink2.Wanted); if (chest && num6 > 0 && sendingStash != Entity.Null) { int territoryId = Core.TerritoryService.GetTerritoryId(sendingStash); DestDebugLog.Move("conveyor", territoryId, item, num6, sendingStash, Entity.Null, "station", Core.PlayerSettings.GetPullReserve(ownerId, item), "station"); } sinks.RemoveAt(num5); } else if (!chest && num4 > 0) { int num7 = Move(sgm, inventory, beltSink2.Inventory, item, num4); if (num7 < num4) { sinks.RemoveAt(num5); } num4 -= num7; } } } if (num4 > 0) { DumpToOverflow(sgm, inventory, item, num4, overflow); } continue; } int remainder = 0; int num8 = 0; for (int num9 = sinks.Count - 1; num9 >= 0; num9--) { BeltSink value = sinks[num9]; if ((!chest || !value.Chest) && value.Wanted > 0) { entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(value.Inventory)) { num3 -= value.Wanted; sinks.RemoveAt(num9); } else { int num10 = Slice(value.Wanted, num2, num3, ref remainder); int num11 = Move(sgm, inventory, value.Inventory, item, num10); if (chest && num11 > 0 && sendingStash != Entity.Null) { int territoryId2 = Core.TerritoryService.GetTerritoryId(sendingStash); DestDebugLog.Move("conveyor", territoryId2, item, num11, sendingStash, Entity.Null, "station", Core.PlayerSettings.GetPullReserve(ownerId, item), "station"); } num8 += num11; if (num11 < num10) { remainder += num3 * (num10 - num11); sinks.RemoveAt(num9); } else if (num11 >= value.Wanted) { sinks.RemoveAt(num9); } else { value.Wanted -= num11; sinks[num9] = value; } } } } if (!chest && num8 < num2) { DumpToOverflow(sgm, inventory, item, num2 - num8, overflow); } } if (chest) { ChestToChest(book, sgm, group, inventory, ownerId, sendingStash); } } private static void ChestToChest(BeltBook book, ServerGameManager sgm, int group, Entity inventory, ulong ownerId, Entity sendingStash) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) if (!Core.PlayerSettings.IsConveyorLoopsAllowed() && sendingStash != Entity.Null) { StashHasToken(sendingStash, Core.Stash.ReceiveToken, group); } Dictionary dictionary = CountStackable(inventory); HonorReserve(dictionary, ownerId, apply: true); bool flag = Core.PlayerSettings.IsConveyorLoopsAllowed(); int plot = ((sendingStash != Entity.Null) ? Core.TerritoryService.GetTerritoryId(sendingStash) : (-1)); bool flag2 = sendingStash != Entity.Null && StashHasToken(sendingStash, Core.Stash.ReceiveToken, group); foreach (var (item, num2) in dictionary) { if (num2 <= 0 || !book.TryGrouped(group, item, out var sinks) || sinks == null) { continue; } int num3 = num2; for (int i = 0; i < sinks.Count; i++) { if (num3 <= 0) { break; } BeltSink value = sinks[i]; if (!value.Chest || value.Inventory == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(value.Inventory) || ((Entity)(ref value.Inventory)).Equals(inventory)) { continue; } Entity val2 = StashFromInventory(value.Inventory, sendingStash); if (!flag && val2 != Entity.Null && val2 != sendingStash && flag2 && StashHasToken(val2, Core.Stash.SendToken, group)) { continue; } int num4 = (value.Unlimited ? num3 : ((value.Wanted < num3) ? value.Wanted : num3)); if (num4 <= 0) { continue; } int num5 = Move(sgm, inventory, value.Inventory, item, num4); if (num5 <= 0) { continue; } num3 -= num5; DestDebugLog.Move("conveyor", plot, item, num5, sendingStash, val2, "chest-r#", Core.PlayerSettings.GetPullReserve(ownerId, item), "chest"); if (value.Wanted > 0) { value.Wanted -= num5; if (value.Wanted <= 0) { sinks.RemoveAt(i--); } else { sinks[i] = value; } } } } } private static Entity StashFromInventory(Entity destInv, Entity sendingStash) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) int territoryId = Core.TerritoryService.GetTerritoryId(destInv); if (territoryId < 0 && sendingStash != Entity.Null) { territoryId = Core.TerritoryService.GetTerritoryId(sendingStash); } if (territoryId < 0) { return Entity.Null; } foreach (Entity item in Core.Stash.ChestsOnPlot(territoryId)) { if (StashRouting.TryGetExternalInventory(item, out var inventory) && ((Entity)(ref inventory)).Equals(destInv)) { return item; } } return Entity.Null; } private unsafe static bool StashHasToken(Entity stash, Regex regex, int group) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!(stash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash) && stash.Has()) { NameableInteractable val = stash.Read(); string text = ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrEmpty(text)) { return false; } foreach (Match item in regex.Matches(text.ToLowerInvariant())) { if (int.TryParse(item.Groups[1].Value, out var result) && result == group) { return true; } } return false; } } return false; } public static void Ungrouped(Dictionary> needs, ServerGameManager sgm, Entity inventory, ulong ownerId, bool applyReserve) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = CountStackable(inventory); HonorReserve(dictionary, ownerId, applyReserve); foreach (var (val2, num2) in dictionary) { if (num2 <= 0 || !needs.TryGetValue(val2, out List<(Entity, int)> value) || value == null) { continue; } int num3 = 0; for (int i = 0; i < value.Count; i++) { if (value[i].Item2 > 0) { num3 += value[i].Item2; } } if (num3 <= 0) { continue; } EntityManager entityManager; if (num3 <= num2) { for (int num4 = value.Count - 1; num4 >= 0; num4--) { (Entity, int) tuple = value[num4]; Entity item = tuple.Item1; int item2 = tuple.Item2; entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(item)) { value.RemoveAt(num4); } else { Move(sgm, inventory, item, val2, item2); } } value.Clear(); continue; } int remainder = 0; for (int num5 = value.Count - 1; num5 >= 0; num5--) { (Entity, int) tuple2 = value[num5]; Entity item3 = tuple2.Item1; int item4 = tuple2.Item2; entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(item3)) { num3 -= item4; value.RemoveAt(num5); } else { int num6 = Slice(item4, num2, num3, ref remainder); int num7 = Move(sgm, inventory, item3, val2, num6); if (num7 < num6) { remainder += num6 - num7; value.RemoveAt(num5); } else if (num7 >= item4) { value.RemoveAt(num5); } else { value[num5] = (item3, item4 - num7); } } } } } } internal static class BeltTokens { public const string Receiver = "r(\\d+)"; public const string Sender = "s(\\d+)"; } internal sealed class BrazierService { private readonly HeartBoundIndex index; private readonly Dictionary> proxTouched = new Dictionary>(); private const float TickSeconds = 2.5f; private const float ProxRange = 20f; private readonly ProxLights lights; public BrazierService() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) index = HeartBoundIndex.Scan(true, ComponentType.ReadOnly(Il2CppType.Of())); for (int i = 0; i <= 146; i++) { proxTouched[i] = new HashSet(); } lights = new ProxLights(index, proxTouched); } internal void AddBrazier(Entity bonfire) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) index.Track(bonfire); } internal void RemoveBrazier(Entity bonfire) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) index.Untrack(bonfire); } public IEnumerable GetAllBraziers(int territoryId) { return index.OnTerritory(territoryId); } } internal static class CastleWorkDrain { private static bool ParkIfRebuilding(WorkQueueService q, int plot, Entity heart) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!Core.TerritoryService.IsTerritoryRebuilding(plot) && (int)heart.Read().State == 0) { return false; } q.rebuildDeferred.Add(plot); return true; } public static IEnumerator Loop(WorkQueueService q) { yield return null; Core.TerritoryService.StartTimer(); while (true) { if (q.pending.Count == 0) { q.DrainGeneration++; yield return null; Core.TerritoryService.StartTimer(); continue; } if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; Core.TerritoryService.StartTimer(); } int plot = q.pending.Dequeue(); q.queued.Remove(plot); Entity heart = Core.TerritoryService.GetCastleHeart(plot); if (heart == Entity.Null || ParkIfRebuilding(q, plot, heart)) { continue; } q.processing = plot; q.reprocessCurrent = false; IReadOnlyList> callbacks = Core.TerritoryService.UpdateCallbacks; for (int c = 0; c < callbacks.Count; c++) { IEnumerator step = null; bool flag = false; try { step = callbacks[c](plot, heart); flag = step.MoveNext(); } catch (Exception e) { Core.LogException(e, "Loop"); } while (flag) { yield return null; Core.TerritoryService.StartTimer(); try { flag = step.MoveNext(); } catch (Exception e2) { Core.LogException(e2, "Loop"); flag = false; } } if (Core.TerritoryService.ShouldUpdateYield()) { yield return null; Core.TerritoryService.StartTimer(); } } q.processing = -1; if (q.reprocessCurrent) { q.Enqueue(plot); } } } } internal sealed class ChestIndex { private readonly Dictionary List)> cache = new Dictionary)>(); private readonly Regex send; private readonly Regex receive; public ChestIndex(Regex sendToken, Regex receiveToken) { send = sendToken; receive = receiveToken; } public void Forget(int plot) { cache.Remove(plot); } public void ForgetAll() { cache.Clear(); } public IEnumerable OnPlot(int plot) { DateTime utcNow = DateTime.UtcNow; if (cache.TryGetValue(plot, out var hit) && (utcNow - hit.At).TotalSeconds < 0.25 && hit.List != null) { for (int i = 0; i < hit.List.Count; i++) { Entity val = hit.List[i]; if (!(val == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val)) { yield return val; } } } } else { List list = ScanPlot(plot); cache[plot] = (utcNow, list); for (int i = 0; i < list.Count; i++) { yield return list[i]; } } } private unsafe static List ScanPlot(int plot) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); if (castleHeart == Entity.Null || !castleHeart.Has()) { return list; } SharedCastleInventoryConnection val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.SharedInventoryManager)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasBuffer(entityOnServer)) { entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(entityOnServer, false); for (int i = 0; i < buffer.Length; i++) { Entity inventorySource = buffer[i].InventorySource; if (inventorySource == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inventorySource) && inventorySource.Has()) { NameableInteractable val2 = inventorySource.Read(); string text = ((object)(*(FixedString64Bytes*)(&val2.Name))/*cast due to .constrained prefix*/).ToString(); if ((string.IsNullOrEmpty(text) || !text.EndsWith("''", StringComparison.Ordinal)) && !StashRouting.IsNoShareName(text)) { list.Add(inventorySource); } } } return list; } } } return list; } public IEnumerable<(int group, Entity chest)> Senders(int plot) { return Grouped(send, plot, skipStations: true, skipOverflow: false); } public IEnumerable<(int group, Entity chest)> Receivers(int plot) { return Grouped(receive, plot, skipStations: true, skipOverflow: true); } private IEnumerable<(int group, Entity chest)> Grouped(Regex token, int plot, bool skipStations, bool skipOverflow) { foreach (Entity chest in OnPlot(plot)) { if ((skipStations && chest.Has()) || Core.TerritoryService.GetTerritoryId(chest) != plot) { continue; } string text = StashRouting.RawName(chest); if (string.IsNullOrEmpty(text) || StashRouting.IsNoShareName(text) || (skipOverflow && (text.IndexOf("overflow", StringComparison.OrdinalIgnoreCase) >= 0 || StashRouting.IsOverflowDestName(text)))) { continue; } foreach (Match item in token.Matches(text.ToLowerInvariant())) { if (int.TryParse(item.Groups[1].Value, out var result)) { yield return (group: result, chest: chest); } } } } public IEnumerable Named(int plot, string needle) { needle = needle.ToLowerInvariant(); foreach (Entity item in OnPlot(plot)) { string text = StashRouting.RawName(item).ToLowerInvariant(); if (!string.IsNullOrEmpty(text) && !text.EndsWith("''", StringComparison.Ordinal) && !StashRouting.IsNoShareName(text) && text.IndexOf(needle, StringComparison.Ordinal) >= 0) { yield return item; } } } } internal static class ChestTidy { private static bool running; public static bool TryStart(Entity character, User user, out string deny) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) deny = null; if (running) { deny = "Chest tidy is already running."; return false; } if (!PlayerActionGate.TryOpen(character, "tidy chests", requireAlliedHeart: true, out var _, out deny)) { return false; } running = true; Core.StartCoroutine(Run(character, user)); return true; } private static IEnumerator Run(Entity character, User user) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) int moved = 0; int types = 0; int chestCount = 0; bool clanWide = false; try { if (character == Entity.Null) { yield break; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(character)) { yield break; } clanWide = Core.TerritoryService.IsClanShareOn(user); int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(character); IReadOnlyList readOnlyList2; if (!clanWide) { IReadOnlyList readOnlyList = ((standingTerritoryId < 0) ? ((IReadOnlyList)Array.Empty()) : ((IReadOnlyList)new int[1] { standingTerritoryId })); readOnlyList2 = readOnlyList; } else { readOnlyList2 = Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(character); } IReadOnlyList readOnlyList3 = readOnlyList2; if (readOnlyList3 == null || readOnlyList3.Count == 0) { yield break; } ulong ownerId = 0uL; if (standingTerritoryId >= 0) { Core.TerritoryService.TryGetTerritoryOwnerPlatformId(standingTerritoryId, out ownerId); } else if (readOnlyList3.Count > 0) { Core.TerritoryService.TryGetTerritoryOwnerPlatformId(readOnlyList3[0], out ownerId); } List<(Entity stash, Entity inv, int plot)> chests = new List<(Entity, Entity, int)>(); for (int i = 0; i < readOnlyList3.Count; i++) { int num = readOnlyList3[i]; Entity castleHeart = Core.TerritoryService.GetCastleHeart(num); if (castleHeart == Entity.Null || TerritoryService.IsHeartRaided(castleHeart)) { continue; } foreach (Entity item in Core.Stash.ChestsOnPlot(num)) { Entity current = item; if (!current.Has() && !((Entity)(ref current)).Equals(castleHeart) && !current.Has() && StashRouting.TryGetExternalInventory(current, out var inventory) && !SkipPlate(StashRouting.RawName(current))) { chests.Add((current, inventory, num)); } } } chestCount = chests.Count; if (chestCount < 2) { yield break; } ServerGameManager sgm = Core.ServerGameManager; List items = new List(); HashSet hashSet = new HashSet(); DynamicBuffer val = default(DynamicBuffer); for (int j = 0; j < chests.Count; j++) { if (!((ServerGameManager)(ref sgm)).TryGetBuffer(chests[j].inv, ref val)) { continue; } for (int k = 0; k < val.Length; k++) { PrefabGUID itemType = val[k].ItemType; if (((PrefabGUID)(ref itemType)).GuidHash != 0 && val[k].Amount > 0 && hashSet.Add(((PrefabGUID)(ref itemType)).GuidHash)) { items.Add(itemType); } } } if (Core.TerritoryService != null) { Core.TerritoryService.StartTimer(); } for (int n = 0; n < items.Count; n++) { try { TidyOne(sgm, chests, items[n], ownerId, ref moved, ref types); } catch (Exception e) { Core.LogException(e, "Run"); } if (Core.TerritoryService != null && Core.TerritoryService.ShouldUpdateYield()) { yield return null; Core.TerritoryService.StartTimer(); } } sgm = default(ServerGameManager); } finally { running = false; string value = (clanWide ? "clan island" : "this plot"); string message = ((moved > 0) ? $"Tidied {moved} items ({types} kinds) across {chestCount} chests on the {value}." : $"No better dests. Looked at {chestCount} chests on the {value}."); try { if (user.IsConnected) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, message); } } catch { } } } private static void TidyOne(ServerGameManager sgm, List<(Entity stash, Entity inv, int plot)> chests, PrefabGUID item, ulong ownerId, ref int moved, ref int types) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) List<(Entity, Entity, int, StashRouting.SortRank)> list = new List<(Entity, Entity, int, StashRouting.SortRank)>(chests.Count); bool flag = false; for (int i = 0; i < chests.Count; i++) { var (val, val2, item2) = chests[i]; if (val2 == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val2)) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val)) { bool hasItem = StashRouting.InventoryHasItem(val2, item); StashRouting.SortRank item3 = TidyRank(val, item, ownerId, hasItem); list.Add((val, val2, item2, item3)); if (item3.UsableDest) { flag = true; } } } if (!flag) { return; } list.Sort(((Entity stash, Entity inv, int plot, StashRouting.SortRank rank) a, (Entity stash, Entity inv, int plot, StashRouting.SortRank rank) b) => a.rank.CompareTo(b.rank)); int num = 0; for (int num2 = 0; num2 < list.Count; num2++) { (Entity, Entity, int, StashRouting.SortRank) tuple2 = list[num2]; if (!tuple2.Item4.UsableSource) { continue; } int num3 = ((ServerGameManager)(ref sgm)).GetInventoryItemCount(tuple2.Item2, item); if (num3 <= 0) { continue; } bool flag2 = SlotIsEntity(sgm, tuple2.Item2, item); for (int num4 = 0; num4 < list.Count; num4++) { if (num3 <= 0) { break; } (Entity, Entity, int, StashRouting.SortRank) tuple3 = list[num4]; if (((Entity)(ref tuple3.Item2)).Equals(tuple2.Item2) || !tuple3.Item4.StrictlyBetterDestThan(tuple2.Item4) || ClanTreasuryLend.InEmptyHold(tuple3.Item3, tuple3.Item2)) { continue; } int inventoryItemCount = ((ServerGameManager)(ref sgm)).GetInventoryItemCount(tuple2.Item2, item); int amountTransferred; if (flag2) { int startInputSlot = 0; Utilities.TransferItemEntities(tuple2.Item2, tuple3.Item2, item, num3, ref startInputSlot, out amountTransferred); } else { amountTransferred = Utilities.TransferItems(sgm, tuple2.Item2, tuple3.Item2, item, num3); } int inventoryItemCount2 = ((ServerGameManager)(ref sgm)).GetInventoryItemCount(tuple2.Item2, item); if (amountTransferred > 0 && inventoryItemCount2 >= inventoryItemCount) { int inventoryItemCount3 = ((ServerGameManager)(ref sgm)).GetInventoryItemCount(tuple3.Item2, item); int num5 = ((inventoryItemCount3 < amountTransferred) ? inventoryItemCount3 : amountTransferred); if (num5 > 0) { ((ServerGameManager)(ref sgm)).TryRemoveInventoryItem(tuple3.Item2, item, num5); } } else if (amountTransferred > 0) { num3 -= amountTransferred; num += amountTransferred; moved += amountTransferred; StashRouting.LogDestPick(tuple3.Item4.Label, tuple3.Item3, item, StashRouting.RawName(tuple3.Item1), "tidy"); DestDebugLog.Move("tidy", tuple3.Item3, item, amountTransferred, tuple2.Item1, tuple3.Item1, tuple3.Item4.Label, 0, "stays"); } } } if (num > 0) { types++; } } private static bool SkipPlate(string plate) { if (StashRouting.IsNoShareName(plate) || StashRouting.IsSkipQuotesName(plate)) { return true; } if (string.IsNullOrEmpty(plate)) { return false; } string text = plate.ToLowerInvariant(); if (!text.Contains("salvage") && !text.Contains("trash") && !text.Contains("brazier")) { return text.Contains("spawner"); } return true; } private static bool IsSpoilsOrOverflow(string plate) { if (string.IsNullOrEmpty(plate)) { return false; } string text = plate.ToLowerInvariant(); if (!text.Contains("overflow")) { return text.Contains("spoils"); } return true; } private static StashRouting.SortRank TidyRank(Entity stash, PrefabGUID item, ulong ownerId, bool hasItem) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) string text = StashRouting.RawName(stash); StashRouting.SortRank result = new StashRouting.SortRank { Class = 9, Label = StashRouting.SkipLabel(text), Seeded = hasItem }; if (SkipPlate(text) || stash.Has()) { result.UsableDest = false; result.UsableSource = false; return result; } if (IsSpoilsOrOverflow(text)) { result.Class = 8; result.UsableSource = true; result.UsableDest = false; result.Label = "overflow"; return result; } StashRouting.DepositRank depositRank = StashRouting.RankDeposit(stash, item, ownerId, hasItem); result.Class = depositRank.Class; result.Spec = depositRank.Spec; result.Seeded = depositRank.Seeded; result.Label = depositRank.Label; bool flag = StashRouting.IsConveyorName(text); result.UsableSource = !flag; result.UsableDest = (flag ? (depositRank.Class <= 2) : (depositRank.Class <= 4)); return result; } private static bool SlotIsEntity(ServerGameManager sgm, Entity inv, PrefabGUID item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref sgm)).TryGetBuffer(inv, ref val)) { return false; } for (int i = 0; i < val.Length; i++) { InventoryBuffer val2 = val[i]; if (((PrefabGUID)(ref val2.ItemType)).Equals(item)) { val2 = val[i]; Entity entityOnServer = ((NetworkedEntity)(ref val2.ItemEntity)).GetEntityOnServer(); if (!((Entity)(ref entityOnServer)).Equals(Entity.Null)) { return true; } } } return false; } } internal static class ClanThroneServants { private struct PendingPick { public List Plots; public DateTime ExpiresUtc; } private struct PendingHunt { public int Plot; public List Servants; public List Names; public DateTime ExpiresUtc; } private struct ServantRow { public string Name; public NetworkId Nid; public Entity Servant; } private struct ConnectedPlayer { public ulong steam; public string name; public int plot; public float3 pos; public Entity character; } private static readonly Dictionary selectedPlot = new Dictionary(); private static readonly Dictionary returnPos = new Dictionary(); private static readonly Dictionary pendingPick = new Dictionary(); private static readonly Dictionary> pendingHuntList = new Dictionary>(); private static readonly Dictionary pendingHunt = new Dictionary(); private static readonly Dictionary throneByPlot = new Dictionary(); private static readonly Dictionary learnedThroneByPlot = new Dictionary(); private static DateTime throneCacheAt; private static readonly TimeSpan PickTtl = TimeSpan.FromMinutes(2.0); private static readonly List<(Entity character, Entity target, NetworkId nid)> interactRestore = new List<(Entity, Entity, NetworkId)>(); private static readonly List infoEntities = new List(); private static string lastSkip = ""; private static int lastSitting = -1; private static int lastSelected = -1; private static int lastFrom = -1; private static int lastTo = -1; private static int lastResponseCount = -1; private static string lastResponseNames = ""; private static string lastPatched = ""; private static string lastGoto = ""; private static string lastSit = ""; private static string lastSend = ""; internal static readonly string ClientJsonPath = Path.Combine(Paths.ConfigPath, "Satisvampory", "debug", "thrones-client.json"); public static void RewriteInfoRequests(ServantInfoEventSystem_Server system) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) RestoreInteract(); interactRestore.Clear(); infoEntities.Clear(); if (system != null && Core.HasInitialized) { RewriteQuery(system._RequestQuery, RewriteInfo); } } public static void AfterInfoUpdate() { try { CaptureResponse(); } catch (Exception e) { Core.LogException(e, "AfterInfoUpdate"); } } public static void RewriteMissionEvents(ServantMissionActionSystem system) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (system != null && Core.HasInitialized) { RewriteQuery(system._StartMissionEventQuery, RewriteStart); RewriteQuery(system._AbortMissionEventQuery, RewriteAbort); } } public static bool MayManageFrom(Entity character, Entity throne) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized || character == Entity.Null || throne == Entity.Null) { return false; } EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(throne)) { int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(character); int territoryId = Core.TerritoryService.GetTerritoryId(throne); if (standingTerritoryId < 0 || territoryId < 0) { return false; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(standingTerritoryId); if (logisticsTerritoryIds == null || logisticsTerritoryIds.Count <= 1) { return false; } bool flag = false; bool flag2 = false; for (int i = 0; i < logisticsTerritoryIds.Count; i++) { if (logisticsTerritoryIds[i] == standingTerritoryId) { flag = true; } if (logisticsTerritoryIds[i] == territoryId) { flag2 = true; } } return flag && flag2; } } return false; } public static string ChatList(Entity character, ulong steam) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) int num = ((character != Entity.Null) ? Core.TerritoryService.GetStandingTerritoryId(character) : (-1)); if (num < 0) { return "Stand on a clan castle (or sit its throne) to pick a plot."; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (logisticsTerritoryIds == null || logisticsTerritoryIds.Count == 0) { return "No castle under you."; } if (logisticsTerritoryIds.Count == 1) { return "ClanShare is off or this plot is excluded. Sit this throne to manage its servants."; } selectedPlot.TryGetValue(steam, out var value); bool flag = value <= 0 || value == num; pendingPick[steam] = new PendingPick { Plots = new List(logisticsTerritoryIds), ExpiresUtc = DateTime.UtcNow + PickTtl }; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("ClanShare throne — pick a plot to hunt from this chair (vanilla map keeps fog).\n"); for (int i = 0; i < logisticsTerritoryIds.Count; i++) { int num2 = logisticsTerritoryIds[i]; List list = AliveNames(num2); string text = ""; if (num2 == num && flag) { text = " (here, default)"; } else if (num2 == num) { text = " (here)"; } if (num2 == value && !flag) { text += " (managing)"; } stringBuilder.Append(i + 1).Append(") ").Append(Core.TerritoryService.FormatPlotLabel(num2)) .Append(text) .Append(" ") .Append((list.Count == 0) ? "no servants" : string.Join(", ", list)) .Append('\n'); } stringBuilder.Append(".s 2 then .s hunt 1 2 then click a discovered zone"); string text2 = stringBuilder.ToString(); if (text2.Length > 509) { return text2.Substring(0, 509); } return text2; } public static bool TryPickNumber(Entity character, ulong steam, int number, out string reply) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) reply = null; if (!pendingPick.TryGetValue(steam, out var value) || value.Plots == null) { return false; } if (DateTime.UtcNow > value.ExpiresUtc) { pendingPick.Remove(steam); return false; } if (number < 1 || number > value.Plots.Count) { return false; } reply = ApplyPlot(character, steam, value.Plots[number - 1]); return true; } public static string ChatSelect(Entity character, ulong steam, string arg) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(arg) || arg.Equals("list", StringComparison.OrdinalIgnoreCase)) { return ChatList(character, steam); } if (arg.Equals("here", StringComparison.OrdinalIgnoreCase) || arg.Equals("clear", StringComparison.OrdinalIgnoreCase) || arg.Equals("local", StringComparison.OrdinalIgnoreCase) || arg.Equals("default", StringComparison.OrdinalIgnoreCase)) { selectedPlot.Remove(steam); pendingPick.Remove(steam); pendingHunt.Remove(steam); pendingHuntList.Remove(steam); if (returnPos.TryGetValue(steam, out var value) && TryTeleport(character, value, out var via)) { returnPos.Remove(steam); return "Returned (" + via + "). This throne's servants again."; } returnPos.Remove(steam); return "Default: this castle's throne. Sit and use the vanilla hunt map."; } if (!int.TryParse(arg, out var result)) { return "Use .s throne then .s 2, then .s hunt 1 2, or .s throne here."; } if (TryPickNumber(character, steam, result, out var reply)) { return reply; } return ApplyPlot(character, steam, result); } private static string ApplyPlot(Entity character, ulong steam, int plot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) int num = ((character != Entity.Null) ? Core.TerritoryService.GetStandingTerritoryId(character) : (-1)); if (num < 0) { return "Stand on a clan castle (or sit its throne) to pick a plot."; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(num); bool flag = false; if (logisticsTerritoryIds != null) { for (int i = 0; i < logisticsTerritoryIds.Count; i++) { if (logisticsTerritoryIds[i] == plot) { flag = true; break; } } } if (!flag) { return "Plot " + plot + " is not on your ClanShare island (need .s cs, not .s cse)."; } if (FindThrone(plot) == Entity.Null) { return "No throne on " + Core.TerritoryService.FormatPlotLabel(plot) + "."; } pendingPick.Remove(steam); pendingHunt.Remove(steam); List list = AliveNames(plot); string text = ((list.Count == 0) ? "no living servants" : string.Join(", ", list)); if (plot == num) { selectedPlot.Remove(steam); return "Default: " + Core.TerritoryService.FormatPlotLabel(plot) + " (this castle). Sit this throne. " + text; } selectedPlot[steam] = plot; pendingHuntList[steam] = AliveRows(plot); return "Managing " + Core.TerritoryService.FormatPlotLabel(plot) + " from this chair. " + text + " .s hunt 1 2 then click a discovered zone on this map (fog stays vanilla)."; } public static string ChatHunt(Entity character, ulong steam, string arg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) int num = ManagingPlot(character, steam); if (num < 0) { return "Stand on a clan castle (or sit its throne). .s throne to pick another plot."; } List list = AliveRows(num); pendingHuntList[steam] = list; if (string.IsNullOrWhiteSpace(arg) || arg.Equals("list", StringComparison.OrdinalIgnoreCase)) { return FormatHuntList(num, list); } if (arg.Equals("clear", StringComparison.OrdinalIgnoreCase) || arg.Equals("here", StringComparison.OrdinalIgnoreCase)) { pendingHunt.Remove(steam); return "Cleared. Next map click is vanilla (this throne's servants)."; } List list2 = ParseHuntNumbers(arg, list); if (list2.Count == 0) { if (list.Count != 0) { return "Use .s hunt 1 2 (max 3) from the numbered list."; } return "No idle servants on " + Core.TerritoryService.FormatPlotLabel(num) + "."; } List list3 = new List(); List list4 = new List(); for (int i = 0; i < list2.Count; i++) { list3.Add(list2[i].Nid); list4.Add(list2[i].Name); } pendingHunt[steam] = new PendingHunt { Plot = num, Servants = list3, Names = list4, ExpiresUtc = DateTime.UtcNow + PickTtl }; selectedPlot[steam] = num; return "Next click on this throne's map sends " + string.Join(", ", list4) + " from " + Core.TerritoryService.FormatPlotLabel(num) + ". Undiscovered zones stay fogged (vanilla map)."; } public unsafe static void WriteClientSnapshot() { if (!Core.HasInitialized) { return; } try { Directory.CreateDirectory(Path.GetDirectoryName(ClientJsonPath)); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plots\":["); bool flag = true; foreach (ConnectedPlayer item in ConnectedPlayers()) { int plot = item.plot; if (plot < 0) { continue; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(plot); if (logisticsTerritoryIds == null || logisticsTerritoryIds.Count == 0) { continue; } for (int i = 0; i < logisticsTerritoryIds.Count; i++) { int num = logisticsTerritoryIds[i]; if (!flag) { stringBuilder.Append(','); } flag = false; stringBuilder.Append("{\"plot\":").Append(num).Append(",\"here\":") .Append((num == plot) ? "true" : "false") .Append(",\"label\":\"") .Append(Esc(Core.TerritoryService.FormatPlotLabel(num))) .Append('"') .Append(",\"servants\":["); List list = AliveRows(num); for (int j = 0; j < list.Count; j++) { if (j > 0) { stringBuilder.Append(','); } StringBuilder stringBuilder2 = stringBuilder.Append("{\"i\":").Append(j + 1).Append(",\"name\":\"") .Append(Esc(list[j].Name)) .Append('"') .Append(",\"nid\":\""); ServantRow servantRow = list[j]; stringBuilder2.Append(Esc(((object)(*(NetworkId*)(&servantRow.Nid))/*cast due to .constrained prefix*/).ToString())).Append("\"}"); } stringBuilder.Append("]}"); } break; } stringBuilder.Append("]}"); string text = ClientJsonPath + ".tmp"; File.WriteAllText(text, stringBuilder.ToString()); File.Copy(text, ClientJsonPath, overwrite: true); File.Delete(text); } catch (Exception e) { Core.LogException(e, "WriteClientSnapshot"); } } public static string DebugHunt(int plot, string arg) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!TryFindConnected("", out var steam, out var character, out var playerName, out var error)) { return "{\"error\":\"" + Esc(error) + "\"}"; } if (plot >= 0) { selectedPlot[steam] = plot; pendingHuntList[steam] = AliveRows(plot); } string s = ChatHunt(character, steam, arg); return "{\"player\":\"" + Esc(playerName) + "\",\"text\":\"" + Esc(s) + "\",\"lastSend\":\"" + Esc(lastSend) + "\"}"; } public static string DebugDump(int plotFilter) { //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) RefreshThroneCache(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plot\":").Append(plotFilter).Append(",\"lastSitting\":") .Append(lastSitting) .Append(",\"lastSelected\":") .Append(lastSelected) .Append(",\"lastFrom\":") .Append(lastFrom) .Append(",\"lastTo\":") .Append(lastTo) .Append(",\"lastPatched\":\"") .Append(Esc(lastPatched)) .Append('"') .Append(",\"lastSkip\":\"") .Append(Esc(lastSkip)) .Append('"') .Append(",\"lastGoto\":\"") .Append(Esc(lastGoto)) .Append('"') .Append(",\"lastSit\":\"") .Append(Esc(lastSit)) .Append('"') .Append(",\"lastSend\":\"") .Append(Esc(lastSend)) .Append('"') .Append(",\"lastResponseCount\":") .Append(lastResponseCount) .Append(",\"lastResponseNames\":\"") .Append(Esc(lastResponseNames)) .Append('"') .Append(",\"hint\":\"{\\\"op\\\":\\\"hunt\\\",\\\"plot\\\":86,\\\"name\\\":\\\"1 2\\\"} then click a vanilla map zone\"") .Append(",\"picks\":["); bool flag = true; foreach (KeyValuePair item in selectedPlot) { if (!flag) { stringBuilder.Append(','); } flag = false; stringBuilder.Append("{\"steam\":").Append(item.Key).Append(",\"plot\":") .Append(item.Value) .Append('}'); } stringBuilder.Append("],\"returns\":["); flag = true; foreach (KeyValuePair returnPo in returnPos) { if (!flag) { stringBuilder.Append(','); } flag = false; AppendPos(stringBuilder.Append("{\"steam\":").Append(returnPo.Key).Append(','), returnPo.Value, "pos").Append('}'); } stringBuilder.Append("],\"players\":["); flag = true; foreach (ConnectedPlayer item2 in ConnectedPlayers()) { if (!flag) { stringBuilder.Append(','); } flag = false; int value = -1; if (TryGetInteractTarget(item2.character, out var target, out var _)) { value = Core.TerritoryService.GetTerritoryId(target); } stringBuilder.Append("{\"steam\":").Append(item2.steam).Append(",\"name\":\"") .Append(Esc(item2.name)) .Append('"') .Append(",\"plot\":") .Append(item2.plot) .Append(",\"sitPlot\":") .Append(value) .Append(",\"interactBuffs\":") .Append(CountInteractBuffs(item2.character)) .Append(','); AppendPos(stringBuilder, item2.pos, "pos").Append('}'); } stringBuilder.Append("],\"thrones\":["); flag = true; foreach (KeyValuePair item3 in throneByPlot) { if (plotFilter < 0 || item3.Key == plotFilter) { if (!flag) { stringBuilder.Append(','); } flag = false; string s = (item3.Value.Has() ? ((object)item3.Value.Read()/*cast due to .constrained prefix*/).ToString() : ""); stringBuilder.Append("{\"plot\":").Append(item3.Key).Append(",\"alive\":") .Append(CountAlive(item3.Key)) .Append(",\"nid\":\"") .Append(Esc(s)) .Append('"') .Append(",\"useThrone\":") .Append(item3.Value.Has() ? "true" : "false") .Append(",\"heart\":") .Append(item3.Value.Has() ? "true" : "false") .Append(",\"missions\":") .Append(item3.Value.Has() ? "true" : "false") .Append(",\"ability\":\"") .Append(Esc(InteractAbilityName(item3.Value))) .Append('"') .Append(','); float3 pos = (float3)(item3.Value.Has() ? item3.Value.Read().Value : default(float3)); AppendPos(stringBuilder, pos, "pos").Append('}'); } } stringBuilder.Append("]}"); return stringBuilder.ToString(); } public static string DebugGoto(int plot, string who) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) RefreshThroneCache(); bool flag = !string.IsNullOrWhiteSpace(who) && (who.Equals("here", StringComparison.OrdinalIgnoreCase) || who.Equals("back", StringComparison.OrdinalIgnoreCase) || who.Equals("return", StringComparison.OrdinalIgnoreCase)); if (!TryFindConnected(flag ? "" : who, out var steam, out var character, out var playerName, out var error)) { lastGoto = "no-player " + error; return "{\"error\":\"" + Esc(error) + "\",\"dump\":" + DebugDump(plot) + "}"; } if (flag) { if (!returnPos.TryGetValue(steam, out var value)) { lastGoto = "no-return " + playerName; return "{\"error\":\"no saved return position\",\"player\":\"" + Esc(playerName) + "\"}"; } return FinishGoto(character, steam, playerName, -1, "return", value, saveReturn: false, clearReturn: true); } if (plot < 0) { return DebugDump(plot); } Entity val = FindThrone(plot); if (!(val == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val) && val.Has()) { float3 value2 = val.Read().Value; value2.y += 1.5f; string text = (val.Has() ? ((object)val.Read()/*cast due to .constrained prefix*/).ToString() : ""); List list = AliveNames(plot); string text2 = ((list.Count == 0) ? "no living servants" : string.Join(", ", list)); return FinishGoto(character, steam, playerName, plot, text + " " + text2, value2, saveReturn: true, clearReturn: false); } } lastGoto = "no-throne plot=" + plot; return "{\"error\":\"no throne on plot " + plot + "\",\"player\":\"" + Esc(playerName) + "\",\"dump\":" + DebugDump(plot) + "}"; } private static string Esc(string s) { if (string.IsNullOrEmpty(s)) { return ""; } return s.Replace("\\", "\\\\").Replace("\"", "\\\""); } private static void RewriteQuery(EntityQuery query, Action rewrite) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) NativeArray val = default(NativeArray); try { val = ((EntityQuery)(ref query)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val.Length; i++) { Entity val2 = val[i]; if (!(val2 == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val2)) { rewrite(val2); } } } } catch (Exception e) { Core.LogException(e, "RewriteQuery"); } finally { if (val.IsCreated) { val.Dispose(); } } } private static void RewriteInfo(Entity entity) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) infoEntities.Add(entity); if (!entity.Has()) { lastSkip = "no-request"; return; } LearnIncomingThrone(entity); if (!TryTargetFromEvent(entity, out var target, out var plot, out var sitting, out var skip)) { lastSkip = skip; return; } lastSitting = sitting; lastSelected = plot; int fromPlot; bool flag = PatchThroneId(entity, new ComponentType(Il2CppType.Of(), (AccessMode)0), target, out fromPlot); bool flag2 = false; if (entity.Has()) { flag2 = RetargetInteract(entity.Read().Character, target); } lastFrom = fromPlot; lastTo = plot; lastPatched = "req=" + flag + " interact=" + flag2; lastSkip = ""; if (flag || flag2) { DestDebugLog.Note("throne", plot, 0uL, "info " + fromPlot + " -> " + plot + " " + lastPatched); } } private static void RewriteStart(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) if (!entity.Has()) { return; } try { if (!entity.Has()) { return; } FromCharacter val = entity.Read(); if (val.User == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val.User) || !val.User.Has()) { return; } ulong platformId = val.User.Read().PlatformId; if (!pendingHunt.TryGetValue(platformId, out var value) || value.Servants == null || value.Servants.Count == 0) { return; } if (DateTime.UtcNow > value.ExpiresUtc) { pendingHunt.Remove(platformId); return; } if (!TryTargetFromEvent(entity, out var target, out var plot, out var _, out var skip)) { lastSkip = skip; return; } if (value.Plot >= 0) { Entity val2 = FindThrone(value.Plot); if (val2 != Entity.Null) { target = val2; plot = value.Plot; } } if (PatchSend(entity, target, value.Servants, out var fromPlot)) { lastSend = string.Join(",", value.Names) + " plot=" + plot; lastTo = plot; lastFrom = fromPlot; DestDebugLog.Note("throne", plot, 0uL, "send " + fromPlot + " -> " + plot + " " + lastSend); } } finally { RepeatHunts.Remember(entity); } } private static void RewriteAbort(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (entity.Has()) { RepeatHunts.ForgetAbort(entity); if (TryTargetFromEvent(entity, out var target, out var plot, out var _, out var _) && PatchThroneId(entity, new ComponentType(Il2CppType.Of(), (AccessMode)0), target, out var fromPlot)) { DestDebugLog.Note("throne", plot, 0uL, "abort " + fromPlot + " -> " + plot); } } } private static bool TryTargetFromEvent(Entity entity, out Entity target, out int plot, out int sitting, out string skip) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) target = Entity.Null; plot = -1; sitting = -1; skip = "ok"; if (!entity.Has()) { skip = "no-from"; return false; } FromCharacter val = entity.Read(); Entity character = val.Character; if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && val.User.Has()) { ulong platformId = val.User.Read().PlatformId; sitting = Core.TerritoryService.GetStandingTerritoryId(character); lastSitting = sitting; if (!selectedPlot.TryGetValue(platformId, out plot) || plot < 0) { skip = "no-pick steam=" + platformId; lastSelected = -1; return false; } lastSelected = plot; if (sitting < 0) { skip = "not-on-plot"; return false; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(sitting); bool flag = false; if (logisticsTerritoryIds != null) { for (int i = 0; i < logisticsTerritoryIds.Count; i++) { if (logisticsTerritoryIds[i] == plot) { flag = true; break; } } } if (!flag) { skip = "pick-not-on-island plot=" + plot; return false; } target = FindThrone(plot); if (!(target == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(target) && target.Has()) { skip = ""; return true; } } skip = "no-throne plot=" + plot; return false; } } skip = "no-character"; return false; } private unsafe static bool RetargetInteract(Entity character, Entity target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && character.Has()) { ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(character, val.TypeIndex); if (componentDataRawRW == null) { return false; } IntPtr pointer = new IntPtr(componentDataRawRW); IntPtr ptr = IntPtr.Add(pointer, 8); IntPtr ptr2 = IntPtr.Add(pointer, 20); NetworkId item = Marshal.PtrToStructure(ptr); Entity val2 = Marshal.PtrToStructure(ptr2); if (val2 == target) { return false; } interactRestore.Add((character, val2, item)); Marshal.StructureToPtr(target.Read(), ptr, fDeleteOld: false); Marshal.StructureToPtr(target, ptr2, fDeleteOld: false); return true; } } return false; } private unsafe static void RestoreInteract() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); for (int i = 0; i < interactRestore.Count; i++) { (Entity, Entity, NetworkId) tuple = interactRestore[i]; if (tuple.Item1 == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(tuple.Item1) && tuple.Item1.Has()) { ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(tuple.Item1, val.TypeIndex); if (componentDataRawRW != null) { IntPtr pointer = new IntPtr(componentDataRawRW); Marshal.StructureToPtr(tuple.Item3, IntPtr.Add(pointer, 8), fDeleteOld: false); Marshal.StructureToPtr(tuple.Item2, IntPtr.Add(pointer, 20), fDeleteOld: false); } } } interactRestore.Clear(); } private static void CaptureResponse() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) lastResponseCount = -1; lastResponseNames = ""; for (int i = 0; i < infoEntities.Count; i++) { ReadResponse(infoEntities[i]); } infoEntities.Clear(); if (lastResponseCount >= 0) { return; } EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int j = 0; j < val4.Length; j++) { ReadResponse(val4[j]); } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } private unsafe static void ReadResponse(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (entity == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entity) || !entity.Has()) { return; } Response val = entity.Read(); lastResponseCount = val.Result.Length; StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < val.Result.Length && i < 12; i++) { if (i > 0) { stringBuilder.Append(','); } Entry val2 = val.Result[i]; stringBuilder.Append(((object)(*(FixedString64Bytes*)(&val2.Name))/*cast due to .constrained prefix*/).ToString()); } lastResponseNames = stringBuilder.ToString(); DestDebugLog.Note("throne", lastTo, 0uL, "response n=" + lastResponseCount + " " + lastResponseNames + " patched=" + lastPatched); } private static void LearnIncomingThrone(Entity requestEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (Core.TryGetEntityFromNetworkId(requestEntity.Read().Throne, out var entity) && !entity.Has() && !entity.Has()) { int territoryId = Core.TerritoryService.GetTerritoryId(entity); if (territoryId >= 0 && entity.Has()) { learnedThroneByPlot[territoryId] = entity; throneByPlot[territoryId] = entity; } } } public static void RemapGetEntries(ref Entity throneEntity) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (lastSelected >= 0 && !(throneEntity == Entity.Null)) { Entity val = FindThrone(lastSelected); if (!(val == Entity.Null) && !(val == throneEntity)) { throneEntity = val; lastPatched += " getEntries=True"; } } } private unsafe static bool PatchThroneId(Entity entity, ComponentType type, Entity target, out int fromPlot) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) fromPlot = -1; NetworkId val = target.Read(); EntityManager entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(entity, type.TypeIndex); if (componentDataRawRW == null) { return false; } IntPtr ptr = new IntPtr(componentDataRawRW); if (Core.TryGetEntityFromNetworkId(Marshal.PtrToStructure(ptr), out var entity2)) { fromPlot = Core.TerritoryService.GetTerritoryId(entity2); if (fromPlot == Core.TerritoryService.GetTerritoryId(target)) { return false; } } Marshal.StructureToPtr(val, ptr, fDeleteOld: false); NetworkId val2 = Marshal.PtrToStructure(ptr); string[] obj = new string[5] { lastPatched, " rb=", null, null, null }; NetworkId val3 = val2; obj[2] = ((object)(*(NetworkId*)(&val3))/*cast due to .constrained prefix*/).ToString(); obj[3] = " want="; val3 = val; obj[4] = ((object)(*(NetworkId*)(&val3))/*cast due to .constrained prefix*/).ToString(); lastPatched = string.Concat(obj); return true; } private unsafe static bool PatchSend(Entity entity, Entity throne, List servants, out int fromPlot) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) fromPlot = -1; if (throne == Entity.Null || !throne.Has() || servants == null || servants.Count == 0) { return false; } ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(entity, val.TypeIndex); if (componentDataRawRW == null) { return false; } IntPtr ptr = new IntPtr(componentDataRawRW); SendOnMissionEvent val2 = Marshal.PtrToStructure(ptr); if (Core.TryGetEntityFromNetworkId(val2.Throne, out var entity2)) { fromPlot = Core.TerritoryService.GetTerritoryId(entity2); } val2.Throne = throne.Read(); val2.Servant1 = servants[0]; val2.Servant2 = (NetworkId)((servants.Count > 1) ? servants[1] : default(NetworkId)); val2.Servant3 = (NetworkId)((servants.Count > 2) ? servants[2] : default(NetworkId)); Marshal.StructureToPtr(val2, ptr, fDeleteOld: false); NetworkId throne2 = Marshal.PtrToStructure(ptr).Throne; lastPatched = "send rb=" + ((object)(*(NetworkId*)(&throne2))/*cast due to .constrained prefix*/).ToString(); return true; } private static int ManagingPlot(Entity character, ulong steam) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) int num = ((character != Entity.Null) ? Core.TerritoryService.GetStandingTerritoryId(character) : (-1)); if (num < 0) { return -1; } if (!selectedPlot.TryGetValue(steam, out var value) || value < 0) { return num; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (logisticsTerritoryIds == null) { return num; } for (int i = 0; i < logisticsTerritoryIds.Count; i++) { if (logisticsTerritoryIds[i] == value) { return value; } } return num; } private static string FormatHuntList(int plot, List rows) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Hunt from ").Append(Core.TerritoryService.FormatPlotLabel(plot)).Append(" — pick up to 3, then click a discovered zone on this map.\n"); if (rows.Count == 0) { stringBuilder.Append("no idle servants"); } for (int i = 0; i < rows.Count; i++) { stringBuilder.Append(i + 1).Append(") ").Append(rows[i].Name) .Append('\n'); } if (rows.Count > 0) { stringBuilder.Append(".s hunt 1 2"); } string text = stringBuilder.ToString(); if (text.Length > 509) { return text.Substring(0, 509); } return text; } private static List ParseHuntNumbers(string arg, List rows) { List list = new List(); if (string.IsNullOrWhiteSpace(arg) || rows == null || rows.Count == 0) { return list; } string[] array = arg.Replace(',', ' ').Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); HashSet hashSet = new HashSet(); for (int i = 0; i < array.Length; i++) { if (list.Count >= 3) { break; } if (int.TryParse(array[i], out var result) && result >= 1 && result <= rows.Count && hashSet.Add(result)) { list.Add(rows[result - 1]); } } return list; } private static IEnumerator SitSoon(Entity character, Entity throne) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return null; yield return null; if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && !(throne == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(throne)) { TrySitThrone(character, throne, out var via); lastSit = via; lastGoto = lastGoto + " sit=" + via; DestDebugLog.Note("throne", Core.TerritoryService.GetTerritoryId(throne), 0uL, "sit " + via); yield break; } } } lastSit = "gone"; } private static string TryUnseat(Entity character) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character)) { int num = DestroyInteractBuffs(character); string text = ""; if (TryGetInteractTarget(character, out var _, out var nid)) { SpawnStopInteract(character, nid); ClearInteractTarget(character); text = " stop"; } if (num == 0 && text.Length == 0) { return " standing"; } return " unseat buffs=" + num + text; } } return ""; } private static int DestroyInteractBuffs(Entity character) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) int num = 0; EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)0)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val5)) { bool flag = false; if (val5.Has() && val5.Read().Target == character) { flag = true; } if (val5.Has() && val5.Read().Owner == character) { flag = true; } if (flag) { DestroyUtility.Destroy(Core.EntityManager, val5, (DestroyDebugReason)13, (string)null, 0); num++; } } } } catch (Exception e) { Core.LogException(e, "DestroyInteractBuffs"); } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } return num; } private static int CountInteractBuffs(Entity character) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character)) { int num = 0; EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val5)) { if (val5.Has() && val5.Read().Target == character) { num++; } else if (val5.Has() && val5.Read().Owner == character) { num++; } } } return num; } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } } return 0; } private static void SpawnStopInteract(Entity character, NetworkId target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (character.Has()) { Entity userEntity = character.Read().UserEntity; EntityManager entityManager = Core.EntityManager; Entity entity = ((EntityManager)(ref entityManager)).CreateEntity(); entity.Add(); entity.Add(); entity.Write(new FromCharacter { User = userEntity, Character = character }); entity.Write(new StopInteractingWithObjectEvent { Target = target }); } } private static bool TrySitThrone(Entity character, Entity throne, out string via) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) via = "no-sit"; if (!(character == Entity.Null) && !(throne == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(throne)) { if (!character.Has() || !throne.Has()) { return false; } PrefabGUID val = InteractAbility(throne); if (((PrefabGUID)(ref val)).GuidHash == 0) { via = "no-interact-ability"; return false; } try { Entity userEntity = character.Read().UserEntity; User val2 = userEntity.Read(); FromCharacter val3 = new FromCharacter { User = userEntity, Character = character }; CastAbilityServerDebugEvent val4 = new CastAbilityServerDebugEvent { AbilityGroup = val, Who = throne.Read() }; Core.DebugEventsSystem.CastAbilityServerDebugEvent(val2.Index, ref val4, ref val3); via = "cast " + val.LookupName(); lastSit = via; return true; } catch (Exception e) { Core.LogException(e, "TrySitThrone"); via = "cast-fail"; lastSit = via; return false; } } } } return false; } private static PrefabGUID InteractAbility(Entity throne) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!(throne == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(throne) && throne.Has()) { DynamicBuffer val = throne.ReadBuffer(); if (val.Length == 0) { return default(PrefabGUID); } return val[0].Ability; } } return default(PrefabGUID); } private static string InteractAbilityName(Entity throne) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) PrefabGUID prefabGuid = InteractAbility(throne); if (((PrefabGUID)(ref prefabGuid)).GuidHash != 0) { return prefabGuid.LookupName(); } return ""; } private unsafe static bool TryGetInteractTarget(Entity character, out Entity target, out NetworkId nid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) target = Entity.Null; nid = default(NetworkId); if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && character.Has()) { ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(character, val.TypeIndex); if (componentDataRawRW == null) { return false; } IntPtr pointer = new IntPtr(componentDataRawRW); nid = Marshal.PtrToStructure(IntPtr.Add(pointer, 8)); target = Marshal.PtrToStructure(IntPtr.Add(pointer, 20)); if (target != Entity.Null) { entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).Exists(target); } return false; } } return false; } private unsafe static void ClearInteractTarget(Entity character) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (character == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && character.Has()) { ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(character, val.TypeIndex); if (componentDataRawRW != null) { IntPtr pointer = new IntPtr(componentDataRawRW); Marshal.StructureToPtr(default(NetworkId), IntPtr.Add(pointer, 8), fDeleteOld: false); Marshal.StructureToPtr(Entity.Null, IntPtr.Add(pointer, 20), fDeleteOld: false); } } } private static bool TryTeleportToThrone(Entity character, Entity throne) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) string via; return TryTeleportToThrone(character, throne, out via); } private static bool TryTeleportToThrone(Entity character, Entity throne, out string via) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) via = "no-throne"; if (!(character == Entity.Null) && !(throne == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(throne) && throne.Has()) { float3 value = throne.Read().Value; value.y += 1.5f; return TryTeleport(character, value, out via); } } } return false; } private static bool TryTeleport(Entity character, float3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) string via; return TryTeleport(character, pos, out via); } private static bool TryTeleport(Entity character, float3 pos, out string via) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) via = "missing"; if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character)) { bool flag = false; try { TeleportUtilityServer.Teleport(Core.EntityManager, character, pos, default(Nullable_Unboxed)); flag = true; via = "TeleportUtilityServer"; } catch (Exception e) { Core.LogException(e, "TryTeleport"); via = "TeleportUtilityServer-fail"; } bool flag2 = false; try { if (character.Has()) { character.Write(new Translation { Value = pos }); flag2 = true; } if (character.Has()) { character.Write(new LastTranslation { Value = pos }); flag2 = true; } if (flag2) { via = (flag ? "TeleportUtilityServer+Translation" : "Translation"); } } catch (Exception e2) { Core.LogException(e2, "TryTeleport"); if (!flag) { via += "+Translation-fail"; return false; } } return flag || flag2; } } return false; } private static string FinishGoto(Entity character, ulong steam, string playerName, int toPlot, string extra, float3 dest, bool saveReturn, bool clearReturn) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(character); int value = -1; if (TryGetInteractTarget(character, out var target, out var _)) { value = Core.TerritoryService.GetTerritoryId(target); } string text = TryUnseat(character); float3 val = (float3)(character.Has() ? character.Read().Value : default(float3)); if (saveReturn && character.Has() && !returnPos.ContainsKey(steam)) { returnPos[steam] = val; } string via; bool flag = TryTeleport(character, dest, out via); if (clearReturn) { returnPos.Remove(steam); } Entity val2 = Entity.Null; if (toPlot >= 0) { val2 = FindThrone(toPlot); } if (flag && val2 != Entity.Null) { Core.StartCoroutine(SitSoon(character, val2)); } int standingTerritoryId2 = Core.TerritoryService.GetStandingTerritoryId(character); float3 pos = (float3)(character.Has() ? character.Read().Value : default(float3)); lastGoto = (flag ? "ok " : "fail ") + playerName + " " + standingTerritoryId + "->" + toPlot + " sitWas=" + value + " " + via + text; DestDebugLog.Note("throne", toPlot, 0uL, lastGoto + " " + extra); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"moved\":").Append(flag ? "true" : "false").Append(",\"player\":\"") .Append(Esc(playerName)) .Append('"') .Append(",\"steam\":") .Append(steam) .Append(",\"fromPlot\":") .Append(standingTerritoryId) .Append(",\"sitWas\":") .Append(value) .Append(",\"toPlot\":") .Append(toPlot) .Append(",\"afterPlot\":") .Append(standingTerritoryId2) .Append(",\"via\":\"") .Append(Esc(via + text)) .Append('"') .Append(",\"sitPending\":") .Append((flag && val2 != Entity.Null) ? "true" : "false") .Append(",\"extra\":\"") .Append(Esc(extra)) .Append('"') .Append(",\"savedReturn\":") .Append(returnPos.ContainsKey(steam) ? "true" : "false") .Append(','); AppendPos(stringBuilder, val, "from").Append(','); AppendPos(stringBuilder, dest, "dest").Append(','); AppendPos(stringBuilder, pos, "after").Append('}'); return stringBuilder.ToString(); } private static bool TryFindConnected(string who, out ulong steam, out Entity character, out string playerName, out string error) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) steam = 0uL; character = Entity.Null; playerName = ""; error = "no connected player"; ulong result = 0uL; bool flag = !string.IsNullOrWhiteSpace(who) && ulong.TryParse(who, out result); ConnectedPlayer connectedPlayer = default(ConnectedPlayer); bool flag2 = false; foreach (ConnectedPlayer item in ConnectedPlayers()) { if (!flag2) { connectedPlayer = item; flag2 = true; } if (flag && item.steam == result) { steam = item.steam; character = item.character; playerName = item.name; error = ""; return true; } if (!flag && !string.IsNullOrWhiteSpace(who) && item.name.IndexOf(who, StringComparison.OrdinalIgnoreCase) >= 0) { steam = item.steam; character = item.character; playerName = item.name; error = ""; return true; } } if (flag2 && string.IsNullOrWhiteSpace(who)) { steam = connectedPlayer.steam; character = connectedPlayer.character; playerName = connectedPlayer.name; error = ""; return true; } if (flag2 && !string.IsNullOrWhiteSpace(who)) { error = "no connected player matching " + who; } return false; } private unsafe static List ConnectedPlayers() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has()) { continue; } User val6 = val5.Read(); if (!val6.IsConnected) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val6.LocalCharacter)).GetEntityOnServer(); int plot = -1; float3 pos = default(float3); if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { plot = Core.TerritoryService.GetStandingTerritoryId(entityOnServer); if (entityOnServer.Has()) { pos = entityOnServer.Read().Value; } } } list.Add(new ConnectedPlayer { steam = val6.PlatformId, name = ((object)(*(FixedString64Bytes*)(&val6.CharacterName))/*cast due to .constrained prefix*/).ToString(), plot = plot, pos = pos, character = entityOnServer }); } return list; } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } private static StringBuilder AppendPos(StringBuilder sb, float3 pos, string prefix = null) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(prefix)) { sb.Append('"').Append(prefix).Append("\":"); } sb.Append("{\"x\":").Append(F(pos.x)).Append(",\"y\":") .Append(F(pos.y)) .Append(",\"z\":") .Append(F(pos.z)) .Append('}'); return sb; } private static string F(float v) { return v.ToString("0.###", CultureInfo.InvariantCulture); } internal static Entity FindThrone(int plot) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager; if (learnedThroneByPlot.TryGetValue(plot, out var value) && value != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(value) && value.Has() && !value.Has()) { return value; } } RefreshThroneCache(); if (throneByPlot.TryGetValue(plot, out var value2) && value2 != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(value2) && value2.Has() && !value2.Has()) { return value2; } } return Entity.Null; } private static Dictionary AllThrones() { RefreshThroneCache(); return throneByPlot; } private static void RefreshThroneCache() { if (!(throneCacheAt != default(DateTime)) || !((DateTime.UtcNow - throneCacheAt).TotalSeconds < 2.0)) { throneByPlot.Clear(); throneCacheAt = DateTime.UtcNow; RememberThrones(Il2CppType.Of()); RememberPrefabThrones(); } } private static void RememberPrefabThrones() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has() || val5.Has() || val5.Has() || !val5.Has()) { continue; } string text = val5.Read().LookupName(); if (text != null && text.IndexOf("Throne", StringComparison.OrdinalIgnoreCase) >= 0) { int territoryId = Core.TerritoryService.GetTerritoryId(val5); if (territoryId >= 0 && !throneByPlot.ContainsKey(territoryId)) { throneByPlot[territoryId] = val5; } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } private static void RememberThrones(Type component) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(component, (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val5) && val5.Has() && !val5.Has() && !val5.Has()) { int territoryId = Core.TerritoryService.GetTerritoryId(val5); if (territoryId >= 0 && !throneByPlot.ContainsKey(territoryId)) { throneByPlot[territoryId] = val5; } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } private static int CountAlive(int plot) { return AliveRows(plot).Count; } private static List AliveNames(int plot) { List list = AliveRows(plot); List list2 = new List(list.Count); for (int i = 0; i < list.Count; i++) { list2.Add(list[i].Name); } return list2; } internal static List<(string Name, NetworkId Nid)> DebugIdleServants(int plot) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) List list = AliveRows(plot); List<(string, NetworkId)> list2 = new List<(string, NetworkId)>(list.Count); for (int i = 0; i < list.Count; i++) { list2.Add((list[i].Name, list[i].Nid)); } return list2; } private unsafe static List AliveRows(int plot) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Invalid comparison between Unknown and I4 //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) List list = new List(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has() || Core.TerritoryService.GetTerritoryId(val5) != plot) { continue; } ServantCoffinstation val6 = val5.Read(); if ((int)val6.State != 7) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val6.ConnectedServant)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has()) { string text = ((object)(*(FixedString64Bytes*)(&val6.ServantName))/*cast due to .constrained prefix*/).ToString(); list.Add(new ServantRow { Name = (string.IsNullOrWhiteSpace(text) ? "unnamed" : text), Nid = (val5.Has() ? val5.Read() : entityOnServer.Read()), Servant = entityOnServer }); } } } return list; } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } } internal static class ClanTreasuryLend { private struct SourceChest : IEquatable { public int TerritoryId; public NetworkId NetId; public int InvIndex; public int InvVersion; public bool HasNet; public bool Equals(SourceChest other) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (TerritoryId != other.TerritoryId) { return false; } if (HasNet && other.HasNet) { return ((NetworkId)(ref NetId)).Equals(other.NetId); } if (InvIndex == other.InvIndex) { return InvVersion == other.InvVersion; } return false; } public override bool Equals(object obj) { if (obj is SourceChest other) { return Equals(other); } return false; } public override int GetHashCode() { if (HasNet) { return HashCode.Combine(TerritoryId, ((object)Unsafe.As(ref NetId)/*cast due to .constrained prefix*/).GetHashCode()); } return HashCode.Combine(TerritoryId, InvIndex, InvVersion); } public override string ToString() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (HasNet) { return $"net={NetId} plot={TerritoryId} inv={InvIndex}:{InvVersion}"; } return $"inv={InvIndex}:{InvVersion} plot={TerritoryId}"; } } private struct LedgerKey : IEquatable { public int DestPlot; public int Guid; public SourceChest Source; public bool Equals(LedgerKey other) { if (DestPlot == other.DestPlot && Guid == other.Guid) { return Source.Equals(other.Source); } return false; } public override bool Equals(object obj) { if (obj is LedgerKey other) { return Equals(other); } return false; } public override int GetHashCode() { return HashCode.Combine(DestPlot, Guid, Source); } } private struct LastMove { public SourceChest Source; public int Amount; } private const float IntervalSeconds = 5f; internal const int PlankHash = -1017402979; internal const int StoneBrickHash = 1788016417; internal const int CopperIngotHash = -1237019921; internal const int BloodEssenceHash = 862477668; internal const int GreaterBloodEssenceHash = 271594022; internal const int GemDustHash = 820932258; internal const int IronIngotHash = -1750550553; internal const int StoneHash = -1531666018; internal const int GlassHash = -1233716303; internal const int LeatherHash = -1907572080; internal const int ReinforcedPlankHash = -1397591435; internal const int RadiumAlloyHash = 2116142390; internal const int PrimalBloodEssenceHash = 1566989408; internal const int DarkSilverIngotHash = -762000259; internal const int PowerCoreHash = -1190647720; private const int KitPlank = 288; private const int KitStoneBrick = 456; private const int KitCopper = 24; private const int KitIron = 24; private const int KitGemDust = 32; private const int KitStone = 192; private const int KitChestPlank = 72; private const int KitChestCopper = 24; private const int HeartFuelStack = 500; private const int Covering1xCap = 200; private const int CoveringBloodEssenceChests = 500; private static readonly Dictionary ledger = new Dictionary(); private static readonly Dictionary lastMove = new Dictionary(); private static readonly HashSet pendingVerify = new HashSet(); private static readonly HashSet stickyFailed = new HashSet(); private static readonly HashSet warnedNoDest = new HashSet(); private static readonly HashSet loggedDestMode = new HashSet(); private static readonly HashSet loggedFirstSuccess = new HashSet(); private static readonly HashSet previouslyOccupied = new HashSet(); private static readonly HashSet stickyFailedAllSharedPlots = new HashSet(); private static readonly HashSet loggedAllSharedPlotSkip = new HashSet(); private static readonly HashSet loggedUpgradeCosts = new HashSet(); private static readonly HashSet loggedNamedBorrow = new HashSet(); private static readonly Dictionary> heartUpgradeCache = new Dictionary>(); private static readonly Dictionary heartUpgradeCacheLevel = new Dictionary(); private static readonly HashSet loggedHeartFuel = new HashSet(); private static readonly HashSet loggedCovering = new HashSet(); private static readonly HashSet occupiedPlots = new HashSet(); private static readonly HashSet holdKitOverflowPlots = new HashSet(); private static readonly Dictionary> workstationsByPlot = new Dictionary>(); private static List<(int blueprint, bool start, List<(int guid, int amount)> costs)> blueprintCosts; private static readonly Dictionary destStackCount = new Dictionary(); private static readonly Dictionary destEmptyHoldUntil = new Dictionary(); private static readonly HashSet loggedEmptyHold = new HashSet(); private static bool loggedEmptySkip; private const int BuildCoverCopies = 3; private const int EmptyHoldSeconds = 300; private const int UnoccupiedReturnSeconds = 90; private const int MaxLendPullsPerTick = 120; private const int MaxLendPullsPerPlot = 12; private static readonly Dictionary coverCursor = new Dictionary(); private static readonly Dictionary leftAt = new Dictionary(); private static int lendPullsLeft; private static int plotPullsLeft; private static int occupyCursor; private static int depositMaxClass = 5; private static readonly Dictionary One)> coveringCache = new Dictionary)>(); private static Dictionary> tickTreasuryInvs; private static Dictionary> tickAllSharedInvs; private static Dictionary> tickStashes; private static Dictionary> tickVanillaCounts; private static Dictionary> tickUnlocks; private static bool tickCachesOn; private static readonly HashSet islandDirty = new HashSet(); private static int settingsEpoch; private static string lastControlKey = ""; private static bool lastTickUsedPull; private static bool forceHunt; private static bool tickBusy; private static DateTime nextHuntAt; private const int FatHuntMs = 50; private const float HuntMaxSeconds = 15f; private const int SelfSortMovesPerTick = 24; internal static void MarkDirty(int territoryId) { if (territoryId >= 0 && territoryId <= 146) { islandDirty.Add(territoryId); coveringCache.Remove(territoryId); } } internal static void BumpSettings() { settingsEpoch++; } private static bool CanLendPull() { if (lendPullsLeft > 0) { return plotPullsLeft > 0; } return false; } private static void ConsumeLendPull() { if (lendPullsLeft > 0) { lendPullsLeft--; } if (plotPullsLeft > 0) { plotPullsLeft--; } } private static void RefundLendPull() { lendPullsLeft++; plotPullsLeft++; } internal static bool HoldKitOverflow(int plot) { if (plot >= 0) { return holdKitOverflowPlots.Contains(plot); } return false; } internal static Dictionary DebugCovering1x(int plot) { return GetCovering1x(plot); } internal static void DebugTick() { forceHunt = true; nextHuntAt = DateTime.MinValue; if (tickBusy) { return; } IEnumerator enumerator = Tick(); try { while (enumerator.MoveNext()) { } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } } internal static int DebugUnstick(int plot) { if (plot < 0) { int result = stickyFailed.Count + stickyFailedAllSharedPlots.Count; stickyFailed.Clear(); stickyFailedAllSharedPlots.Clear(); return result; } int num = 0; List list = new List(); foreach (long item in stickyFailed) { if ((int)(item >> 32) == plot) { list.Add(item); } } for (int i = 0; i < list.Count; i++) { stickyFailed.Remove(list[i]); num++; } if (stickyFailedAllSharedPlots.Remove(plot)) { num++; } return num; } internal static bool DebugSticky(int plot, int guid) { return stickyFailed.Contains(FailKey(plot, guid)); } internal static bool DebugIsOccupied(int plot) { if (plot >= 0) { return occupiedPlots.Contains(plot); } return false; } internal static string DebugUpgrade(int plot) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plot\":").Append(plot); if (plot < 0) { stringBuilder.Append(",\"error\":\"no plot\"}"); return stringBuilder.ToString(); } Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); if (!(castleHeart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { CastleHeart val = castleHeart.Read(); Dictionary heartUpgradeCosts = GetHeartUpgradeCosts(plot, castleHeart); stringBuilder.Append(",\"heartLevel\":").Append(val.Level).Append(",\"nextLevel\":") .Append(val.Level + 1) .Append(",\"occupied\":") .Append(DebugIsOccupied(plot) ? "true" : "false") .Append(",\"costs\":["); bool flag = true; PrefabGUID val2 = default(PrefabGUID); foreach (KeyValuePair item in heartUpgradeCosts) { if (!flag) { stringBuilder.Append(','); } flag = false; ((PrefabGUID)(ref val2))..ctor(item.Key); int num = CountVanillaOnPlot(plot, val2); stringBuilder.Append("{\"guid\":").Append(item.Key).Append(",\"name\":\"") .Append(EscSim(StashRouting.ItemLabel(val2))) .Append('"') .Append(",\"need\":") .Append(item.Value) .Append(",\"have\":") .Append(num) .Append(",\"ok\":") .Append((num >= item.Value) ? "true" : "false") .Append('}'); } stringBuilder.Append("],\"fuel\":").Append(DebugHeartFuelJson(plot, castleHeart, val)).Append('}'); return stringBuilder.ToString(); } } stringBuilder.Append(",\"error\":\"no heart\"}"); return stringBuilder.ToString(); } private static string DebugHeartFuelJson(int plot, Entity heart, CastleHeart ch) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); Core.TerritoryService.TryGetTerritoryOwnerPlatformId(plot, out var platformId); string[] keys = HeartFuelKeys(heart); List heartFuelInventories = GetHeartFuelInventories(heart); bool flag = Core.PlayerSettings.IsHeartFeedEnabled(platformId, plot); bool flag2 = AnyHeartKey(keys, Core.PlayerSettings.IsHeartFuelSeeded); bool flag3 = AnyHeartKey(keys, Core.PlayerSettings.IsHeartFuelOptOut); int value = CountHeartFuel(heartFuelInventories, heart); int value2 = HeartFuelTopOffNeed(heart, heartFuelInventories); int value3 = HeartFuelEmptySlotNeed(heart, heartFuelInventories); int value4 = HeartFuelNeed(heart, heartFuelInventories); int num = 0; int num2 = 0; int value5 = 0; int value6 = 0; try { num = ((CastleHeart)(ref ch)).GetLevelData((int)ch.Level).ItemSlots; } catch { } if (num <= 0) { try { num = ((CastleHeart)(ref ch)).GetLevelData().ItemSlots; } catch { } } ServerGameManager serverGameManager = Core.ServerGameManager; stringBuilder.Append("{\"hf\":").Append(flag ? "true" : "false").Append(",\"seeded\":") .Append(flag2 ? "true" : "false") .Append(",\"opted\":") .Append(flag3 ? "true" : "false") .Append(",\"invs\":") .Append(heartFuelInventories.Count) .Append(",\"fuel\":") .Append(value) .Append(",\"topOffNeed\":") .Append(value2) .Append(",\"emptyNeed\":") .Append(value3) .Append(",\"need\":") .Append(value4) .Append(",\"level\":") .Append(ch.Level) .Append(",\"itemSlots\":") .Append(num) .Append(",\"slots\":["); bool flag4 = true; DynamicBuffer val = default(DynamicBuffer); DynamicBuffer val2 = default(DynamicBuffer); foreach (Entity item in heartFuelInventories) { if (item == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(item) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item, ref val)) { continue; } value5 = val.Length; value6 = UnlockedFuelSlotCount(heart, item, val.Length); try { if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(heart, ref val2)) { Enumerator enumerator2 = val2.GetEnumerator(); while (enumerator2.MoveNext()) { InventoryInstanceElement current2 = enumerator2.Current; NetworkedEntity externalInventoryEntity = current2.ExternalInventoryEntity; Entity entityOnServer = ((NetworkedEntity)(ref externalInventoryEntity)).GetEntityOnServer(); if (((Entity)(ref entityOnServer)).Equals(item) && current2.Slots > num2) { num2 = current2.Slots; } } } } catch { } for (int i = 0; i < val.Length; i++) { if (!flag4) { stringBuilder.Append(','); } flag4 = false; InventoryBuffer val3 = val[i]; stringBuilder.Append("{\"i\":").Append(i).Append(",\"guid\":") .Append(((PrefabGUID)(ref val3.ItemType)).GuidHash) .Append(",\"n\":") .Append(val3.Amount) .Append(",\"cap\":") .Append(val3.MaxAmountOverride) .Append('}'); } } stringBuilder.Append("],\"bufLen\":").Append(value5).Append(",\"unlocked\":") .Append(value6) .Append(",\"iieSlots\":") .Append(num2) .Append('}'); return stringBuilder.ToString(); } internal static string DebugSimulate(int destPlot, PrefabGUID type, bool apply) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Unknown result type (might be due to invalid IL or missing references) //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06db: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0761: Unknown result type (might be due to invalid IL or missing references) //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_0779: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_0792: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_07f5: Unknown result type (might be due to invalid IL or missing references) //IL_07d3: Unknown result type (might be due to invalid IL or missing references) //IL_084e: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_09b6: Unknown result type (might be due to invalid IL or missing references) //IL_094d: Unknown result type (might be due to invalid IL or missing references) //IL_0950: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plot\":").Append(destPlot).Append(",\"guid\":") .Append(((PrefabGUID)(ref type)).GuidHash) .Append(",\"name\":\"") .Append(EscSim(StashRouting.ItemLabel(type))) .Append('"'); if (destPlot < 0) { stringBuilder.Append(",\"error\":\"no plot\"}"); return stringBuilder.ToString(); } depositMaxClass = 3; try { string destMode; List destInventories = GetDestInventories(destPlot, out destMode); List list = VanillaVisibleDests(destPlot, destInventories); if (list.Count == 0) { list = NonOverflowDests(destPlot, destInventories); } GetBuildCovering1x(destPlot).TryGetValue(((PrefabGUID)(ref type)).GuidHash, out var value); int num = value * 3; int num2 = CountVanillaOnPlot(destPlot, type); bool flag = stickyFailed.Contains(FailKey(destPlot, ((PrefabGUID)(ref type)).GuidHash)); bool flag2 = DestHasRoomFor(list, type); List list2 = StashRouting.OrderDepositInventories(destPlot, list, type, 3); IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(destPlot); List list3 = new List(); foreach (int occupiedPlot in occupiedPlots) { if (logisticsTerritoryIds == null) { continue; } bool flag3 = false; for (int i = 0; i < logisticsTerritoryIds.Count; i++) { if (logisticsTerritoryIds[i] == occupiedPlot) { flag3 = true; break; } } if (flag3) { list3.Add(occupiedPlot); } } List list4 = new List(list3); if (!list4.Contains(destPlot)) { list4.Add(destPlot); } stringBuilder.Append(",\"destMode\":\"").Append(EscSim(destMode)).Append('"') .Append(",\"park\":") .Append(list.Count) .Append(",\"destInvs\":") .Append(destInventories.Count) .Append(",\"ranked\":") .Append(list2.Count) .Append(",\"maxClass\":3") .Append(",\"coveringCap\":") .Append(200) .Append(",\"room\":") .Append(flag2 ? "true" : "false") .Append(",\"sticky\":") .Append(flag ? "true" : "false") .Append(",\"covering1\":") .Append(value) .Append(",\"covering3\":") .Append(num) .Append(",\"local\":") .Append(num2) .Append(",\"need1\":") .Append(Math.Max(0, value - num2)) .Append(",\"need3\":") .Append(Math.Max(0, num - num2)) .Append(",\"occupiedLive\":["); for (int j = 0; j < list3.Count; j++) { if (j > 0) { stringBuilder.Append(','); } stringBuilder.Append(list3[j]); } stringBuilder.Append("],\"occupiedSim\":["); for (int k = 0; k < list4.Count; k++) { if (k > 0) { stringBuilder.Append(','); } stringBuilder.Append(list4[k]); } stringBuilder.Append(']'); Core.TerritoryService.TryGetTerritoryOwnerPlatformId(destPlot, out var platformId); stringBuilder.Append(",\"dests\":["); bool flag4 = true; DynamicBuffer val2 = default(DynamicBuffer); foreach (Entity item in StashesOnPlot(destPlot)) { if (item.Has() || StashRouting.IsNoShare(item) || StashRouting.IsConveyorName(StashRouting.RawName(item)) || !StashRouting.TryGetExternalInventory(item, out var inventory)) { continue; } bool flag5 = IsDest(list, inventory); if (!flag5 && !IsDest(destInventories, inventory)) { continue; } bool flag6 = StashRouting.InventoryHasItem(inventory, type); StashRouting.DepositRank depositRank = StashRouting.RankDeposit(item, type, platformId, flag6, destPlot); bool flag7 = false; for (int l = 0; l < list2.Count; l++) { Entity val = list2[l]; if (((Entity)(ref val)).Equals(inventory)) { flag7 = true; break; } } int num3 = 0; int value2 = 0; int num4 = 0; ServerGameManager serverGameManager = Core.ServerGameManager; if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val2)) { value2 = val2.Length; for (int m = 0; m < val2.Length; m++) { InventoryBuffer val3 = val2[m]; if (((PrefabGUID)(ref val3.ItemType)).GuidHash == 0 || val2[m].Amount <= 0) { num4++; } else { num3++; } } } if (!flag4) { stringBuilder.Append(','); } flag4 = false; stringBuilder.Append("{\"name\":\"").Append(EscSim(StashRouting.RawName(item))).Append('"') .Append(",\"destName\":\"") .Append(EscSim(StashRouting.DestName(item))) .Append('"') .Append(",\"class\":") .Append(depositRank.Class) .Append(",\"label\":\"") .Append(EscSim(depositRank.Label)) .Append('"') .Append(",\"usable\":") .Append(depositRank.IsDepositUsable ? "true" : "false") .Append(",\"ranked\":") .Append(flag7 ? "true" : "false") .Append(",\"park\":") .Append(flag5 ? "true" : "false") .Append(",\"overflow\":") .Append(StashRouting.IsOverflowDestName(StashRouting.RawName(item)) ? "true" : "false") .Append(",\"hasItem\":") .Append(flag6 ? "true" : "false") .Append(",\"stacks\":") .Append(num3) .Append(",\"slots\":") .Append(value2) .Append(",\"empty\":") .Append(num4) .Append('}'); } stringBuilder.Append(']'); int num5 = Math.Max(0, value - num2); if (num5 <= 0) { num5 = Math.Max(0, num - num2); } if (num5 <= 0 && value <= 0) { num5 = 40; } bool flag8 = list4.Count <= 1; Dictionary dictionary = new Dictionary(); for (int n = 0; n < list4.Count; n++) { int num6 = list4[n]; if (num6 != destPlot) { int num7 = ChestTargetForPlot(num6, ((PrefabGUID)(ref type)).GuidHash); if (num7 < 0) { num7 = 0; } dictionary[num6] = CountVanillaOnPlot(num6, type) - num7; } } int num8 = 0; int num9 = 0; int num10 = 0; stringBuilder.Append(",\"leftoverBypass\":").Append(flag8 ? "true" : "false").Append(",\"sources\":["); bool flag9 = true; if (logisticsTerritoryIds != null) { ServerGameManager serverGameManager2 = Core.ServerGameManager; for (int num11 = 0; num11 < 2; num11++) { if (num5 <= 0) { break; } for (int num12 = 0; num12 < 3; num12++) { if (num5 <= 0) { break; } foreach (int item2 in logisticsTerritoryIds) { if (num5 <= 0) { break; } if (item2 == destPlot) { continue; } bool flag10 = list4.Contains(item2); bool flag11 = flag8 && num12 == 2; if (num11 == 1 && !flag10) { continue; } foreach (Entity item3 in StashesOnPlot(item2)) { if (num5 <= 0) { break; } if (item3.Has() || StashRouting.IsNoShare(item3)) { continue; } int num13 = StashRouting.SourcePass(item3); if (!StashRouting.TryGetExternalInventory(item3, out var inventory2)) { continue; } int inventoryItemCount = ((ServerGameManager)(ref serverGameManager2)).GetInventoryItemCount(inventory2, type); if (inventoryItemCount <= 0 || num13 != num12) { continue; } if (num11 == 1 && !flag11) { List list5 = GetTreasuryInventories(item2); if (list5.Count == 0) { list5 = GetAllSharedInventories(item2); } if (!IsDest(list5, inventory2)) { continue; } } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(item2, out var platformId2); int pullReserve = Core.PlayerSettings.GetPullReserve(platformId2, type); string text = ""; int value3; if (num11 == 0 && flag10 && !flag11) { text = "occupied"; } else if (num11 == 1 && !flag11 && (!dictionary.TryGetValue(item2, out value3) || value3 <= 0)) { text = "no-spare"; } else if (num13 < 0) { text = "ns"; } else if (IsDest(list, inventory2) || IsDest(destInventories, inventory2)) { text = "is-dest"; } int num14 = inventoryItemCount; int num15 = ((pullReserve > 0) ? (inventoryItemCount - pullReserve) : inventoryItemCount); if (num15 < 0) { num15 = 0; } int num16 = 0; int num17 = 0; int num18 = 0; if (text.Length == 0) { num16 = ((num14 < num5) ? num14 : num5); if (num16 < 0) { num16 = 0; } num17 = ((num15 < num5) ? num15 : num5); if (num17 < 0) { num17 = 0; } num18 = (flag8 ? num16 : num17); if (num11 == 1 && dictionary.TryGetValue(item2, out var value4) && value4 >= 0 && num18 > value4) { num18 = value4; } num8 += num18; num9 += (flag8 ? num17 : num18); if (!apply && num18 > 0) { num5 -= num18; if (num11 == 1) { dictionary[item2] -= num18; } } } int num19 = 0; bool destRejected = false; if (apply && text.Length == 0 && num18 > 0 && !flag) { num19 = MoveIntoDest(destPlot, inventory2, list, type, num18, destMode, out destRejected); num10 += num19; if (num19 > 0) { num5 -= num19; if (num11 == 1) { dictionary[item2] -= num19; } } } if (!flag9) { stringBuilder.Append(','); } flag9 = false; stringBuilder.Append("{\"plot\":").Append(item2).Append(",\"name\":\"") .Append(EscSim(StashRouting.RawName(item3))) .Append('"') .Append(",\"pass\":") .Append(num13) .Append(",\"have\":") .Append(inventoryItemCount) .Append(",\"reserve\":") .Append(pullReserve) .Append(",\"availBypass\":") .Append(num14) .Append(",\"availHonor\":") .Append(num15) .Append(",\"occupied\":") .Append(flag10 ? "true" : "false") .Append(",\"namedBypass\":") .Append(flag11 ? "true" : "false") .Append(",\"sparePass\":") .Append((num11 == 1) ? "true" : "false") .Append(",\"skip\":\"") .Append(EscSim(text)) .Append('"') .Append(",\"takeBypass\":") .Append(num16) .Append(",\"takeHonor\":") .Append(num17) .Append(",\"take\":") .Append(num18) .Append(",\"got\":") .Append(num19) .Append(",\"destRejected\":") .Append(destRejected ? "true" : "false") .Append('}'); } } } } } stringBuilder.Append("],\"wouldMove\":").Append(num8).Append(",\"wouldHonor\":") .Append(num9) .Append(",\"apply\":") .Append(apply ? "true" : "false") .Append(",\"moved\":") .Append(num10) .Append('}'); return stringBuilder.ToString(); } finally { depositMaxClass = 5; } } private static string EscSim(string s) { if (string.IsNullOrEmpty(s)) { return ""; } return s.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\r", " ") .Replace("\n", " "); } internal static string DebugFairness(int users) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (users < 1) { users = 30; } if (users > 64) { users = 64; } List list = new List(); for (int i = 0; i <= 146; i++) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(i); if (!(castleHeart == Entity.Null) && ClanTreasuryShare.ShouldShare(castleHeart)) { list.Add(i); } } list.Sort(); List list2 = new List(); list2.AddRange(list); if (list2.Count > users) { list2.RemoveRange(users, list2.Count - users); } int j = 1000; while (list2.Count < users) { for (; list2.Contains(j); j++) { } list2.Add(j++); } list2.Sort(); HashSet hashSet = new HashSet(list2); int num = 10; if (num > hashSet.Count) { num = hashSet.Count; } int num2 = ((hashSet.Count != 0 && num > 0) ? ((hashSet.Count + num - 1) / num) : 0); int num3 = ((occupyCursor >= 0) ? occupyCursor : 0); List list3 = new List(hashSet); list3.Sort(); List list4 = new List(); if (list3.Count > 0) { int num4 = num3 % list3.Count; for (int k = 0; k < list3.Count && k < num; k++) { list4.Add(list3[(num4 + k) % list3.Count]); } } bool flag = hashSet.Count <= 1; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"users\":").Append(users).Append(",\"maxPullsPerTick\":") .Append(120) .Append(",\"maxPullsPerPlot\":") .Append(12) .Append(",\"plotsPerTick\":") .Append(num) .Append(",\"ticksToServeAll\":") .Append(num2) .Append(",\"secondsToServeAll\":") .Append(num2 * 5) .Append(",\"occupyCursor\":") .Append(num3) .Append(",\"livePlots\":["); for (int l = 0; l < list.Count; l++) { if (l > 0) { stringBuilder.Append(','); } stringBuilder.Append(list[l]); } stringBuilder.Append("],\"uniqueOccupied\":").Append(hashSet.Count).Append(",\"leftoverBypass\":") .Append(flag ? "true" : "false") .Append(",\"guestOccupies\":false") .Append(",\"selfSortGate\":\"plotPullsLeft\"") .Append(",\"firstTickServed\":["); for (int m = 0; m < list4.Count; m++) { if (m > 0) { stringBuilder.Append(','); } stringBuilder.Append(list4[m]); } stringBuilder.Append("],\"guest\":\"IsSameClanAsHeart required to occupy; CS-on visitor uses own clan island; chest HUD CombineMerged only if a clan member is standing\"").Append('}'); return stringBuilder.ToString(); } internal static string DebugGuest() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = 0; int num3 = 0; EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has()) { continue; } User val6 = val5.Read(); if (!val6.IsConnected) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val6.LocalCharacter)).GetEntityOnServer(); if (entityOnServer == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entityOnServer) || !entityOnServer.Has()) { continue; } int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(entityOnServer); if (standingTerritoryId < 0) { num3++; continue; } Entity castleHeart = Core.TerritoryService.GetCastleHeart(standingTerritoryId); if (castleHeart == Entity.Null) { num3++; } else if (Core.TerritoryService.IsSameClanAsHeart(entityOnServer, castleHeart)) { num++; } else { num2++; } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"occupy\":\"ShouldShare heart + IsSameClanAsHeart (guests never occupy / covering / leftover-bypass)\"").Append(",\"build\":\"CanShareBuild standing heart + IsSameClanAsHeart\"").Append(",\"chestHud\":\"player actor IsSameClanAsHeart; else ClanMemberStandingOnHeart\"") .Append(",\"logistics\":\"CS ON = actor clan island (cse standing stays local); CS OFF = standing allied only\"") .Append(",\"coveringUnlocks\":\"CollectUnlocksOnPlot clan members on that plot only\"") .Append(",\"clanStanding\":") .Append(num) .Append(",\"guestsStanding\":") .Append(num2) .Append(",\"offPlot\":") .Append(num3) .Append(",\"guestOccupies\":false") .Append(",\"ok\":true}"); return stringBuilder.ToString(); } internal static void AddWorkstation(Entity station) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) int territoryId = Core.TerritoryService.GetTerritoryId(station); if (territoryId >= 0) { if (!workstationsByPlot.TryGetValue(territoryId, out var value)) { value = new List(); workstationsByPlot[territoryId] = value; } if (!value.Contains(station)) { value.Add(station); } } } internal static void RemoveWorkstation(Entity station) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) int territoryId = Core.TerritoryService.GetTerritoryId(station); if (territoryId >= 0 && workstationsByPlot.TryGetValue(territoryId, out var value)) { value.Remove(station); } } private static long FailKey(int plot, int guid) { return ((long)plot << 32) | (uint)guid; } private static string DestHoldKey(int destPlot, Entity inventory) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string[] array = KitChestKeys(destPlot, inventory); if (array != null && array.Length != 0) { return array[0]; } return "inv" + inventory.Index + ":" + inventory.Version; } private static int CountAnyStacks(Entity inv) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!(inv == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inv)) { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inv, ref val)) { return 0; } int num = 0; for (int i = 0; i < val.Length; i++) { InventoryBuffer val2 = val[i]; if (((PrefabGUID)(ref val2.ItemType)).GuidHash != 0 && val[i].Amount > 0) { num++; } } return num; } } return 0; } private static void NoteDestEmpties(int destPlot, List destInvs) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown if (destInvs == null) { return; } DateTime utcNow = DateTime.UtcNow; bool flag = default(bool); for (int i = 0; i < destInvs.Count; i++) { Entity val = destInvs[i]; string text = DestHoldKey(destPlot, val); int num = CountAnyStacks(val); destStackCount.TryGetValue(text, out var value); destStackCount[text] = num; if (value > 0 && num == 0) { destEmptyHoldUntil[text] = utcNow.AddSeconds(300.0); if (loggedEmptyHold.Add(text)) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(96, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" chest="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" emptied -- no kit/covering/self-sort dest for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(300); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("s (unbuild ok)"); } log.LogInfo(val2); } } else if (num > 0) { destEmptyHoldUntil.Remove(text); loggedEmptyHold.Remove(text); } } } internal static bool InEmptyHold(int destPlot, Entity inventory) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string text = DestHoldKey(destPlot, inventory); if (!destEmptyHoldUntil.TryGetValue(text, out var value)) { return false; } if (DateTime.UtcNow >= value) { destEmptyHoldUntil.Remove(text); loggedEmptyHold.Remove(text); return false; } return true; } private static List FilterEmptyHold(int destPlot, List destInvs) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (destInvs == null) { return list; } for (int i = 0; i < destInvs.Count; i++) { Entity val = destInvs[i]; if (!InEmptyHold(destPlot, val)) { list.Add(val); } } return list; } internal static IEnumerator Loop() { WaitForSeconds wait = new WaitForSeconds(5f); while (true) { yield return wait; IEnumerator step; try { step = Tick(); } catch (Exception e) { Core.LogException(e, "Loop"); continue; } try { while (step != null) { bool flag; try { flag = step.MoveNext(); } catch (Exception e2) { Core.LogException(e2, "Loop"); break; } if (!flag) { break; } yield return step.Current; } } finally { (step as IDisposable)?.Dispose(); } } } private static float HuntWaitSeconds(int huntMs) { if (huntMs <= 50) { return 5f; } float num = 5f * ((float)huntMs / 50f); if (num < 5f) { num = 5f; } if (num > 15f) { num = 15f; } return num; } private static bool TimeToYield() { if (Core.TerritoryService != null) { return Core.TerritoryService.ShouldUpdateYield(); } return false; } private static bool IsStarterKitGuid(int guid) { if (guid != -1017402979 && guid != 1788016417 && guid != -1237019921 && guid != -1750550553 && guid != 820932258) { return guid == -1531666018; } return true; } private static bool IsRaided(Entity heart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 if (!(heart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(heart) && heart.Has()) { return (int)heart.Read().ActiveEvent >= 2; } } return false; } private static Dictionary StarterKitTargets() { return new Dictionary { [-1017402979] = 288, [1788016417] = 456, [-1237019921] = 24, [-1750550553] = 24, [820932258] = 32, [-1531666018] = 192 }; } private static int ChestTarget(int guid, Dictionary upgrade, Dictionary kit) { int num = 0; if (upgrade != null && upgrade.TryGetValue(guid, out var value) && value > num) { num = value; } if (kit != null && kit.TryGetValue(guid, out var value2) && value2 > num) { num = value2; } return num; } private static bool IsTreasuryFloor(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 if (!(stash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash)) { if (ClanTreasuryShare.IsTreasuryLinked(stash)) { return true; } if (stash.Has()) { return (int)stash.Read().MatchingFloorType == 14; } return false; } } return false; } private static bool IsTreasuryRejectedBlood(PrefabGUID item) { int guidHash = ((PrefabGUID)(ref item)).GuidHash; if (guidHash == 0) { return false; } return guidHash == 862477668; } private static string FirstDestName(int plot, List destInvs) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (destInvs == null) { return ""; } foreach (Entity destInv in destInvs) { foreach (Entity item in StashesOnPlot(plot)) { if (StashRouting.TryGetExternalInventory(item, out var inventory) && ((Entity)(ref inventory)).Equals(destInv)) { return StashRouting.RawName(item); } } } return ""; } private static List GetBloodAcceptingDests(int plot, PrefabGUID item) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Core.TerritoryService.TryGetTerritoryOwnerPlatformId(plot, out var platformId); foreach (Entity item2 in StashesOnPlot(plot)) { if (item2.Has()) { continue; } string text = StashRouting.RawName(item2); if (!StashRouting.IsNoShareName(text) && !StashRouting.IsSpecialName(text) && !StashRouting.IsConveyorName(text) && StashRouting.TryGetExternalInventory(item2, out var inventory)) { bool num = StashRouting.IsUnnamedOrGeneric(text); int specificity; bool flag = ((PrefabGUID)(ref item)).GuidHash != 0 && (StashRouting.ExactItemNameMatch(text, item, out specificity) || StashRouting.CategoryMatch(text, item, platformId, out specificity)); if (num || flag) { list.Add(inventory); } } } return StashRouting.OrderDepositInventories(plot, list, item); } private static List DestInvsForUpgradeItem(int plot, PrefabGUID type, List defaultDests) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!IsTreasuryRejectedBlood(type)) { return defaultDests ?? new List(); } List bloodAcceptingDests = GetBloodAcceptingDests(plot, type); if (bloodAcceptingDests.Count > 0) { return bloodAcceptingDests; } if (defaultDests != null && defaultDests.Count > 0) { return StashRouting.OrderDepositInventories(plot, defaultDests, type, 3); } return new List(); } private static int ChestTargetForPlot(int plot, int guid) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); Dictionary upgrade = null; if (castleHeart != Entity.Null && !IsRaided(castleHeart)) { if (GetDestInventories(plot, out var _).Count > 0) { upgrade = GetHeartUpgradeCosts(plot, castleHeart); } return ChestTarget(guid, upgrade, null); } return ChestTarget(guid, upgrade, null); } private static bool DestHasEmptySlots(List destInvs) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = Core.ServerGameManager; if (destInvs == null) { return false; } DynamicBuffer val2 = default(DynamicBuffer); for (int i = 0; i < destInvs.Count; i++) { Entity val = destInvs[i]; if (val == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val, ref val2)) { continue; } for (int j = 0; j < val2.Length; j++) { InventoryBuffer val3 = val2[j]; if (val3.Amount <= 0 || ((PrefabGUID)(ref val3.ItemType)).GuidHash == 0) { return true; } } } return false; } private static bool DestHasRoomFor(List destInvs, PrefabGUID type) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (DestHasEmptySlots(destInvs)) { return true; } ServerGameManager serverGameManager = Core.ServerGameManager; if (destInvs == null) { return false; } DynamicBuffer val2 = default(DynamicBuffer); for (int i = 0; i < destInvs.Count; i++) { Entity val = destInvs[i]; if (val == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val, ref val2)) { continue; } for (int j = 0; j < val2.Length; j++) { InventoryBuffer val3 = val2[j]; if (((PrefabGUID)(ref val3.ItemType)).Equals(type) && val3.Amount > 0 && val3.MaxAmountOverride > 0 && val3.Amount < val3.MaxAmountOverride) { return true; } } } return false; } private static bool DestHasAnyKit(List destInvs) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (CountIn(destInvs, new PrefabGUID(-1017402979)) <= 0 && CountIn(destInvs, new PrefabGUID(1788016417)) <= 0 && CountIn(destInvs, new PrefabGUID(-1237019921)) <= 0 && CountIn(destInvs, new PrefabGUID(-1750550553)) <= 0 && CountIn(destInvs, new PrefabGUID(820932258)) <= 0) { return CountIn(destInvs, new PrefabGUID(-1531666018)) > 0; } return true; } private static bool DestHasAllKitTypes(List destInvs) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (CountIn(destInvs, new PrefabGUID(-1017402979)) > 0 && CountIn(destInvs, new PrefabGUID(1788016417)) > 0 && CountIn(destInvs, new PrefabGUID(-1237019921)) > 0 && CountIn(destInvs, new PrefabGUID(-1750550553)) > 0 && CountIn(destInvs, new PrefabGUID(820932258)) > 0) { return CountIn(destInvs, new PrefabGUID(-1531666018)) > 0; } return false; } private static bool PlotHasAllKitTypes(int plot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (CountVanillaOnPlot(plot, new PrefabGUID(-1017402979)) > 0 && CountVanillaOnPlot(plot, new PrefabGUID(1788016417)) > 0 && CountVanillaOnPlot(plot, new PrefabGUID(-1237019921)) > 0 && CountVanillaOnPlot(plot, new PrefabGUID(-1750550553)) > 0 && CountVanillaOnPlot(plot, new PrefabGUID(820932258)) > 0) { return CountVanillaOnPlot(plot, new PrefabGUID(-1531666018)) > 0; } return false; } private static int GetItemMaxStack(PrefabGUID type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) try { ItemData val = default(ItemData); if (Core.GameDataSystem.ItemHashLookupMap.TryGetValue(type, ref val)) { int maxAmount = val.MaxAmount; if (maxAmount > 0) { return maxAmount; } } } catch { } try { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity val2 = default(Entity); if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(type, ref val2) && val2.Has()) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val2)) { int maxAmount2 = val2.Read().MaxAmount; if (maxAmount2 > 0) { return maxAmount2; } } } } catch { } return 0; } private static int KitBypassTarget(int guid, int locked) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int itemMaxStack = GetItemMaxStack(new PrefabGUID(guid)); if (itemMaxStack <= 1) { return locked; } if (itemMaxStack <= locked) { return locked; } return itemMaxStack; } private static int LendStarterKitOnce(int destPlot, List kitDest, IReadOnlyList clanIds, HashSet occupiedInClan, string destMode) { int num = 0; bool ignoreLeftoverNamed = occupiedInClan == null || occupiedInClan.Count <= 1; num += LendKitGuid(destPlot, kitDest, clanIds, occupiedInClan, destMode, -1017402979, KitBypassTarget(-1017402979, 72), ignoreLeftoverNamed); num += LendKitGuid(destPlot, kitDest, clanIds, occupiedInClan, destMode, -1237019921, KitBypassTarget(-1237019921, 24), ignoreLeftoverNamed); num += LendKitGuid(destPlot, kitDest, clanIds, occupiedInClan, destMode, -1750550553, KitBypassTarget(-1750550553, 24), ignoreLeftoverNamed); num += LendKitGuid(destPlot, kitDest, clanIds, occupiedInClan, destMode, 820932258, KitBypassTarget(820932258, 32), ignoreLeftoverNamed); num += LendKitGuid(destPlot, kitDest, clanIds, occupiedInClan, destMode, 1788016417, KitBypassTarget(1788016417, 456), ignoreLeftoverNamed); num += LendKitGuid(destPlot, kitDest, clanIds, occupiedInClan, destMode, -1531666018, KitBypassTarget(-1531666018, 192), ignoreLeftoverNamed); if (DestHasEmptySlots(kitDest)) { num += LendKitGuid(destPlot, kitDest, clanIds, occupiedInClan, destMode, -1017402979, 288, ignoreLeftoverNamed: false); } return num; } private static int LendKitGuid(int destPlot, List kitDest, IReadOnlyList clanIds, HashSet occupiedInClan, string destMode, int guid, int target, bool ignoreLeftoverNamed) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) if (kitDest == null || kitDest.Count == 0 || guid == 0 || target <= 0 || !CanLendPull()) { return 0; } PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(guid); int num = CountIn(kitDest, val); if (num >= target) { return 0; } bool flag = default(bool); if (!DestHasRoomFor(kitDest, val)) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(77, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] kit destPlot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(guid); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" moved=0 dest-full local="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" target="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(target); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" dest="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destMode); } log.LogInfo(val2); DestDebugLog.Miss("kit", destPlot, val, num, target, "dest-full dest=" + destMode); return 0; } int need = target - num; ConsumeLendPull(); bool fail = false; int leftoverBlocked = 0; int leftoverHave = 0; int leftoverReserve = 0; int num2 = PullFromSources(destPlot, kitDest, val, need, target, clanIds, occupiedInClan, destMode, occupiedSpareOnly: false, allowNamed: true, allowSamePlot: false, ledgerMoves: true, ignoreLeftoverNamed, ref fail, ref leftoverBlocked, ref leftoverHave, ref leftoverReserve); if (!fail) { need = target - CountIn(kitDest, val); if (need > 0) { num2 += PullFromSources(destPlot, kitDest, val, need, target, clanIds, occupiedInClan, destMode, occupiedSpareOnly: true, allowNamed: true, allowSamePlot: false, ledgerMoves: true, ignoreLeftoverNamed, ref fail, ref leftoverBlocked, ref leftoverHave, ref leftoverReserve); } } if (num2 <= 0) { if (fail) { ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(94, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] kit destPlot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(guid); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" moved=0 dest-rejected-or-copy-fail local="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(CountIn(kitDest, val)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" target="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(target); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" dest="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destMode); } log2.LogInfo(val2); } else if (leftoverBlocked > 0) { ManualLogSource log3 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(125, 9, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] kit destPlot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(guid); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" moved=0 no-source local="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(CountIn(kitDest, val)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" target="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(target); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" dest="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destMode); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" leftover="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(leftoverReserve); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" have="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(leftoverHave); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" leftover-blocked="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(leftoverBlocked); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" named-bypass="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ignoreLeftoverNamed); } log3.LogInfo(val2); DestDebugLog.Miss("kit", destPlot, val, leftoverHave, target, "leftover-blocked leftover=" + leftoverReserve + " dest=" + destMode); } else { ManualLogSource log4 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(77, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] kit destPlot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(guid); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" moved=0 no-source local="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(CountIn(kitDest, val)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" target="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(target); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" dest="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destMode); } log4.LogInfo(val2); DestDebugLog.Miss("kit", destPlot, val, CountIn(kitDest, val), target, "no-source dest=" + destMode); } return 0; } pendingVerify.Add(FailKey(destPlot, guid)); return num2; } private static bool InventoryIsOverflow(int plot, Entity inv) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (inv == Entity.Null) { return false; } foreach (Entity item in StashesOnPlot(plot)) { if (StashRouting.TryGetExternalInventory(item, out var inventory) && ((Entity)(ref inventory)).Equals(inv)) { return StashRouting.IsOverflowDestName(StashRouting.RawName(item)); } } return false; } private static Entity StashForInventory(int plot, Entity inv) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (inv == Entity.Null) { return Entity.Null; } foreach (Entity item in StashesOnPlot(plot)) { if (StashRouting.TryGetExternalInventory(item, out var inventory) && ((Entity)(ref inventory)).Equals(inv)) { return item; } } return Entity.Null; } private static List VanillaVisibleDests(int destPlot, List destInvs) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); if (destInvs == null) { return list; } foreach (Entity destInv in destInvs) { if (destInv == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(destInv) || InventoryIsOverflow(destPlot, destInv)) { continue; } Entity stash = StashForInventory(destPlot, destInv); string name = StashRouting.RawName(stash); if (!StashRouting.IsConveyorName(name)) { if (IsTreasuryFloor(stash) || ClanTreasuryShare.IsTreasuryLinked(stash)) { list.Add(destInv); } else if (StashRouting.IsUnnamedOrGeneric(name)) { list2.Add(destInv); } } } if (list.Count <= 0) { return list2; } return list; } private static List NonOverflowDests(int destPlot, List destInvs) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (destInvs == null) { return list; } foreach (Entity destInv in destInvs) { if (!(destInv == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(destInv) && !InventoryIsOverflow(destPlot, destInv) && !StashRouting.IsConveyorName(StashRouting.RawName(StashForInventory(destPlot, destInv)))) { list.Add(destInv); } } } return list; } private static List FirstUsableKitDest(int destPlot, List destInvs) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (Entity item in StashRouting.OrderDepositInventories(destPlot, destInvs, default(PrefabGUID))) { if (item == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(item) || InventoryIsOverflow(destPlot, item) || AnyHeartKey(KitChestKeys(destPlot, item), Core.PlayerSettings.IsStarterKitChestOptOut)) { continue; } list.Add(item); foreach (Entity item2 in StashesOnPlot(destPlot)) { if (StashRouting.TryGetExternalInventory(item2, out var inventory) && ((Entity)(ref inventory)).Equals(item)) { StashRouting.LogDestPick(StashRouting.RankDeposit(item2, default(PrefabGUID), 0uL, hasItem: false).Label, destPlot, default(PrefabGUID), StashRouting.RawName(item2), "kit-first-dest"); break; } } return list; } return FirstDestOnly(destPlot, destInvs); } private static List FirstDestOnly(int destPlot, List destInvs) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = StashRouting.OrderDepositInventories(destPlot, destInvs, default(PrefabGUID)); if (list2.Count == 0) { return list; } Entity val = Entity.Null; foreach (Entity item in list2) { if (!InventoryIsOverflow(destPlot, item)) { val = item; break; } } if (val == Entity.Null) { val = list2[0]; } list.Add(val); foreach (Entity item2 in StashesOnPlot(destPlot)) { if (StashRouting.TryGetExternalInventory(item2, out var inventory) && ((Entity)(ref inventory)).Equals(val)) { StashRouting.LogDestPick(StashRouting.RankDeposit(item2, default(PrefabGUID), 0uL, hasItem: false).Label, destPlot, default(PrefabGUID), StashRouting.RawName(item2), "kit-first-dest"); break; } } return list; } private static void MarkStickyFail(int destPlot, long key, string destMode) { stickyFailed.Add(key); if (destMode == "allShared") { stickyFailedAllSharedPlots.Add(destPlot); } } private unsafe static bool IsNamedStash(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!(stash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash) && stash.Has()) { NameableInteractable val = stash.Read(); return !string.IsNullOrWhiteSpace(((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString()); } } return false; } private static bool IsPreferredSourceStash(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (ClanTreasuryShare.IsTreasuryLinked(stash)) { return true; } return !IsNamedStash(stash); } private static Dictionary GetHeartUpgradeCosts(int destPlot, Entity heartEntity) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) Dictionary result = new Dictionary(); if (!(heartEntity == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(heartEntity) && heartEntity.Has()) { bool flag = default(bool); try { CastleHeart val = heartEntity.Read(); if (heartUpgradeCache.TryGetValue(destPlot, out var value) && heartUpgradeCacheLevel.TryGetValue(destPlot, out var value2) && value2 == val.Level) { return value; } Dictionary dictionary = ParseHeartUpgradeCosts(val); heartUpgradeCache[destPlot] = dictionary; heartUpgradeCacheLevel[destPlot] = val.Level; if (loggedUpgradeCosts.Add(destPlot)) { List list = new List(); foreach (KeyValuePair item in dictionary) { list.Add($"{item.Key}={item.Value}"); } string text = ((list.Count == 0) ? "(none)" : string.Join(",", list)); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(54, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" heartLevel="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.Level); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" UpgradeCosts "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); } log.LogInfo(val2); } return dictionary; } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(54, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" UpgradeCosts unreadable: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log2.LogWarning(val3); return result; } } } return result; } private static Dictionary ParseHeartUpgradeCosts(CastleHeart ch) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); byte level = ch.Level; int num = level + 1; bool flag = default(bool); try { AddUpgradeCosts(dictionary, ((CastleHeart)(ref ch)).GetLevelData(num).UpgradeCosts); } catch (Exception ex) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] GetLevelData("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } if (dictionary.Count == 0) { try { AddUpgradeCosts(dictionary, ((CastleHeart)(ref ch)).GetLevelData().UpgradeCosts); } catch (Exception ex2) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] GetLevelData failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex2.Message); } log2.LogWarning(val); } } if (dictionary.Count == 0) { TryParseUpgradeCostsFromBlob(ch, dictionary, num); } if (dictionary.Count == 0) { TryParseUpgradeCostsFromBlob(ch, dictionary, level); } if (dictionary.Count == 0) { ApplyFallbackUpgradeCosts(level, dictionary); } return dictionary; } private static void TryParseUpgradeCostsFromBlob(CastleHeart ch, Dictionary map, int wantLevel) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) try { if (!ch.Data.IsCreated) { return; } BlobArray levels = ch.Data.Value.Levels; for (int i = 0; i < 2; i++) { if (map.Count != 0) { break; } for (int j = 0; j < levels.Length; j++) { ref CastleHeartLevelBlobData reference = ref levels[j]; bool num; if (i != 0) { if (j == wantLevel) { goto IL_0053; } num = j == wantLevel - 1; } else { num = reference.Level == wantLevel; } if (!num) { continue; } goto IL_0053; IL_0053: AddUpgradeCosts(map, reference.UpgradeCosts); if (map.Count > 0) { return; } } } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] blob UpgradeCosts failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } private static void ApplyFallbackUpgradeCosts(int currentLevel, Dictionary map) { switch (currentLevel) { case 1: map[-1907572080] = 12; map[-1237019921] = 12; break; case 2: map[-1397591435] = 8; map[-1233716303] = 24; map[271594022] = 1; break; case 3: map[2116142390] = 12; map[1566989408] = 1; break; case 4: map[-762000259] = 12; map[-1190647720] = 4; map[1566989408] = 1; break; } } private static void AddUpgradeCosts(Dictionary map, BlobArray costs) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) int length = costs.Length; for (int i = 0; i < length; i++) { CastleHeartCost val = costs[i]; int guidHash = ((PrefabGUID)(ref val.ItemType)).GuidHash; int amount = val.Amount; if (guidHash != 0 && amount > 0 && (!map.TryGetValue(guidHash, out var value) || amount > value)) { map[guidHash] = amount; } } } private static void BeginLendTickCaches(HashSet occupied) { tickCachesOn = true; tickTreasuryInvs = new Dictionary>(); tickAllSharedInvs = new Dictionary>(); tickStashes = new Dictionary>(); tickVanillaCounts = new Dictionary>(); StashRouting.InvalidatePlotStashMap(); SeedUnlocksForOccupied(occupied); } private static void EndLendTickCaches() { tickCachesOn = false; tickTreasuryInvs = null; tickAllSharedInvs = null; tickStashes = null; tickVanillaCounts = null; tickUnlocks = null; StashRouting.InvalidatePlotStashMap(); } private static void InvalidateTickPlotCounts(int plot) { if (tickVanillaCounts != null) { tickVanillaCounts.Remove(plot); } } private static void SeedUnlocksForOccupied(HashSet occupied) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) tickUnlocks = new Dictionary>(); if (occupied == null || occupied.Count == 0) { return; } foreach (int item in occupied) { tickUnlocks[item] = new HashSet(); } EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has()) { continue; } User val6 = val5.Read(); if (!val6.IsConnected) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val6.LocalCharacter)).GetEntityOnServer(); if (entityOnServer == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entityOnServer) || !entityOnServer.Has()) { continue; } int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(entityOnServer); if (tickUnlocks.TryGetValue(standingTerritoryId, out var value)) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(standingTerritoryId); if (Core.TerritoryService.IsSameClanAsHeart(entityOnServer, castleHeart)) { AddUnlockedBlueprints(val5, value); } } } } catch (Exception e) { Core.LogException(e, "SeedUnlocksForOccupied"); } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } private static IEnumerator Tick() { if (!Core.HasInitialized || tickBusy) { yield break; } tickBusy = true; bool hunt = false; int connectedPlayers = 0; int occupiedCount = 0; DateTime tickAt = DateTime.UtcNow; int usedPulls = 0; int skip = 1; int backoff = 0; try { HashSet occupied = CollectOccupiedClanSharePlots(out connectedPlayers); occupiedCount = occupied.Count; if (connectedPlayers == 0) { ReturnAllLedgers("empty-server"); previouslyOccupied.Clear(); leftAt.Clear(); pendingVerify.Clear(); occupiedPlots.Clear(); holdKitOverflowPlots.Clear(); lastTickUsedPull = false; nextHuntAt = DateTime.MinValue; if (!loggedEmptySkip) { Core.Log.LogInfo((object)"[ClanTreasuryLend] empty server (0 connected players) -- zero lends, returned leftovers"); DestDebugLog.Note("lend", -1, 0uL, "empty-server"); loggedEmptySkip = true; } yield break; } loggedEmptySkip = false; lendPullsLeft = 120; foreach (int item in occupied) { leftAt.Remove(item); } foreach (int item2 in previouslyOccupied) { if (!occupied.Contains(item2) && !leftAt.ContainsKey(item2)) { leftAt[item2] = DateTime.UtcNow; } } List list = new List(); foreach (KeyValuePair item3 in leftAt) { if ((DateTime.UtcNow - item3.Value).TotalSeconds >= 90.0) { list.Add(item3.Key); } } for (int i = 0; i < list.Count; i++) { ReturnPlot(list[i], "unoccupied"); leftAt.Remove(list[i]); } previouslyOccupied.Clear(); occupiedPlots.Clear(); holdKitOverflowPlots.Clear(); foreach (int item4 in occupied) { previouslyOccupied.Add(item4); occupiedPlots.Add(item4); GetDestInventories(item4, out var destMode); if (destMode == "allShared") { holdKitOverflowPlots.Add(item4); } } CheckStickyRetain(occupied); List order = new List(occupied); order.Sort(); if (order.Count == 0) { yield break; } if (occupyCursor < 0) { occupyCursor = 0; } int start = occupyCursor % order.Count; occupyCursor = (start + 1) % order.Count; bool flag = EmptyHoldExpired(); string text = BuildControlKey(occupied, flag); bool flag2 = forceHunt || lastTickUsedPull || flag || text != lastControlKey || IslandDirtyFor(occupied); bool flag3 = forceHunt || lastTickUsedPull || flag || text != lastControlKey; forceHunt = false; DateTime utcNow = DateTime.UtcNow; if (flag2 && !flag3 && utcNow < nextHuntAt) { lastTickUsedPull = false; skip = 2; backoff = (int)Math.Ceiling((nextHuntAt - utcNow).TotalSeconds); if (backoff < 0) { backoff = 0; } yield break; } hunt = flag2; skip = ((!hunt) ? 1 : 0); if (!hunt) { lastTickUsedPull = false; yield break; } lastControlKey = text; ClearDirtyFor(occupied); BeginLendTickCaches(occupied); if (Core.TerritoryService != null) { Core.TerritoryService.StartTimer(); } for (int j = 0; j < order.Count; j++) { int plot = order[(start + j) % order.Count]; plotPullsLeft = 12; IEnumerator lend = LendToPlot(plot, occupied); while (true) { bool flag4; try { flag4 = lend.MoveNext(); } catch (Exception e) { Core.LogException(e, "Tick"); break; } if (!flag4) { break; } yield return lend.Current; } if (plotPullsLeft < 12) { continue; } IEnumerator sort = SelfSortPlot(plot); while (true) { bool flag5; try { flag5 = sort.MoveNext(); } catch (Exception e2) { Core.LogException(e2, "Tick"); break; } if (!flag5) { break; } yield return sort.Current; } if (TimeToYield()) { yield return null; Core.TerritoryService.StartTimer(); } } usedPulls = 120 - lendPullsLeft; lastTickUsedPull = usedPulls > 0; } finally { if (hunt) { EndLendTickCaches(); } int num = (int)(DateTime.UtcNow - tickAt).TotalMilliseconds; if (hunt) { float list = HuntWaitSeconds(num); nextHuntAt = DateTime.UtcNow.AddSeconds(list); if (list > 5f) { backoff = (int)Math.Ceiling(list); } } DestDebugLog.Perf("lend", occupiedCount, usedPulls, num, (Core.WorkQueue != null) ? Core.WorkQueue.QueueDepth : 0, connectedPlayers, skip, backoff); tickBusy = false; } } private static bool EmptyHoldExpired() { if (destEmptyHoldUntil.Count == 0) { return false; } DateTime utcNow = DateTime.UtcNow; foreach (DateTime value in destEmptyHoldUntil.Values) { if (utcNow >= value) { return true; } } return false; } private static bool IslandDirtyFor(HashSet occupied) { if (islandDirty.Count == 0) { return false; } foreach (int item in occupied) { if (islandDirty.Contains(item)) { return true; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(item); if (logisticsTerritoryIds == null) { continue; } for (int i = 0; i < logisticsTerritoryIds.Count; i++) { if (islandDirty.Contains(logisticsTerritoryIds[i])) { return true; } } } return false; } private static void ClearDirtyFor(HashSet occupied) { foreach (int item in occupied) { islandDirty.Remove(item); IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(item); if (logisticsTerritoryIds != null) { for (int i = 0; i < logisticsTerritoryIds.Count; i++) { islandDirty.Remove(logisticsTerritoryIds[i]); } } } } private static string BuildControlKey(HashSet occupied, bool emptyHoldDue) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected I4, but got Unknown StringBuilder stringBuilder = new StringBuilder(128); stringBuilder.Append('s').Append(settingsEpoch).Append('|'); stringBuilder.Append('o').Append(occupied.Count).Append('|'); stringBuilder.Append('b').Append((occupied.Count <= 1) ? 1 : 0).Append('|'); stringBuilder.Append('h').Append(emptyHoldDue ? 1 : 0).Append('|'); stringBuilder.Append('u').Append(leftAt.Count).Append('|'); List list = new List(occupied); list.Sort(); for (int i = 0; i < list.Count; i++) { int num = list[i]; stringBuilder.Append(num).Append(':'); Entity castleHeart = Core.TerritoryService.GetCastleHeart(num); if (castleHeart != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { CastleHeart val = castleHeart.Read(); stringBuilder.Append('L').Append(val.Level); stringBuilder.Append('R').Append((int)val.ActiveEvent); } } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(num, out var platformId); stringBuilder.Append('F').Append(Core.PlayerSettings.IsHeartFeedEnabled(platformId, num) ? 1 : 0); GetDestInventories(num, out var destMode); stringBuilder.Append((destMode == "treasury") ? 'T' : 'A'); IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (logisticsTerritoryIds != null) { stringBuilder.Append('i'); for (int j = 0; j < logisticsTerritoryIds.Count; j++) { stringBuilder.Append(logisticsTerritoryIds[j]).Append(','); } } stringBuilder.Append(';'); } return stringBuilder.ToString(); } private static void CheckStickyRetain(HashSet occupied) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) if (pendingVerify.Count == 0) { return; } List list = new List(pendingVerify); pendingVerify.Clear(); foreach (long item in list) { if (stickyFailed.Contains(item)) { continue; } int num = (int)(item >> 32); int num2 = (int)(item & 0xFFFFFFFFu); if (!occupied.Contains(num)) { continue; } string destMode; List destInventories = GetDestInventories(num, out destMode); if (destInventories.Count != 0 && CountIn(destInventories, new PrefabGUID(num2)) <= 0 && (!(destMode == "allShared") || !IsStarterKitGuid(num2))) { MarkStickyFail(num, item, destMode); int num3 = 0; string value = ""; if (lastMove.TryGetValue(item, out var value2)) { value = value2.Source.ToString(); num3 = ReverseToSource(destInventories, value2.Source, new PrefabGUID(num2), value2.Amount); } Core.Log.LogWarning((object)($"[ClanTreasuryLend] FAIL sticky destPlot={num} guid={num2} local=0 next-tick after move dest={destMode} lastFrom={value} reversed={num3} -- stop this boot" + ((destMode == "allShared") ? " (skip entire allShared dest plot this boot)" : ""))); DestDebugLog.Dupe("lend", num, new PrefabGUID(num2), num3, $"sticky local=0 dest={destMode} lastFrom={value} reversed={num3}"); } } } private static HashSet CollectOccupiedClanSharePlots(out int connectedPlayers) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) connectedPlayers = 0; HashSet hashSet = new HashSet(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has()) { continue; } User val6 = val5.Read(); if (!val6.IsConnected) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val6.LocalCharacter)).GetEntityOnServer(); if (entityOnServer == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entityOnServer) || !entityOnServer.Has()) { continue; } connectedPlayers++; int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(entityOnServer); if (standingTerritoryId < 0) { continue; } Entity castleHeart = Core.TerritoryService.GetCastleHeart(standingTerritoryId); if (ClanTreasuryShare.ShouldShare(castleHeart)) { if (!Core.TerritoryService.IsSameClanAsHeart(entityOnServer, castleHeart)) { DestDebugLog.Guest(standingTerritoryId, val6.PlatformId, "not-clan"); } else { hashSet.Add(standingTerritoryId); } } } return hashSet; } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } private unsafe static IEnumerator LendToPlot(int destPlot, HashSet occupiedAll) { Entity heart = Core.TerritoryService.GetCastleHeart(destPlot); if (heart == Entity.Null || !ClanTreasuryShare.ShouldShare(heart)) { yield break; } IReadOnlyList clanIds = Core.TerritoryService.GetLogisticsTerritoryIds(destPlot); if (clanIds == null || clanIds.Count <= 1) { yield break; } HashSet occupiedInClan = new HashSet(); foreach (int item in clanIds) { if (occupiedAll.Contains(item)) { occupiedInClan.Add(item); } } if (occupiedInClan.Count == 0) { yield break; } bool flag = default(bool); if (IsRaided(heart)) { if (loggedDestMode.Add(destPlot)) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] skip destPlot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" raided ActiveEvent="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(heart.Read().ActiveEvent); } log.LogInfo(val); } yield break; } HandleHeartFuel(destPlot, heart, clanIds, occupiedInClan); if (TimeToYield()) { yield return null; Core.TerritoryService.StartTimer(); } List destInvs = GetDestInventories(destPlot, out var destMode); NoteDestEmpties(destPlot, destInvs); if (destInvs.Count == 0) { if (warnedNoDest.Add(destPlot)) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(77, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] no dest chest plot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -- kit/upgrade skipped, fuel seed only"); } log2.LogWarning(val2); } yield break; } destInvs = FilterEmptyHold(destPlot, destInvs); if (destInvs.Count == 0) { yield break; } if (destMode == "allShared" && stickyFailedAllSharedPlots.Contains(destPlot)) { if (loggedAllSharedPlotSkip.Add(destPlot)) { ManualLogSource log3 = Core.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(110, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] skip destPlot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" dest=allShared sticky-fail this boot -- kit GUIDs vanished, no further dumps"); } log3.LogWarning(val2); } yield break; } Dictionary upgrade = GetHeartUpgradeCosts(destPlot, heart); if (loggedDestMode.Add(destPlot)) { ManualLogSource log4 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(430, 12, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] dest plot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" mode="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destMode); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" invs="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destInvs.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" occupiedInClan="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(occupiedInClan.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (upgrade=yes; kit="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted((destMode == "allShared") ? "spend-refill until treasury, never overflow if other dest exists" : "first-fill plank/brick/gemdust/copper/iron/stone if dest has none, then covering"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; covering=kit mats first then hungriest unlocked blueprint per mat, 3x (1x if reserve-tight); leftover-bypass plank="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(72); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("+stack copper="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(24); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("+stack iron="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(24); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("+stack gemdust="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(32); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("+stack brick="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(456); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("+stack stone="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(192); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("+stack; remaining plank="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(216); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" honor leftover; named last-resort kit/upgrade/covering; dest=never-NS seeded-s# generic exact category overflow custom-last; self-sort same-plot)"); } log4.LogInfo(val); foreach (Entity item2 in StashesOnPlot(destPlot)) { if (!item2.Has() && !StashRouting.IsNoShare(item2)) { string text = StashRouting.RawName(item2); object obj; if (!item2.Has()) { obj = "no-ws"; } else { CastleWorkstation val3 = item2.Read(); obj = ((object)(*(CastleFloorTypes*)(&val3.MatchingFloorType))/*cast due to .constrained prefix*/).ToString(); } string text2 = (string)obj; ManualLogSource log5 = Core.Log; val = new BepInExInfoLogInterpolatedStringHandler(93, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] dest-chest plot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" name=\""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" treasuryLinked="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ClanTreasuryShare.IsTreasuryLinked(item2)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" matchingFloor="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" unnamed="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(StashRouting.IsUnnamedOrGeneric(text)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" overflow="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(StashRouting.IsOverflowDestName(text)); } log5.LogInfo(val); } } } List list = VanillaVisibleDests(destPlot, destInvs); if (list.Count == 0) { list = NonOverflowDests(destPlot, destInvs); } if (destMode == "allShared") { List list2 = FirstUsableKitDest(destPlot, list); if (list2.Count > 0) { string[] array = KitChestKeys(destPlot, list2[0]); bool num = AnyHeartKey(array, Core.PlayerSettings.IsStarterKitChestOptOut); bool flag2 = AnyHeartKey(array, Core.PlayerSettings.IsStarterKitChestSeeded); bool flag3 = DestHasAnyKit(list); string text3 = ((array.Length != 0) ? array[0] : "no-net"); if (num) { if (loggedFirstSuccess.Add(FailKey(destPlot, -1017402979) ^ 6)) { ManualLogSource log6 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(101, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" kit skip consumed chest="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (manual empty opt-out) -- no refill, unbuild ok"); } log6.LogInfo(val); } } else if (flag2 && !flag3) { Core.PlayerSettings.SetStarterKitChestOptOut(optedOut: true, array); if (loggedFirstSuccess.Add(FailKey(destPlot, -1017402979) ^ 7)) { ManualLogSource log7 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(110, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" kit empty after seeded chest="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -- opt-out (manual empty; 5s tick will not restuff)"); } log7.LogInfo(val); } } else { int num2 = LendStarterKitOnce(destPlot, list, clanIds, occupiedInClan, destMode); if ((DestHasAnyKit(list) || num2 > 0) && array.Length != 0) { Core.PlayerSettings.MarkStarterKitChestSeeded(array); } if (num2 > 0 && loggedFirstSuccess.Add(FailKey(destPlot, -1017402979) ^ (flag2 ? 3 : 2))) { string text4 = (flag2 ? "spend-refill" : "first-fill"); ManualLogSource log8 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" kit "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text4); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" moved="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" chest="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text3); } log8.LogInfo(val); } else if (array.Length == 0 && loggedFirstSuccess.Add(FailKey(destPlot, -1017402979) ^ 5)) { ManualLogSource log9 = Core.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(104, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" kit dest chest has no NetworkId -- fill/top-off without empty-opt-out latch"); } log9.LogWarning(val2); } } } } else if (!PlotHasAllKitTypes(destPlot) && list.Count > 0) { int num3 = LendStarterKitOnce(destPlot, list, clanIds, occupiedInClan, destMode); if (num3 > 0 && loggedFirstSuccess.Add(FailKey(destPlot, -1017402979) ^ 0x11)) { ManualLogSource log10 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(97, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" treasury first-fill kit moved="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (plank/brick/gemdust before covering)"); } log10.LogInfo(val); } } List parkInvs = VanillaVisibleDests(destPlot, destInvs); if (parkInvs.Count == 0) { parkInvs = NonOverflowDests(destPlot, destInvs); } Dictionary buildCovering1x = GetBuildCovering1x(destPlot); Dictionary covering3 = ScaleCovering(buildCovering1x, 3); if (buildCovering1x.Count > 0 && loggedCovering.Add(destPlot)) { buildCovering1x.TryGetValue(-1017402979, out var value); buildCovering1x.TryGetValue(-1237019921, out var value2); buildCovering1x.TryGetValue(271594022, out var value3); buildCovering1x.TryGetValue(862477668, out var value4); ManualLogSource log11 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(135, 9, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" build-covering mats="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(buildCovering1x.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" copies="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" park="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(parkInvs.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destInvs.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" plank1x="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" copper1x="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" be1x="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value4); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" gbe1x="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (1x leftover-bypass, 3x honor reserve)"); } log11.LogInfo(val); } bool bypass1x = occupiedInClan == null || occupiedInClan.Count <= 1; if (parkInvs.Count > 0) { depositMaxClass = 3; try { IEnumerator cover1 = LendTargetAmounts(destPlot, parkInvs, buildCovering1x, clanIds, occupiedInClan, destMode, bypass1x, stockOnPlot: true); while (cover1.MoveNext()) { yield return cover1.Current; } } finally { depositMaxClass = 5; } } if (upgrade != null) { IEnumerator cover1 = LendTargetAmounts(destPlot, destInvs, upgrade, clanIds, occupiedInClan, destMode, bypass1x); while (cover1.MoveNext()) { yield return cover1.Current; } } if (parkInvs.Count <= 0) { yield break; } depositMaxClass = 3; try { IEnumerator cover1 = LendTargetAmounts(destPlot, parkInvs, covering3, clanIds, occupiedInClan, destMode, ignoreLeftoverNamed: false, stockOnPlot: true); while (cover1.MoveNext()) { yield return cover1.Current; } } finally { depositMaxClass = 5; } } private static List> OrderedCoveringTargets(int destPlot, Dictionary targets, bool stockOnPlot) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) List> list = new List>(); if (targets == null || targets.Count == 0) { return list; } int[] kitOrder = new int[7] { -1017402979, 1788016417, 820932258, -1237019921, -1750550553, -1531666018, 862477668 }; HashSet hashSet = new HashSet(kitOrder); List> list2 = new List>(); List> list3 = new List>(); List> list4 = new List>(); List> list5 = new List>(); foreach (KeyValuePair target in targets) { if (target.Key == 0 || target.Value <= 0) { continue; } int num = 0; if (stockOnPlot && destPlot >= 0) { num = CountVanillaOnPlot(destPlot, new PrefabGUID(target.Key)); } bool flag = num <= 0; if (hashSet.Contains(target.Key)) { if (flag) { list2.Add(target); } else if (num < target.Value) { list3.Add(target); } } else if (flag) { list4.Add(target); } else if (num < target.Value) { list5.Add(target); } } list2.Sort((KeyValuePair a, KeyValuePair b) => Array.IndexOf(kitOrder, a.Key).CompareTo(Array.IndexOf(kitOrder, b.Key))); list3.Sort((KeyValuePair a, KeyValuePair b) => Array.IndexOf(kitOrder, a.Key).CompareTo(Array.IndexOf(kitOrder, b.Key))); if (destPlot >= 0 && !PlotHasAllKitTypes(destPlot)) { list.AddRange(list2); list.AddRange(list3); RotateAppend(list, list4, destPlot); RotateAppend(list, list5, destPlot); } else { list.AddRange(list2); RotateAppend(list, list4, destPlot); list.AddRange(list3); RotateAppend(list, list5, destPlot); } return list; } private static void RotateAppend(List> dest, List> rest, int plot) { if (rest.Count != 0) { rest.Sort((KeyValuePair a, KeyValuePair b) => a.Key.CompareTo(b.Key)); coverCursor.TryGetValue(plot, out var value); int num = (value % rest.Count + rest.Count) % rest.Count; coverCursor[plot] = value + 1; for (int num2 = 0; num2 < rest.Count; num2++) { dest.Add(rest[(num + num2) % rest.Count]); } } } private static IEnumerator LendTargetAmounts(int destPlot, List destInvs, Dictionary targets, IReadOnlyList clanIds, HashSet occupiedInClan, string destMode, bool ignoreLeftoverNamed, bool stockOnPlot = false) { if (targets == null || targets.Count == 0 || !CanLendPull()) { yield break; } bool destFull = false; PrefabGUID val = default(PrefabGUID); bool flag = default(bool); foreach (KeyValuePair item2 in OrderedCoveringTargets(destPlot, targets, stockOnPlot)) { if (!CanLendPull()) { yield break; } int key = item2.Key; int value = item2.Value; if (key == 0 || value <= 0) { continue; } long item = FailKey(destPlot, key); if (stickyFailed.Contains(item)) { continue; } ((PrefabGUID)(ref val))..ctor(key); List list = DestInvsForUpgradeItem(destPlot, val, destInvs); if (list.Count == 0) { if (!IsTreasuryRejectedBlood(val)) { continue; } DestDebugLog.Miss(stockOnPlot ? "covering" : "upgrade", destPlot, val, 0, value, "no-blood-dest dest=" + destMode); if (loggedFirstSuccess.Add(FailKey(destPlot, key) ^ 0xB)) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(87, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(key); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" blood dest skipped -- no Blood/Alchemy/generic chest"); } log.LogWarning(val2); } continue; } int num = (stockOnPlot ? CountVanillaOnPlot(destPlot, val) : CountIn(list, val)); if (num >= value || (destFull && num == 0)) { continue; } if (num == 0 && !DestHasRoomFor(list, val)) { destFull = true; DestDebugLog.Miss(stockOnPlot ? "covering" : "upgrade", destPlot, val, num, value, "dest-full dest=" + destMode); continue; } int num2 = value - num; if (num2 <= 0) { continue; } ConsumeLendPull(); bool fail = false; int leftoverBlocked = 0; int leftoverHave = 0; int leftoverReserve = 0; int num3 = PullFromSources(destPlot, list, val, num2, value, clanIds, occupiedInClan, destMode, occupiedSpareOnly: false, allowNamed: true, allowSamePlot: false, ledgerMoves: true, ignoreLeftoverNamed, ref fail, ref leftoverBlocked, ref leftoverHave, ref leftoverReserve); if (!fail) { int num4 = (stockOnPlot ? CountVanillaOnPlot(destPlot, val) : CountIn(list, val)); num2 = value - num4; if (num2 > 0) { num3 += PullFromSources(destPlot, list, val, num2, value, clanIds, occupiedInClan, destMode, occupiedSpareOnly: true, allowNamed: true, allowSamePlot: false, ledgerMoves: true, ignoreLeftoverNamed, ref fail, ref leftoverBlocked, ref leftoverHave, ref leftoverReserve); } } if (num3 <= 0) { string via = (stockOnPlot ? "covering" : "upgrade"); if (leftoverBlocked > 0) { DestDebugLog.Miss(via, destPlot, val, leftoverHave, value, "leftover-blocked leftover=" + leftoverReserve); } else if (!fail) { DestDebugLog.Miss(via, destPlot, val, num, value, "no-source dest=" + destMode); } } if (num3 <= 0 && num == 0 && !DestHasRoomFor(list, val)) { destFull = true; } if (num3 > 0) { pendingVerify.Add(item); } if (TimeToYield()) { yield return null; Core.TerritoryService.StartTimer(); } } } private static void EnsureBlueprintCostCache() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) if (blueprintCosts != null) { return; } blueprintCosts = new List<(int, bool, List<(int, int)>)>(); try { EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)3); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || val5.Has()) { continue; } BlueprintData val6 = val5.Read(); int guidHash = ((PrefabGUID)(ref val6.Guid)).GuidHash; if (guidHash == 0 && val5.Has()) { PrefabGUID val7 = val5.Read(); guidHash = ((PrefabGUID)(ref val7)).GuidHash; } if (guidHash == 0 || !val5.Has()) { continue; } DynamicBuffer val8 = val5.ReadBuffer(); List<(int, int)> list = new List<(int, int)>(); for (int j = 0; j < val8.Length; j++) { BlueprintRequirementBuffer val9 = val8[j]; if (val9.Amount > 0 && ((PrefabGUID)(ref val9.PrefabGUID)).GuidHash != 0) { list.Add((((PrefabGUID)(ref val9.PrefabGUID)).GuidHash, val9.Amount)); } } if (list.Count != 0) { blueprintCosts.Add((guidHash, val6.IsStartBlueprint, list)); } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val10 = new BepInExInfoLogInterpolatedStringHandler(89, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val10).AppendLiteral("[ClanTreasuryLend] covering-cost cache castleBlueprints="); ((BepInExLogInterpolatedStringHandler)val10).AppendFormatted(blueprintCosts.Count); ((BepInExLogInterpolatedStringHandler)val10).AppendLiteral(" (station recipes added per plot)"); } log.LogInfo(val10); } catch (Exception e) { Core.LogException(e, "EnsureBlueprintCostCache"); if (blueprintCosts.Count == 0) { blueprintCosts = new List<(int, bool, List<(int, int)>)>(); } } } private static HashSet CollectUnlocksOnPlot(int plot) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) if (tickUnlocks != null && tickUnlocks.TryGetValue(plot, out var value)) { return value; } HashSet hashSet = new HashSet(); try { Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has()) { continue; } User val6 = val5.Read(); if (!val6.IsConnected) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val6.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has() && Core.TerritoryService.GetStandingTerritoryId(entityOnServer) == plot && Core.TerritoryService.IsSameClanAsHeart(entityOnServer, castleHeart)) { AddUnlockedBlueprints(val5, hashSet); } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } catch (Exception e) { Core.LogException(e, "CollectUnlocksOnPlot"); } return hashSet; } private static void AddUnlockedBlueprints(Entity userEntity, HashSet unlocked) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (!ProgressionUtility.TryGetProgressionEntity(Core.EntityManager, userEntity, ref val) || val == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val)) { return; } if (val.Has()) { DynamicBuffer val2 = val.ReadBuffer(); for (int i = 0; i < val2.Length; i++) { UnlockedBlueprintElement val3 = val2[i]; int guidHash = ((PrefabGUID)(ref val3.UnlockedBlueprint)).GuidHash; if (guidHash != 0) { unlocked.Add(guidHash); } } } if (!val.Has()) { return; } DynamicBuffer val4 = val.ReadBuffer(); Entity val5 = default(Entity); for (int j = 0; j < val4.Length; j++) { PrefabGUID unlockedPrefab = val4[j].UnlockedPrefab; if (((PrefabGUID)(ref unlockedPrefab)).GuidHash == 0) { continue; } unlocked.Add(((PrefabGUID)(ref unlockedPrefab)).GuidHash); try { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(unlockedPrefab, ref val5) || !(val5 != Entity.Null)) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has()) { continue; } DynamicBuffer val6 = val5.ReadBuffer(); for (int k = 0; k < val6.Length; k++) { TechUnlockBlueprintBuffer val7 = val6[k]; int guidHash2 = ((PrefabGUID)(ref val7.Guid)).GuidHash; if (guidHash2 != 0) { unlocked.Add(guidHash2); } } } catch { } } } private static float BuildCostMod() { try { float buildCostModifier = Core.ServerGameSettingsSystem.Settings.BuildCostModifier; if (buildCostModifier < 0f) { return 0f; } return buildCostModifier; } catch { return 1f; } } private static int ApplyBuildCost(int amount, float mod) { if (amount <= 0 || mod <= 0f) { return 0; } if (Math.Abs(mod - 1f) < 0.0001f) { return amount; } int num = (int)Math.Ceiling((double)amount * (double)mod); if (num >= 1) { return num; } return 1; } private static Dictionary GetCovering1x(int destPlot) { if (destPlot >= 0 && coveringCache.TryGetValue(destPlot, out (DateTime, Dictionary) value) && (DateTime.UtcNow - value.Item1).TotalSeconds < 5.0 && value.Item2 != null) { return new Dictionary(value.Item2); } EnsureBlueprintCostCache(); float num = BuildCostMod(); if (num <= 0f || blueprintCosts == null) { return new Dictionary(); } HashSet hashSet = ((destPlot >= 0) ? CollectUnlocksOnPlot(destPlot) : new HashSet()); Dictionary dictionary = new Dictionary(); foreach (var blueprintCost in blueprintCosts) { if (hashSet.Count == 0) { if (!blueprintCost.start) { continue; } } else if (!hashSet.Contains(blueprintCost.blueprint) && !blueprintCost.start) { continue; } MergeCosts(dictionary, blueprintCost.costs, num); } if (destPlot >= 0) { AddPlotStationRecipeCosts(destPlot, dictionary, num); } if (dictionary.Count > 0) { List list = new List(dictionary.Keys); for (int i = 0; i < list.Count; i++) { int num2 = list[i]; if (num2 != 862477668) { dictionary[num2] = CapCovering1x(dictionary[num2]); } } } ApplyChestBloodEssenceFloor(dictionary); if (destPlot >= 0) { if (coveringCache.Count > 160) { coveringCache.Clear(); } coveringCache[destPlot] = (DateTime.UtcNow, dictionary); } return new Dictionary(dictionary); } internal static int CapCovering1x(int amount) { if (amount <= 0) { return 0; } if (amount <= 200) { return amount; } return 200; } private static void ApplyChestBloodEssenceFloor(Dictionary max) { if (max != null) { max.TryGetValue(862477668, out var value); if (value < 500) { max[862477668] = 500; } } } private static void MergeCosts(Dictionary max, List<(int guid, int amount)> costs, float mod) { if (costs == null) { return; } foreach (var cost in costs) { int item = cost.guid; int num = ApplyBuildCost(cost.amount, mod); if (num > 0 && (!max.TryGetValue(item, out var value) || num > value)) { max[item] = num; } } } private static void AddRecipeGuidCosts(PrefabGUID recipeGuid, Dictionary max, float mod) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (((PrefabGUID)(ref recipeGuid)).GuidHash == 0 || !Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(recipeGuid, ref val) || val == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val) || (val.Has() && val.Read().HideInStation) || !val.Has()) { return; } DynamicBuffer val2 = val.ReadBuffer(); List<(int, int)> list = new List<(int, int)>(); int num = 0; for (int i = 0; i < val2.Length; i++) { RecipeRequirementBuffer val3 = val2[i]; if (val3.Amount <= 0 || ((PrefabGUID)(ref val3.Guid)).GuidHash == 0) { continue; } string loc = StashRouting.ItemLabel(val3.Guid); if (ItemGroupService.IsFishOrFeedPlaceholder("", loc)) { if (val3.Amount > num) { num = val3.Amount; } } else if (ItemGroupService.IsMachineSpendItem(((PrefabGUID)(ref val3.Guid)).GuidHash)) { list.Add((((PrefabGUID)(ref val3.Guid)).GuidHash, val3.Amount)); } } MergeCosts(max, list, mod); if (num > 0) { AddFishSpend(max, mod, num); } } private static void AddFishSpend(Dictionary max, float mod, int amount) { if (amount <= 0) { amount = 1; } IReadOnlyList builtInMembers = ItemGroupService.GetBuiltInMembers("fish"); List<(int, int)> list = new List<(int, int)>(); for (int i = 0; i < builtInMembers.Count; i++) { if (builtInMembers[i].GuidHash != 0) { list.Add((builtInMembers[i].GuidHash, amount)); } } MergeCosts(max, list, mod); } private unsafe static bool StationIsPrison(Entity station) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!(station == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(station) && station.Has()) { CastleWorkstation val = station.Read(); return ((object)(*(CastleFloorTypes*)(&val.MatchingFloorType))/*cast due to .constrained prefix*/).ToString().IndexOf("Prison", StringComparison.OrdinalIgnoreCase) >= 0; } } return false; } private static void AddPlotStationRecipeCosts(int plot, Dictionary max, float mod) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) bool flag = false; if (Core.RefinementStations != null) { foreach (Entity item in Core.RefinementStations.BenchesOnPlot(plot)) { if (item.Has()) { continue; } if (StationIsPrison(item)) { flag = true; } if (!item.Has()) { continue; } DynamicBuffer val = item.ReadBuffer(); for (int i = 0; i < val.Length; i++) { if (val[i].Unlocked && !val[i].Disabled) { AddRecipeGuidCosts(val[i].RecipeGuid, max, mod); } } } } if (!workstationsByPlot.ContainsKey(plot)) { SeedWorkstationsOnPlot(plot); } if (workstationsByPlot.TryGetValue(plot, out var value)) { for (int num = value.Count - 1; num >= 0; num--) { Entity val2 = value[num]; if (!(val2 == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val2)) { if (val2.Has()) { continue; } if (StationIsPrison(val2)) { flag = true; } if (val2.Has() && !val2.Has()) { DynamicBuffer val3 = val2.ReadBuffer(); for (int j = 0; j < val3.Length; j++) { AddRecipeGuidCosts(val3[j].RecipeGuid, max, mod); } } continue; } } value.RemoveAt(num); } } if (flag) { AddFishSpend(max, mod, 1); } } private static void SeedWorkstationsOnPlot(int plot) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) List list = new List(); workstationsByPlot[plot] = list; EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (!(val5 == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val5) && Core.TerritoryService.GetTerritoryId(val5) == plot) { list.Add(val5); } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } private static int CountClanTakeable(int destPlot, PrefabGUID type, IReadOnlyList clanIds) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) int num = 0; ServerGameManager serverGameManager = Core.ServerGameManager; if (clanIds == null) { return 0; } DynamicBuffer val = default(DynamicBuffer); foreach (int clanId in clanIds) { if (clanId == destPlot) { continue; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(clanId, out var platformId); int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, type); int num2 = 0; foreach (Entity item in StashesOnPlot(clanId)) { if (item.Has() || StashRouting.IsNoShare(item) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item, ref val)) { continue; } Enumerator enumerator3 = val.GetEnumerator(); while (enumerator3.MoveNext()) { Entity entity = enumerator3.Current.Entity; if (IsValidExternalInv(entity)) { num2 += ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(entity, type); } } } if (pullReserve > 0) { num2 -= pullReserve; } if (num2 > 0) { num += num2; } } return num; } private static Dictionary GetBuildCovering1x(int destPlot) { try { return GetCovering1x(destPlot) ?? new Dictionary(); } catch (Exception e) { Core.LogException(e, "GetBuildCovering1x"); return new Dictionary(); } } private static Dictionary ScaleCovering(Dictionary one, int copies) { Dictionary dictionary = new Dictionary(); if (one == null) { return dictionary; } foreach (KeyValuePair item in one) { if (item.Key != 0 && item.Value > 0) { dictionary[item.Key] = ((item.Key == 862477668) ? item.Value : (item.Value * copies)); } } return dictionary; } private static int PullFromSources(int destPlot, List destInvs, PrefabGUID type, int need, int destTarget, IReadOnlyList clanIds, HashSet occupiedInClan, string destMode, bool occupiedSpareOnly, bool allowNamed, bool allowSamePlot, bool ledgerMoves, ref bool fail) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) int leftoverBlocked = 0; int leftoverHave = 0; int leftoverReserve = 0; return PullFromSources(destPlot, destInvs, type, need, destTarget, clanIds, occupiedInClan, destMode, occupiedSpareOnly, allowNamed, allowSamePlot, ledgerMoves, ignoreLeftoverNamed: false, ref fail, ref leftoverBlocked, ref leftoverHave, ref leftoverReserve); } private static int PullFromSources(int destPlot, List destInvs, PrefabGUID type, int need, int destTarget, IReadOnlyList clanIds, HashSet occupiedInClan, string destMode, bool occupiedSpareOnly, bool allowNamed, bool allowSamePlot, bool ledgerMoves, bool ignoreLeftoverNamed, ref bool fail, ref int leftoverBlocked, ref int leftoverHave, ref int leftoverReserve) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_06a8: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Expected O, but got Unknown //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_0605: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_07d3: Unknown result type (might be due to invalid IL or missing references) //IL_07da: Expected O, but got Unknown //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_0735: Expected O, but got Unknown //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Expected O, but got Unknown //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) if ((need <= 0) | fail) { return 0; } int num = 0; ServerGameManager serverGameManager = Core.ServerGameManager; long num2 = FailKey(destPlot, ((PrefabGUID)(ref type)).GuidHash); Dictionary dictionary = new Dictionary(); if (occupiedSpareOnly) { foreach (int item in occupiedInClan) { if (item != destPlot || allowSamePlot) { int num3 = ChestTargetForPlot(item, ((PrefabGUID)(ref type)).GuidHash); if (num3 < 0) { num3 = 0; } dictionary[item] = CountVanillaOnPlot(item, type) - num3; } } } DynamicBuffer val = default(DynamicBuffer); bool flag4 = default(bool); for (int i = 0; i < 3; i++) { if (need <= 0) { break; } if (fail) { break; } if (i > 0 && !allowNamed) { continue; } foreach (int clanId in clanIds) { if ((need <= 0) | fail) { break; } if (clanId == destPlot && !allowSamePlot) { continue; } bool flag = occupiedInClan?.Contains(clanId) ?? false; bool flag2 = ignoreLeftoverNamed && i == 2 && allowNamed; if (occupiedSpareOnly) { if (!flag || (!flag2 && (!dictionary.TryGetValue(clanId, out var value) || value <= 0))) { continue; } } else if (flag && !flag2) { continue; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(clanId, out var platformId); foreach (Entity item2 in StashesOnPlot(clanId)) { if ((need <= 0) | fail) { break; } if (item2.Has() || StashRouting.IsNoShare(item2)) { continue; } int num4 = StashRouting.SourcePass(item2); if (num4 < 0 || num4 != i || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item2, ref val)) { continue; } Enumerator enumerator4 = val.GetEnumerator(); while (enumerator4.MoveNext()) { AttachedBuffer current4 = enumerator4.Current; if ((need <= 0) | fail) { break; } Entity entity = current4.Entity; if (entity == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entity) || !entity.Has()) { continue; } PrefabGUID val2 = entity.Read(); if (!((PrefabGUID)(ref val2)).Equals(StashService.ChestBagGuid) || IsDest(destInvs, entity)) { continue; } if (occupiedSpareOnly && !(ignoreLeftoverNamed && i == 2 && allowNamed)) { List list = GetTreasuryInventories(clanId); if (list.Count == 0) { list = GetAllSharedInventories(clanId); } if (!IsDest(list, entity)) { continue; } } int inventoryItemCount = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(entity, type); if (inventoryItemCount <= 0) { continue; } int num5 = inventoryItemCount; int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, type); bool flag3 = ignoreLeftoverNamed && i == 2 && allowNamed; if (pullReserve > 0 && !ignoreLeftoverNamed) { num5 -= pullReserve; } if (num5 <= 0) { if (pullReserve > 0 && inventoryItemCount > 0) { leftoverBlocked++; leftoverHave = inventoryItemCount; leftoverReserve = pullReserve; } continue; } int num6 = ((num5 < need) ? num5 : need); if (occupiedSpareOnly && !flag3) { if (!dictionary.TryGetValue(clanId, out var value2) || value2 <= 0) { continue; } if (num6 > value2) { num6 = value2; } } if (num6 <= 0) { continue; } int inventoryItemCount2 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(entity, type); bool destRejected; int num7 = MoveIntoDest(destPlot, entity, destInvs, type, num6, destMode, out destRejected); int inventoryItemCount3 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(entity, type); if (num7 > 0 && inventoryItemCount3 >= inventoryItemCount2) { fail = true; MarkStickyFail(destPlot, num2, destMode); int num8 = 0; foreach (Entity destInv in destInvs) { if (destInv == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(destInv)) { continue; } int inventoryItemCount4 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(destInv, type); int num9 = ((inventoryItemCount4 < num7) ? inventoryItemCount4 : num7); if (num9 > 0) { if (((ServerGameManager)(ref serverGameManager)).TryRemoveInventoryItem(destInv, type, num9)) { num8 += num9; } if (num8 >= num7) { break; } } } ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(122, 8, ref flag4); if (flag4) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] FAIL copy destPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((PrefabGUID)(ref type)).GuidHash); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" movedReported="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num7); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" fromPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(clanId); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" dest="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destMode); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" src="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Identify(item2, entity, clanId)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" srcAfter="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(inventoryItemCount3); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" reversedDest="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num8); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" -- stop this boot"); } log.LogWarning(val3); DestDebugLog.Dupe("lend", destPlot, type, num7, $"copy-fail fromPlot={clanId} srcAfter={inventoryItemCount3} reversed={num8} dest={destMode}"); return num; } if (num7 <= 0) { if (!destRejected) { continue; } fail = true; MarkStickyFail(destPlot, num2, destMode); ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(114, 6, ref flag4); if (flag4) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] FAIL dest-rejected destPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((PrefabGUID)(ref type)).GuidHash); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" take="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num6); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" fromPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(clanId); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" dest="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destMode); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" src="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(Identify(item2, entity, clanId)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" -- stop this boot (will not hold)"); } log2.LogWarning(val3); DestDebugLog.Dupe("lend", destPlot, type, num6, $"dest-rejected fromPlot={clanId} dest={destMode}"); return num; } need -= num7; num += num7; InvalidateTickPlotCounts(destPlot); InvalidateTickPlotCounts(clanId); if (occupiedSpareOnly) { dictionary[clanId] -= num7; } SourceChest sourceChest = Identify(item2, entity, clanId); if (ledgerMoves) { CreditLedger(destPlot, ((PrefabGUID)(ref type)).GuidHash, sourceChest, num7); lastMove[num2] = new LastMove { Source = sourceChest, Amount = num7 }; } DestDebugLog.Move("lend", destPlot, type, num7, item2, Entity.Null, destMode, 0, "stays"); if (i == 2 && loggedNamedBorrow.Add(num2)) { ManualLogSource log3 = Core.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(127, 5, ref flag4); if (flag4) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[ClanTreasuryLend] named-chest borrow destPlot="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((PrefabGUID)(ref type)).GuidHash); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" moved="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num7); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" from="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(sourceChest); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" dest="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(destMode); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (treasury/unnamed exhausted; return to this NetworkId)"); } log3.LogInfo(val4); } if (loggedFirstSuccess.Add(num2)) { ManualLogSource log4 = Core.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(107, 5, ref flag4); if (flag4) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[ClanTreasuryLend] lend destPlot="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((PrefabGUID)(ref type)).GuidHash); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" moved="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num7); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" from="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(sourceChest); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" dest="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(destMode); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (first-success; further stacks this guid silent)"); } log4.LogInfo(val4); } } } } } return num; } private static int MoveIntoDest(int destPlot, Entity source, List destInvs, PrefabGUID type, int amount, string destMode, out bool destRejected) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) destRejected = false; if (amount <= 0) { return 0; } int num = amount; int num2 = 0; bool flag = false; ServerGameManager serverGameManager = Core.ServerGameManager; EntityManager entityManager; if (destMode == "heartFuel") { foreach (Entity destInv in destInvs) { Entity current = destInv; if (num <= 0) { break; } if (current == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(current) && !((Entity)(ref current)).Equals(source)) { flag = true; int num3 = Utilities.TransferItems(serverGameManager, source, current, type, num); if (num3 > 0) { num -= num3; num2 += num3; } } } if (flag && num2 == 0) { destRejected = true; } return num2; } List list = StashRouting.OrderDepositInventories(destPlot, destInvs, type, depositMaxClass); if (destInvs != null) { for (int i = 0; i < destInvs.Count; i++) { Entity val = destInvs[i]; if (val == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val) || InventoryIsOverflow(destPlot, val)) { continue; } bool flag2 = false; for (int j = 0; j < list.Count; j++) { Entity val2 = list[j]; if (((Entity)(ref val2)).Equals(val)) { flag2 = true; break; } } if (flag2) { continue; } Entity val3 = StashForInventory(destPlot, val); if (!(val3 == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val3)) { string text = StashRouting.RawName(val3); if (!StashRouting.IsConveyorName(text) && (string.IsNullOrWhiteSpace(text) || StashRouting.IsUnnamedOrGeneric(text))) { list.Add(val); } continue; } } list.Add(val); } } if (list.Count == 0 && destInvs != null && destInvs.Count > 0 && loggedFirstSuccess.Add(FailKey(destPlot, ((PrefabGUID)(ref type)).GuidHash) ^ 0x15)) { ManualLogSource log = Core.Log; bool flag3 = default(bool); BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(73, 3, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((PrefabGUID)(ref type)).GuidHash); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" no-ranked-dest park="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(destInvs.Count); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" -- fallback empty"); } log.LogInfo(val4); DestDebugLog.Miss("lend", destPlot, type, 0, amount, "no-ranked-dest park=" + destInvs.Count); } foreach (Entity item in list) { Entity current2 = item; if (num <= 0) { break; } if (current2 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(current2) || ((Entity)(ref current2)).Equals(source)) { continue; } flag = true; int num4 = Utilities.TransferItems(serverGameManager, source, current2, type, num); if (num4 <= 0) { continue; } num -= num4; num2 += num4; foreach (Entity item2 in StashesOnPlot(destPlot)) { if (StashRouting.TryGetExternalInventory(item2, out var inventory) && ((Entity)(ref inventory)).Equals(current2)) { StashRouting.LogDestPick(StashRouting.RankDeposit(item2, type, 0uL, hasItem: true).Label, destPlot, type, StashRouting.RawName(item2), "lend-dest"); break; } } } if (flag && num2 == 0) { destRejected = DestHasRoomFor(destInvs, type); } return num2; } private static void CreditLedger(int destPlot, int guid, SourceChest source, int amount) { LedgerKey key = new LedgerKey { DestPlot = destPlot, Guid = guid, Source = source }; if (ledger.TryGetValue(key, out var value)) { ledger[key] = value + amount; } else { ledger[key] = amount; } } private static SourceChest Identify(Entity stash, Entity inventory, int territoryId) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) SourceChest result = new SourceChest { TerritoryId = territoryId, HasNet = false, InvIndex = inventory.Index, InvVersion = inventory.Version }; if (stash != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash) && stash.Has()) { result.NetId = stash.Read(); result.HasNet = true; } } return result; } private static Entity ResolveSourceInventory(SourceChest src) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) Entity val = new Entity { Index = src.InvIndex, Version = src.InvVersion }; if (IsValidExternalInv(val)) { return val; } if (src.HasNet) { foreach (Entity item in StashesOnPlot(src.TerritoryId)) { if (item.Has() || !item.Has()) { continue; } NetworkId val2 = item.Read(); if (((NetworkId)(ref val2)).Equals(src.NetId)) { Entity val3 = FirstExternalInv(item); if (val3 != Entity.Null) { return val3; } } } } return Entity.Null; } private static List OtherChestsOnSourcePlot(int territoryId, Entity except) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) List list = new List(); ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); foreach (Entity item in StashesOnPlot(territoryId)) { if (item.Has() || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item, ref val)) { continue; } Enumerator enumerator2 = val.GetEnumerator(); while (enumerator2.MoveNext()) { Entity entity = enumerator2.Current.Entity; if (IsValidExternalInv(entity) && (!(except != Entity.Null) || !((Entity)(ref entity)).Equals(except))) { list.Add(entity); } } } return list; } private static void ReturnAllLedgers(string reason) { HashSet hashSet = new HashSet(); foreach (KeyValuePair item in ledger) { hashSet.Add(item.Key.DestPlot); } foreach (int item2 in hashSet) { ReturnPlot(item2, reason); } } private static void ReturnPlot(int destPlot, string reason) { //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (KeyValuePair item in ledger) { if (item.Key.DestPlot == destPlot && item.Value > 0) { list.Add(item.Key); } } if (list.Count == 0) { ClearPlotState(destPlot); return; } string destMode; List destInventories = GetDestInventories(destPlot, out destMode); int num = 0; int num2 = 0; Dictionary> dictionary = new Dictionary>(); foreach (LedgerKey item2 in list) { if (!dictionary.TryGetValue(item2.Guid, out var value)) { value = new List(); dictionary[item2.Guid] = value; } value.Add(item2); } PrefabGUID val = default(PrefabGUID); foreach (KeyValuePair> item3 in dictionary) { ((PrefabGUID)(ref val))..ctor(item3.Key); int num3 = CountIn(destInventories, val); foreach (LedgerKey item4 in item3.Value) { if (!ledger.TryGetValue(item4, out var value2) || value2 <= 0) { continue; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(item4.Source.TerritoryId, out var platformId); int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, val); int num4 = CountVanillaOnPlot(item4.Source.TerritoryId, val); if (num4 >= pullReserve) { ledger.Remove(item4); continue; } int num5 = pullReserve - num4; if (num5 > value2) { num5 = value2; } if (num5 > num3) { num5 = num3; } int num6 = 0; if (num5 > 0) { Entity val2 = ResolveSourceInventory(item4.Source); if (val2 != Entity.Null) { num6 = MoveFromDestTo(destInventories, val2, val, num5); } if (num6 < num5) { foreach (Entity item5 in OtherChestsOnSourcePlot(item4.Source.TerritoryId, val2)) { if (num6 >= num5) { break; } num6 += MoveFromDestTo(destInventories, item5, val, num5 - num6); } } } num3 -= num6; num += num6; num2 += num5 - num6; ledger.Remove(item4); } } ClearPlotState(destPlot); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(72, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] return destPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" reason="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" returned="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" leftover="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" entries="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(list.Count); } log.LogInfo(val3); } private static void ClearPlotState(int destPlot) { List list = new List(); foreach (long item in pendingVerify) { if ((int)(item >> 32) == destPlot) { list.Add(item); } } foreach (long item2 in list) { pendingVerify.Remove(item2); } List list2 = new List(); foreach (KeyValuePair item3 in lastMove) { if ((int)(item3.Key >> 32) == destPlot) { list2.Add(item3.Key); } } foreach (long item4 in list2) { lastMove.Remove(item4); } } private static int ReverseToSource(List destInvs, SourceChest source, PrefabGUID type, int amount) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (amount <= 0) { return 0; } Entity val = ResolveSourceInventory(source); int num = 0; if (val != Entity.Null) { num = MoveFromDestTo(destInvs, val, type, amount); } if (num < amount) { foreach (Entity item in OtherChestsOnSourcePlot(source.TerritoryId, val)) { if (num >= amount) { break; } num += MoveFromDestTo(destInvs, item, type, amount - num); } } return num; } private static int MoveFromDestTo(List destInvs, Entity target, PrefabGUID type, int amount) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if (amount > 0 && !(target == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(target)) { int num = amount; int num2 = 0; ServerGameManager serverGameManager = Core.ServerGameManager; foreach (Entity destInv in destInvs) { Entity current = destInv; if (num <= 0) { break; } if (current == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(current) || ((Entity)(ref current)).Equals(target)) { continue; } int inventoryItemCount = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(current, type); if (inventoryItemCount > 0) { int transferAmount = ((inventoryItemCount < num) ? inventoryItemCount : num); int num3 = Utilities.TransferItems(serverGameManager, current, target, type, transferAmount); if (num3 > 0) { num -= num3; num2 += num3; } } } return num2; } } return 0; } private unsafe static string[] HeartFuelKeys(Entity heart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (heart != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(heart) && heart.Has()) { NetworkId val = heart.Read(); return new string[1] { "n" + ((object)(*(NetworkId*)(&val))/*cast due to .constrained prefix*/).ToString() }; } } return Array.Empty(); } private unsafe static string[] KitChestKeys(int destPlot, Entity inventory) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (!(inventory == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inventory)) { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); foreach (Entity item in StashesOnPlot(destPlot)) { if (item.Has() || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item, ref val)) { continue; } bool flag = false; for (int i = 0; i < val.Length; i++) { AttachedBuffer val2 = val[i]; if (((Entity)(ref val2.Entity)).Equals(inventory)) { flag = true; break; } } if (flag) { if (item.Has()) { NetworkId val3 = item.Read(); return new string[1] { "n" + ((object)(*(NetworkId*)(&val3))/*cast due to .constrained prefix*/).ToString() }; } break; } } return Array.Empty(); } } return Array.Empty(); } private static bool AnyHeartKey(string[] keys, Func pred) { if (keys == null) { return false; } for (int i = 0; i < keys.Length; i++) { if (pred(keys[i])) { return true; } } return false; } private static bool IsBloodEssenceName(string name) { if (string.IsNullOrEmpty(name)) { return false; } string text = name.Replace("Item_Ingredient_", "").Replace("_", " "); if (text.IndexOf("Greater", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } if (text.IndexOf("Primal", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } if (text.IndexOf("Ancestral", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } if (text.IndexOf("Blood Essence", StringComparison.OrdinalIgnoreCase) < 0) { return text.IndexOf("BloodEssence", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static PrefabGUID BloodEssenceType() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new PrefabGUID(862477668); } private static List GetHeartFuelInventories(Entity heart) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (!(heart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(heart)) { ServerGameManager serverGameManager = Core.ServerGameManager; PrefabGUID val = BloodEssenceType(); try { DynamicBuffer val2 = default(DynamicBuffer); if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(heart, ref val2)) { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { InventoryInstanceElement current = enumerator.Current; PrefabGUID restrictedType = current.RestrictedType; bool flag = ((PrefabGUID)(ref restrictedType)).GuidHash == 862477668 || ((PrefabGUID)(ref restrictedType)).Equals(val); if (!flag && ((PrefabGUID)(ref restrictedType)).GuidHash != 0) { string text = restrictedType.LookupName(); if (string.IsNullOrEmpty(text)) { text = ClanTreasuryShare.PrefabName(((PrefabGUID)(ref restrictedType)).GuidHash); } flag = IsBloodEssenceName(text); } if (flag) { NetworkedEntity externalInventoryEntity = current.ExternalInventoryEntity; consider(((NetworkedEntity)(ref externalInventoryEntity)).GetEntityOnServer()); } } } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag2 = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(55, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] InventoryInstanceElement fuel scan: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log.LogWarning(val3); } if (list.Count == 0) { try { DynamicBuffer val4 = default(DynamicBuffer); if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(heart, ref val4)) { Enumerator enumerator2 = val4.GetEnumerator(); while (enumerator2.MoveNext()) { Entity entity = enumerator2.Current.Entity; if (entity == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity) && entity.Has()) { PrefabGUID val5 = entity.Read(); if (!((PrefabGUID)(ref val5)).Equals(StashService.ChestBagGuid) && (((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(entity, val) > 0 || IsValidExternalInv(entity) || entity.Has())) { consider(entity); } } } } } catch { } } Entity inv = default(Entity); if (list.Count == 0 && InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, heart, ref inv, 0)) { consider(inv); } return list; } } return list; void consider(Entity val6) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (!(val6 == Entity.Null)) { EntityManager entityManager2 = Core.EntityManager; if (((EntityManager)(ref entityManager2)).Exists(val6)) { for (int i = 0; i < list.Count; i++) { Entity val7 = list[i]; if (((Entity)(ref val7)).Equals(val6)) { return; } } list.Add(val6); } } } } private static int CountHeartFuel(List fuelInvs, Entity heart) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int num = CountIn(fuelInvs, BloodEssenceType()); if (num <= 0) { return 0; } return num; } private static int UnlockedFuelSlotCount(Entity heart, Entity fuelInv, int bufferLength) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = 0; try { if (heart != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(heart) && heart.Has()) { CastleHeart val = heart.Read(); num2 = val.Level; try { ref CastleHeartLevelBlobData levelData = ref ((CastleHeart)(ref val)).GetLevelData(num2); if (levelData.ItemSlots > 0) { num = levelData.ItemSlots; } } catch { } if (num <= 0) { try { ref CastleHeartLevelBlobData levelData2 = ref ((CastleHeart)(ref val)).GetLevelData(); if (levelData2.ItemSlots > 0) { num = levelData2.ItemSlots; } } catch { } } if (num2 > 0 && num < num2) { num = num2; } } } } catch { } if (num <= 0) { try { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val2 = default(DynamicBuffer); if (heart != Entity.Null && ((ServerGameManager)(ref serverGameManager)).TryGetBuffer(heart, ref val2)) { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { InventoryInstanceElement current = enumerator.Current; NetworkedEntity externalInventoryEntity = current.ExternalInventoryEntity; Entity entityOnServer = ((NetworkedEntity)(ref externalInventoryEntity)).GetEntityOnServer(); if (((Entity)(ref entityOnServer)).Equals(fuelInv) && current.Slots > num) { num = current.Slots; } } } } catch { } } if (num <= 0) { num = bufferLength; } if (bufferLength > 0 && num > bufferLength) { num = bufferLength; } if (num < 0) { num = 0; } return num; } private static int HeartFuelNeed(Entity heart, List fuelInvs) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) int num = CountHeartFuel(fuelInvs, heart); int num2 = HeartFuelTopOffNeed(heart, fuelInvs); if (num <= 0 || num2 <= 0) { num2 += HeartFuelEmptySlotNeed(heart, fuelInvs); } return num2; } private static int HeartFuelTopOffNeed(Entity heart, List fuelInvs) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = BloodEssenceType(); int num = 0; ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val2 = default(DynamicBuffer); foreach (Entity fuelInv in fuelInvs) { if (fuelInv == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(fuelInv) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(fuelInv, ref val2)) { continue; } int num2 = UnlockedFuelSlotCount(heart, fuelInv, val2.Length); for (int i = 0; i < num2 && i < val2.Length; i++) { InventoryBuffer val3 = val2[i]; if (((PrefabGUID)(ref val3.ItemType)).Equals(val) && val3.Amount > 0) { int num3 = 500; if (val3.MaxAmountOverride > 0 && val3.MaxAmountOverride < num3) { num3 = val3.MaxAmountOverride; } if (val3.Amount < num3) { num += num3 - val3.Amount; } } } } return num; } private static int HeartFuelEmptySlotNeed(Entity heart, List fuelInvs) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) BloodEssenceType(); int num = 0; ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); foreach (Entity fuelInv in fuelInvs) { if (fuelInv == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(fuelInv) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(fuelInv, ref val)) { continue; } int num2 = UnlockedFuelSlotCount(heart, fuelInv, val.Length); for (int i = 0; i < num2 && i < val.Length; i++) { InventoryBuffer val2 = val[i]; if (((PrefabGUID)(ref val2.ItemType)).GuidHash == 0 || val2.Amount <= 0) { int num3 = 500; if (val2.MaxAmountOverride > 0 && val2.MaxAmountOverride < num3) { num3 = val2.MaxAmountOverride; } if (num3 > 0) { num += num3; } } } } if (num > 500) { num = 500; } return num; } private static void HandleHeartFuel(int destPlot, Entity heart, IReadOnlyList clanIds, HashSet occupiedInClan) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Expected O, but got Unknown //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Expected O, but got Unknown string[] array = HeartFuelKeys(heart); bool flag = default(bool); if (array.Length == 0) { if (loggedHeartFuel.Add(destPlot)) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(77, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" heart has no NetworkId -- skip fuel seed/opt-out"); } log.LogWarning(val); } DestDebugLog.Miss("heart", destPlot, BloodEssenceType(), 0, 500, "no-heart-net"); return; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(destPlot, out var platformId); bool flag2 = Core.PlayerSettings.IsHeartFeedEnabled(platformId, destPlot); bool flag3 = AnyHeartKey(array, Core.PlayerSettings.IsHeartFuelSeeded); bool flag4 = AnyHeartKey(array, Core.PlayerSettings.IsHeartFuelOptOut); List heartFuelInventories = GetHeartFuelInventories(heart); if (heartFuelInventories.Count == 0) { if (loggedHeartFuel.Add(destPlot)) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(83, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" no heart fuel inventory (RestrictedType Blood Essence)"); } log2.LogWarning(val); } DestDebugLog.Miss("heart", destPlot, BloodEssenceType(), 0, 500, "no-fuel-inv"); return; } int num = CountHeartFuel(heartFuelInventories, heart); PrefabGUID val2 = BloodEssenceType(); string destMode = "heartFuel"; bool ignoreLeftoverNamed = occupiedInClan == null || occupiedInClan.Count <= 1; if (flag2 && flag4) { Core.PlayerSettings.SetHeartFuelOptOut(optedOut: false, array); flag4 = false; if (loggedHeartFuel.Add(destPlot + 100000)) { ManualLogSource log3 = Core.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(66, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" heart fuel opt-out cleared (.s hf ON)"); } log3.LogInfo(val3); } } if (!flag2) { if (flag4) { return; } if (flag3 && num <= 0) { Core.PlayerSettings.SetHeartFuelOptOut(optedOut: true, array); if (loggedHeartFuel.Add(destPlot + 200000)) { ManualLogSource log4 = Core.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(96, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" heart emptied after seed -- opted-out until .s hf ON or they add BE"); } log4.LogInfo(val3); } return; } if (flag3 || num > 0) { return; } } int num2 = HeartFuelNeed(heart, heartFuelInventories); if (num2 <= 0) { if (!loggedHeartFuel.Add(destPlot + 400000)) { return; } int num3 = 0; ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val4 = default(DynamicBuffer); for (int i = 0; i < heartFuelInventories.Count; i++) { if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(heartFuelInventories[i], ref val4)) { num3 = UnlockedFuelSlotCount(heart, heartFuelInventories[i], val4.Length); break; } } ManualLogSource log5 = Core.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(85, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" heart fuel need=0 fuel="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" topOff="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(HeartFuelTopOffNeed(heart, heartFuelInventories)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" empty="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(HeartFuelEmptySlotNeed(heart, heartFuelInventories)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" unlocked="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" feedOn="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(flag2); } log5.LogInfo(val3); DestDebugLog.Miss("heart", destPlot, val2, num, 0, "no-need unlocked=" + num3 + " feedOn=" + flag2); } else { if (!CanLendPull()) { return; } ConsumeLendPull(); bool fail = false; int leftoverBlocked = 0; int leftoverHave = 0; int leftoverReserve = 0; int num4 = PullFromSources(destPlot, heartFuelInventories, val2, num2, 500, clanIds, occupiedInClan, destMode, occupiedSpareOnly: false, allowNamed: true, allowSamePlot: true, ledgerMoves: false, ignoreLeftoverNamed, ref fail, ref leftoverBlocked, ref leftoverHave, ref leftoverReserve); if (!fail) { int num5 = HeartFuelNeed(heart, heartFuelInventories); if (num5 > 0) { num4 += PullFromSources(destPlot, heartFuelInventories, val2, num5, 500, clanIds, occupiedInClan, destMode, occupiedSpareOnly: true, allowNamed: true, allowSamePlot: true, ledgerMoves: false, ignoreLeftoverNamed, ref fail, ref leftoverBlocked, ref leftoverHave, ref leftoverReserve); } } if (num4 > 0) { Core.PlayerSettings.MarkHeartFuelSeeded(array); DestDebugLog.Move("heart", destPlot, val2, num4, Entity.Null, heart, "heartFuel", leftoverReserve, "stays"); if (loggedFirstSuccess.Add(FailKey(destPlot, 862477668))) { ManualLogSource log6 = Core.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(54, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" heart fuel moved="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num4); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" feedOn="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(flag2); } log6.LogInfo(val3); } return; } DestDebugLog.Miss("heart", destPlot, val2, leftoverHave, num2, (fail ? "dest-rejected-or-copy-fail" : ((leftoverBlocked > 0) ? ("leftover-blocked leftover=" + leftoverReserve) : "no-source")) + " feedOn=" + flag2); if (loggedHeartFuel.Add(destPlot + 300000)) { ManualLogSource log7 = Core.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(95, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryLend] destPlot="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(destPlot); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" heart fuel moved=0 leftover-blocked="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(leftoverBlocked); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" leftover="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(leftoverReserve); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" have="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(leftoverHave); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" fail="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(fail); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" feedOn="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(flag2); } log7.LogInfo(val3); } } } private static bool IsDest(List destInvs, Entity inventory) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < destInvs.Count; i++) { Entity val = destInvs[i]; if (((Entity)(ref val)).Equals(inventory)) { return true; } } return false; } private static bool IsValidExternalInv(Entity inventory) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (!(inventory == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inventory)) { if (!inventory.Has()) { return false; } PrefabGUID val = inventory.Read(); return ((PrefabGUID)(ref val)).Equals(StashService.ChestBagGuid); } } return false; } private static Entity FirstExternalInv(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(stash, ref val)) { return Entity.Null; } Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity entity = enumerator.Current.Entity; if (IsValidExternalInv(entity)) { return entity; } } return Entity.Null; } private static int CountVanillaOnPlot(int plot, PrefabGUID type) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (tickVanillaCounts != null && tickVanillaCounts.TryGetValue(plot, out var value) && value.TryGetValue(((PrefabGUID)(ref type)).GuidHash, out var value2)) { return value2; } List list = GetTreasuryInventories(plot); if (list.Count == 0) { list = GetAllSharedInventories(plot); } int num = CountIn(list, type); if (tickVanillaCounts != null) { if (!tickVanillaCounts.TryGetValue(plot, out value) || value == null) { value = new Dictionary(); tickVanillaCounts[plot] = value; } value[((PrefabGUID)(ref type)).GuidHash] = num; } return num; } private static int CountIn(List invs, PrefabGUID type) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) int num = 0; ServerGameManager serverGameManager = Core.ServerGameManager; if (invs == null) { return 0; } for (int i = 0; i < invs.Count; i++) { Entity val = invs[i]; if (!(val == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val)) { num += ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(val, type); } } } return num; } private static IEnumerator SelfSortPlot(int plot) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); if (castleHeart == Entity.Null || IsRaided(castleHeart)) { yield break; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(plot, out var ownerId); GetDestInventories(plot, out var destMode); bool flag = destMode == "allShared"; ServerGameManager sgm = Core.ServerGameManager; List<(Entity stash, Entity inv)> chests = new List<(Entity, Entity)>(); foreach (Entity item5 in StashesOnPlot(plot)) { if (!item5.Has() && !StashRouting.IsNoShare(item5) && StashRouting.TryGetExternalInventory(item5, out var inventory)) { chests.Add((item5, inventory)); } } if (chests.Count < 2) { yield break; } List list = new List(); HashSet hashSet = new HashSet(); DynamicBuffer val = default(DynamicBuffer); foreach (var item6 in chests) { Entity item = item6.inv; if (!((ServerGameManager)(ref sgm)).TryGetBuffer(item, ref val)) { continue; } for (int i = 0; i < val.Length; i++) { PrefabGUID itemType = val[i].ItemType; if (((PrefabGUID)(ref itemType)).GuidHash != 0 && (!flag || !IsStarterKitGuid(((PrefabGUID)(ref itemType)).GuidHash)) && hashSet.Add(((PrefabGUID)(ref itemType)).GuidHash)) { list.Add(itemType); } } } if (list.Count == 0) { yield break; } int moves = 0; DynamicBuffer val4 = default(DynamicBuffer); bool flag4 = default(bool); foreach (PrefabGUID item7 in list) { PrefabGUID current2 = item7; if (moves >= 24) { break; } int pullReserve = Core.PlayerSettings.GetPullReserve(ownerId, current2); List<(Entity, Entity, StashRouting.SortRank)> list2 = new List<(Entity, Entity, StashRouting.SortRank)>(); bool flag2 = false; foreach (var item8 in chests) { Entity item2 = item8.stash; Entity item3 = item8.inv; bool hasItem = StashRouting.InventoryHasItem(item3, current2); StashRouting.SortRank item4 = StashRouting.RankSort(item2, current2, ownerId, hasItem); list2.Add((item2, item3, item4)); if (item4.UsableDest) { flag2 = true; } } if (!flag2) { continue; } list2.Sort(((Entity stash, Entity inv, StashRouting.SortRank rank) a, (Entity stash, Entity inv, StashRouting.SortRank rank) b) => a.rank.CompareTo(b.rank)); foreach (var (val2, val3, source) in list2) { if (moves >= 24) { break; } if (!source.UsableSource) { continue; } int inventoryItemCount = ((ServerGameManager)(ref sgm)).GetInventoryItemCount(val3, current2); if (inventoryItemCount <= 0) { continue; } int num = inventoryItemCount - pullReserve; if (num <= 0) { continue; } bool flag3 = false; if (((ServerGameManager)(ref sgm)).TryGetBuffer(val3, ref val4)) { for (int num2 = 0; num2 < val4.Length; num2++) { InventoryBuffer val5 = val4[num2]; if (((PrefabGUID)(ref val5.ItemType)).Equals(current2)) { val5 = val4[num2]; Entity entityOnServer = ((NetworkedEntity)(ref val5.ItemEntity)).GetEntityOnServer(); if (!((Entity)(ref entityOnServer)).Equals(Entity.Null)) { flag3 = true; break; } } } } foreach (var item9 in list2) { var (val6, val7, sortRank) = item9; if (moves >= 24 || num <= 0) { break; } if (((Entity)(ref val7)).Equals(val3) || InEmptyHold(plot, val7) || !sortRank.StrictlyBetterDestThan(source) || StashRouting.IsOverflowDestName(StashRouting.RawName(val6)) || StashRouting.IsConveyorName(StashRouting.RawName(val2))) { continue; } int inventoryItemCount2 = ((ServerGameManager)(ref sgm)).GetInventoryItemCount(val3, current2); int amountTransferred; if (flag3) { int startInputSlot = 0; Utilities.TransferItemEntities(val3, val7, current2, num, ref startInputSlot, out amountTransferred); } else { amountTransferred = Utilities.TransferItems(sgm, val3, val7, current2, num); } int inventoryItemCount3 = ((ServerGameManager)(ref sgm)).GetInventoryItemCount(val3, current2); if (amountTransferred > 0 && inventoryItemCount3 >= inventoryItemCount2) { int inventoryItemCount4 = ((ServerGameManager)(ref sgm)).GetInventoryItemCount(val7, current2); int num3 = ((inventoryItemCount4 < amountTransferred) ? inventoryItemCount4 : amountTransferred); if (num3 > 0) { ((ServerGameManager)(ref sgm)).TryRemoveInventoryItem(val7, current2, num3); } ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val8 = new BepInExWarningLogInterpolatedStringHandler(56, 3, ref flag4); if (flag4) { ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("[Satisvampory] self-sort copy-fail plot="); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted(plot); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(" guid="); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted(((PrefabGUID)(ref current2)).GuidHash); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(" reversed="); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted(num3); } log.LogWarning(val8); DestDebugLog.Dupe("self-sort", plot, current2, amountTransferred, "copy-fail reversed=" + num3); } else if (amountTransferred > 0) { num -= amountTransferred; moves++; StashRouting.LogDestPick(sortRank.Label, plot, current2, StashRouting.RawName(val6), "self-sort"); DestDebugLog.Move("self-sort", plot, current2, amountTransferred, val2, val6, sortRank.Label, pullReserve, "stays"); } } } if (TimeToYield()) { yield return null; Core.TerritoryService.StartTimer(); } } if (moves > 0) { ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val9 = new BepInExInfoLogInterpolatedStringHandler(51, 3, ref flag4); if (flag4) { ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[ClanTreasuryLend] self-sort plot="); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(plot); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" moves="); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(moves); ((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" destMode="); ((BepInExLogInterpolatedStringHandler)val9).AppendFormatted(destMode); } log2.LogInfo(val9); } } private static List GetDestInventories(int territoryId, out string destMode) { List treasuryInventories = GetTreasuryInventories(territoryId); if (treasuryInventories.Count > 0) { destMode = "treasury"; return treasuryInventories; } destMode = "allShared"; return GetAllSharedInventories(territoryId); } private static List GetTreasuryInventories(int territoryId) { if (tickCachesOn && tickTreasuryInvs != null && tickTreasuryInvs.TryGetValue(territoryId, out var value)) { return value; } List list = new List(); AddPlotInventories(territoryId, list, treasuryOnly: true); if (tickCachesOn && tickTreasuryInvs != null) { tickTreasuryInvs[territoryId] = list; } return list; } private static List GetAllSharedInventories(int territoryId) { if (tickCachesOn && tickAllSharedInvs != null && tickAllSharedInvs.TryGetValue(territoryId, out var value)) { return value; } List list = new List(); AddPlotInventories(territoryId, list, treasuryOnly: false); if (tickCachesOn && tickAllSharedInvs != null) { tickAllSharedInvs[territoryId] = list; } return list; } private static List StashesOnPlot(int territoryId) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (tickCachesOn && tickStashes != null && tickStashes.TryGetValue(territoryId, out var value)) { return value; } List list = new List(); foreach (Entity item in Core.Stash.ChestsOnPlot(territoryId)) { list.Add(item); } if (tickCachesOn && tickStashes != null) { tickStashes[territoryId] = list; } return list; } private static void AddPlotInventories(int territoryId, List list, bool treasuryOnly) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); foreach (Entity item2 in StashesOnPlot(territoryId)) { if (item2.Has() || item2.Has()) { continue; } PrefabGUID item; if (StashRouting.IsNoShare(item2)) { string label = StashRouting.SkipLabel(StashRouting.RawName(item2)); item = default(PrefabGUID); StashRouting.LogDestPick(label, territoryId, item, StashRouting.RawName(item2), "dest-filter"); } else { if ((treasuryOnly && !ClanTreasuryShare.IsTreasuryLinked(item2)) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item2, ref val)) { continue; } Enumerator enumerator2 = val.GetEnumerator(); while (enumerator2.MoveNext()) { Entity entity = enumerator2.Current.Entity; if (entity == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity) && entity.Has()) { item = entity.Read(); if (((PrefabGUID)(ref item)).Equals(StashService.ChestBagGuid)) { list.Add(entity); } } } } } } } internal static class ClanTreasuryShare { private struct PlotCountCache { public DateTime At; public Dictionary Counts; } [ThreadStatic] private static bool suppress; internal const int ReinforcedPlankHash = -1397591435; internal const int IronIngotHash = -1750550553; private static int _sharedLog; private static int _harvestLog; private static DateTime bagAvailAt; private static Entity bagAvailChar; private static readonly Dictionary bagAvail = new Dictionary(); private static readonly Dictionary buildAvail = new Dictionary(); private static DateTime buildAvailAt; private static Entity buildAvailHeart; private static Entity buildAvailChar; private static readonly Dictionary plotAvail = new Dictionary(); internal static bool Suppress { get { return suppress; } set { suppress = value; } } internal static int TerritoryIdFromHeart(Entity castleHeart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (!(castleHeart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { Entity castleTerritoryEntity = castleHeart.Read().CastleTerritoryEntity; if (!(castleTerritoryEntity == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleTerritoryEntity) && castleTerritoryEntity.Has()) { return castleTerritoryEntity.Read().CastleTerritoryIndex; } } return -1; } } return -1; } internal static Entity HeartFromTarget(Entity target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (!(target == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(target)) { if (target.Has()) { int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(target); if (standingTerritoryId >= 0) { return Core.TerritoryService.GetCastleHeart(standingTerritoryId); } return Entity.Null; } if (target.Has()) { CastleHeartConnection val = target.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.CastleHeartEntity)).GetEntityOnServer(); if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has()) { return entityOnServer; } } } int territoryId = Core.TerritoryService.GetTerritoryId(target); if (territoryId < 0) { return Entity.Null; } return Core.TerritoryService.GetCastleHeart(territoryId); } } return Entity.Null; } internal static bool ShouldShare(Entity standingHeart) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized || standingHeart == Entity.Null) { return false; } int num = TerritoryIdFromHeart(standingHeart); if (num < 0) { return false; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (logisticsTerritoryIds != null) { return logisticsTerritoryIds.Count > 1; } return false; } internal static bool IsTreasuryLinked(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Invalid comparison between Unknown and I4 if (!(stash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash)) { if (stash.Has() && (int)stash.Read().MatchingFloorType == 14) { return true; } if (!stash.Has()) { return false; } CastleRoomConnection val = stash.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.RoomEntity)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { if (Utilities.IsRoomOfType(entityOnServer, (CastleFloorTypes)14)) { return true; } if (!entityOnServer.Has()) { return false; } entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(entityOnServer, false); for (int i = 0; i < buffer.Length; i++) { CastleRoomFloorsBuffer val2 = buffer[i]; Entity entityOnServer2 = ((NetworkedEntity)(ref val2.FloorEntity)).GetEntityOnServer(); if (!(entityOnServer2 == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer2) && entityOnServer2.Has() && (int)entityOnServer2.Read().FloorType == 14) { return true; } } } return false; } } return false; } } return false; } internal static NativeArray CombineMerged(EntityManager entityManager, Entity standingHeart, Entity target, bool includeCurrentInteractingInventory, bool includeCastleSharedInventories) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) List> list = new List>(); try { NativeArray castleMergedInventoryDatas = MergedInventoriesUtility.GetCastleMergedInventoryDatas(entityManager, standingHeart, target, includeCurrentInteractingInventory, includeCastleSharedInventories); list.Add(castleMergedInventoryDatas); int num = TerritoryIdFromHeart(standingHeart); IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (logisticsTerritoryIds != null) { foreach (int item in logisticsTerritoryIds) { if (item != num) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(item); if (!(castleHeart == Entity.Null)) { NativeArray castleMergedInventoryDatas2 = MergedInventoriesUtility.GetCastleMergedInventoryDatas(entityManager, castleHeart, target, false, true); list.Add(castleMergedInventoryDatas2); } } } } int num2 = 0; foreach (NativeArray item2 in list) { if (item2.IsCreated) { num2 += item2.Length; } } NativeArray result = default(NativeArray); result..ctor(num2, (Allocator)2, (NativeArrayOptions)1); int num3 = 0; foreach (NativeArray item3 in list) { if (item3.IsCreated) { for (int i = 0; i < item3.Length; i++) { result[num3++] = item3[i]; } } } return result; } finally { foreach (NativeArray item4 in list) { if (item4.IsCreated) { item4.Dispose(); } } } } internal static void ConsumeRemainderFromClanDests(Entity standingHeart, PrefabGUID type, ref int remainder) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (remainder <= 0) { return; } int num = TerritoryIdFromHeart(standingHeart); if (num >= 0) { IReadOnlyList readOnlyList = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (readOnlyList == null || readOnlyList.Count == 0) { readOnlyList = new int[1] { num }; } ConsumeRemainderFromPlots(readOnlyList, num, type, standingFirst: true, ref remainder); } } internal static void ConsumeRemainderFromOtherTreasuries(Entity standingHeart, PrefabGUID type, ref int remainder) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) ConsumeRemainderFromClanDests(standingHeart, type, ref remainder); } private static void ConsumeRemainderFromPlots(IReadOnlyList ids, int standingId, PrefabGUID type, bool standingFirst, ref int remainder) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); for (int i = 0; i < 2; i++) { if (remainder <= 0) { break; } foreach (int id in ids) { if (remainder <= 0) { break; } bool flag = id == standingId; if (standingFirst) { if ((i == 0 && !flag) || (i == 1 && flag)) { continue; } } else if (flag) { continue; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(id, out var platformId); int num = ((!flag) ? Core.PlayerSettings.GetPullReserve(platformId, type) : 0); foreach (Entity item in Core.Stash.ChestsOnPlot(id)) { if (remainder <= 0) { break; } if (item.Has() || StashRouting.IsNoShare(item) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item, ref val)) { continue; } Enumerator enumerator3 = val.GetEnumerator(); while (enumerator3.MoveNext()) { AttachedBuffer current3 = enumerator3.Current; if (remainder <= 0) { break; } Entity entity = current3.Entity; if (!entity.Has()) { continue; } PrefabGUID val2 = entity.Read(); if (!((PrefabGUID)(ref val2)).Equals(StashService.ChestBagGuid)) { continue; } int num2 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(entity, type); if (num > 0) { num2 -= num; } if (num2 > 0) { int num3 = ((num2 < remainder) ? num2 : remainder); if (num3 > 0 && ((ServerGameManager)(ref serverGameManager)).TryRemoveInventoryItem(entity, type, num3)) { remainder -= num3; } } } } } } } private static int CountMergedAmount(NativeArray merged, PrefabGUID type) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) int num = 0; if (!merged.IsCreated) { return 0; } for (int i = 0; i < merged.Length; i++) { InventoryBuffer val = merged[i]; if (((PrefabGUID)(ref val.ItemType)).Equals(type)) { num += merged[i].Amount; } } return num; } internal static int CountSiblingTreasuryAvailable(Entity standingHeart, PrefabGUID type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) int num = TerritoryIdFromHeart(standingHeart); if (num < 0) { return 0; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (logisticsTerritoryIds == null || logisticsTerritoryIds.Count <= 1) { return 0; } int num2 = 0; ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); foreach (int item in logisticsTerritoryIds) { if (item == num) { continue; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(item, out var platformId); foreach (Entity item2 in Core.Stash.ChestsOnPlot(item)) { if (!IsTreasuryLinked(item2) || item2.Has() || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item2, ref val)) { continue; } Enumerator enumerator3 = val.GetEnumerator(); while (enumerator3.MoveNext()) { Entity entity = enumerator3.Current.Entity; if (!entity.Has()) { continue; } PrefabGUID val2 = entity.Read(); if (((PrefabGUID)(ref val2)).Equals(StashService.ChestBagGuid)) { int num3 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(entity, type); int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, type); if (pullReserve > 0) { num3 -= pullReserve; } if (num3 > 0) { num2 += num3; } } } } } return num2; } internal static Dictionary CountAllClanTreasuryAvailable(Entity standingHeart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return CountAllClanTreasuryAvailable(standingHeart, Entity.Null); } internal static Dictionary CountAllClanTreasuryAvailable(Entity standingHeart, Entity target) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); int num = TerritoryIdFromHeart(standingHeart); if (num < 0) { return dictionary; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (logisticsTerritoryIds == null || logisticsTerritoryIds.Count == 0) { return dictionary; } ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); DynamicBuffer val3 = default(DynamicBuffer); foreach (int item in logisticsTerritoryIds) { Core.TerritoryService.TryGetTerritoryOwnerPlatformId(item, out var platformId); foreach (Entity item2 in Core.Stash.ChestsOnPlot(item)) { if (!IsTreasuryLinked(item2) || item2.Has() || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item2, ref val)) { continue; } Enumerator enumerator3 = val.GetEnumerator(); while (enumerator3.MoveNext()) { Entity entity = enumerator3.Current.Entity; if (!entity.Has()) { continue; } PrefabGUID val2 = entity.Read(); if (!((PrefabGUID)(ref val2)).Equals(StashService.ChestBagGuid) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(entity, ref val3)) { continue; } HashSet hashSet = new HashSet(); for (int i = 0; i < val3.Length; i++) { PrefabGUID itemType = val3[i].ItemType; if (((PrefabGUID)(ref itemType)).GuidHash == 0 || !hashSet.Add(((PrefabGUID)(ref itemType)).GuidHash)) { continue; } int num2 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(entity, itemType); int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, itemType); if (pullReserve > 0) { num2 -= pullReserve; } if (num2 > 0) { if (dictionary.TryGetValue(((PrefabGUID)(ref itemType)).GuidHash, out var value)) { dictionary[((PrefabGUID)(ref itemType)).GuidHash] = value + num2; } else { dictionary[((PrefabGUID)(ref itemType)).GuidHash] = num2; } } } } } } MergeSharedCastleInventoryItems(logisticsTerritoryIds, dictionary); MergeVanillaMergedAvailable(standingHeart, target, dictionary); HarvestHeartAttachedInventories(logisticsTerritoryIds, dictionary); HarvestAllStashes(logisticsTerritoryIds, dictionary); UnionNameAliases(dictionary); return dictionary; } private static void MergeSharedCastleInventoryItems(IReadOnlyList ids, Dictionary totals) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (ids == null || ids.Count == 0 || totals == null) { return; } Dictionary dictionary = new Dictionary(); foreach (int id in ids) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(id); if (castleHeart == Entity.Null) { continue; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(id, out var platformId); Dictionary dictionary2 = new Dictionary(); CollectSharedCastleItems(castleHeart, dictionary2); foreach (KeyValuePair item in dictionary2) { int num = item.Value; int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, new PrefabGUID(item.Key)); if (pullReserve > 0) { num -= pullReserve; } if (num > 0) { if (dictionary.TryGetValue(item.Key, out var value)) { dictionary[item.Key] = value + num; } else { dictionary[item.Key] = num; } } } } foreach (KeyValuePair item2 in dictionary) { if (totals.TryGetValue(item2.Key, out var value2)) { if (item2.Value > value2) { totals[item2.Key] = item2.Value; } } else { totals[item2.Key] = item2.Value; } } } private static void CollectSharedCastleItems(Entity heart, Dictionary local) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown int num = 0; int num2 = 0; ServerGameManager serverGameManager; try { serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(heart, ref val)) { num = val.Length; for (int i = 0; i < val.Length; i++) { int num3 = num2; SharedCastleInventoryInstances val2 = val[i]; num2 = num3 + AddSharedItemBuffer(((NetworkedEntity)(ref val2.Entity)).GetEntityOnServer(), local); } } } catch (Exception ex) { if (_sharedLog < 4) { Core.Log.LogWarning((object)("[ClanTreasuryHUD] SharedCastleInventoryInstances: " + ex.Message)); } } try { num2 += AddSharedItemBuffer(heart, local); } catch { } try { serverGameManager = Core.ServerGameManager; DynamicBuffer val3 = default(DynamicBuffer); if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(heart, ref val3)) { for (int j = 0; j < val3.Length; j++) { Entity inventorySource = val3[j].InventorySource; if (!(inventorySource == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inventorySource)) { num2 += AddSharedItemBuffer(inventorySource, local); } } } } } catch (Exception ex2) { if (_sharedLog < 4) { Core.Log.LogWarning((object)("[ClanTreasuryHUD] SharedCastleInventories: " + ex2.Message)); } } if (_sharedLog >= 8) { return; } _sharedLog++; local.TryGetValue(-1750550553, out var value); local.TryGetValue(-1397591435, out var value2); int num4 = 0; foreach (KeyValuePair item in local) { if (IsIronName(PrefabName(item.Key))) { num4++; } } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(93, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[ClanTreasuryHUD] sharedHeart inst="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" added="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" keys="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(local.Count); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" ironCanonical="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" plankCanonical="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(value2); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" ironNameKeys="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num4); } log.LogInfo(val4); } private static int AddSharedItemBuffer(Entity e, Dictionary local) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!(e == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(e)) { int num = 0; ServerGameManager serverGameManager; try { serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(e, ref val)) { for (int i = 0; i < val.Length; i++) { PrefabGUID itemType = val[i].ItemType; int amount = val[i].Amount; if (((PrefabGUID)(ref itemType)).GuidHash != 0 && amount > 0) { if (local.TryGetValue(((PrefabGUID)(ref itemType)).GuidHash, out var value)) { local[((PrefabGUID)(ref itemType)).GuidHash] = value + amount; } else { local[((PrefabGUID)(ref itemType)).GuidHash] = amount; } num++; } } } } catch { } try { serverGameManager = Core.ServerGameManager; DynamicBuffer val2 = default(DynamicBuffer); if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(e, ref val2)) { for (int j = 0; j < val2.Length; j++) { PrefabGUID itemType2 = val2[j].ItemType; int amount2 = val2[j].Amount; if (((PrefabGUID)(ref itemType2)).GuidHash != 0 && amount2 > 0) { if (local.TryGetValue(((PrefabGUID)(ref itemType2)).GuidHash, out var value2)) { local[((PrefabGUID)(ref itemType2)).GuidHash] = value2 + amount2; } else { local[((PrefabGUID)(ref itemType2)).GuidHash] = amount2; } num++; } } } } catch { } return num; } } return 0; } internal static string DebugIronKeys(Dictionary totals) { if (totals == null || totals.Count == 0) { return "ironKeys=0"; } List list = new List(); foreach (KeyValuePair total in totals) { string text = PrefabName(total.Key); if (total.Key == -1750550553 || IsIronName(text)) { list.Add(total.Key + "=" + total.Value + ":" + (text ?? "?")); } } return "ironKeys=" + list.Count + ((list.Count == 0) ? "" : (" " + string.Join(",", list))); } private static void HarvestHeartAttachedInventories(IReadOnlyList ids, Dictionary totals) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown if (ids == null || totals == null) { return; } Dictionary dictionary = new Dictionary(); DynamicBuffer val = default(DynamicBuffer); foreach (int id in ids) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(id); if (castleHeart == Entity.Null) { continue; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(id, out var platformId); Dictionary dictionary2 = new Dictionary(); try { ServerGameManager serverGameManager = Core.ServerGameManager; if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(castleHeart, ref val)) { Enumerator enumerator2 = val.GetEnumerator(); while (enumerator2.MoveNext()) { AddSharedItemBuffer(enumerator2.Current.Entity, dictionary2); } } } catch { } AddSharedItemBuffer(castleHeart, dictionary2); foreach (KeyValuePair item in dictionary2) { int num = item.Value; int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, new PrefabGUID(item.Key)); if (pullReserve > 0) { num -= pullReserve; } if (num > 0) { if (dictionary.TryGetValue(item.Key, out var value)) { dictionary[item.Key] = value + num; } else { dictionary[item.Key] = num; } } } } MaxInto(totals, dictionary); if (_harvestLog >= 4) { return; } dictionary.TryGetValue(-1750550553, out var value2); int num2 = 0; int num3 = 0; foreach (KeyValuePair item2 in dictionary) { string name = PrefabName(item2.Key); if (item2.Key == -1750550553 || IsIronName(name)) { num2++; if (item2.Value > num3) { num3 = item2.Value; } } } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(73, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryHUD] heartAttached keys="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(dictionary.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ironCanonical="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(value2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ironNamed="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ironBest="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num3); } log.LogInfo(val2); } private static void HarvestAllStashes(IReadOnlyList ids, Dictionary totals) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (ids == null || totals == null) { return; } Dictionary dictionary = new Dictionary(); ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); foreach (int id in ids) { Core.TerritoryService.TryGetTerritoryOwnerPlatformId(id, out var _); foreach (Entity item in Core.Stash.ChestsOnPlot(id)) { if (!item.Has() && ((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item, ref val)) { Enumerator enumerator3 = val.GetEnumerator(); while (enumerator3.MoveNext()) { AddSharedItemBuffer(enumerator3.Current.Entity, dictionary); } AddSharedItemBuffer(item, dictionary); } } } int count = totals.Count; MaxInto(totals, dictionary); if (_harvestLog >= 4) { return; } _harvestLog++; int num = 0; int num2 = 0; foreach (KeyValuePair item2 in dictionary) { string name = PrefabName(item2.Key); if (item2.Key == -1750550553 || IsIronName(name)) { num2++; if (item2.Value > num) { num = item2.Value; } } } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(68, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ClanTreasuryHUD] allStash keys="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(dictionary.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ironNamed="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ironBest="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" totals="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(totals.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (was "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")"); } log.LogInfo(val2); } private static void MaxInto(Dictionary totals, Dictionary extra) { if (totals == null || extra == null) { return; } foreach (KeyValuePair item in extra) { if (item.Value <= 0) { continue; } if (totals.TryGetValue(item.Key, out var value)) { if (item.Value > value) { totals[item.Key] = item.Value; } } else { totals[item.Key] = item.Value; } } } private static void MergeVanillaMergedAvailable(Entity standingHeart, Entity target, Dictionary totals) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) int num = TerritoryIdFromHeart(standingHeart); if (num < 0) { return; } IReadOnlyList logisticsTerritoryIds = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (logisticsTerritoryIds == null || logisticsTerritoryIds.Count == 0) { return; } if (!(target == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(target)) { goto IL_0044; } } target = standingHeart; goto IL_0044; IL_0044: bool flag = Suppress; Suppress = true; try { Dictionary dictionary = new Dictionary(); foreach (int item in logisticsTerritoryIds) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(item); if (castleHeart == Entity.Null) { continue; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(item, out var platformId); NativeArray castleMergedInventoryDatas = MergedInventoriesUtility.GetCastleMergedInventoryDatas(Core.EntityManager, castleHeart, target, item == num, true); try { Dictionary dictionary2 = new Dictionary(); if (castleMergedInventoryDatas.IsCreated) { for (int i = 0; i < castleMergedInventoryDatas.Length; i++) { PrefabGUID itemType = castleMergedInventoryDatas[i].ItemType; if (((PrefabGUID)(ref itemType)).GuidHash != 0 && castleMergedInventoryDatas[i].Amount > 0) { if (dictionary2.TryGetValue(((PrefabGUID)(ref itemType)).GuidHash, out var value)) { dictionary2[((PrefabGUID)(ref itemType)).GuidHash] = value + castleMergedInventoryDatas[i].Amount; } else { dictionary2[((PrefabGUID)(ref itemType)).GuidHash] = castleMergedInventoryDatas[i].Amount; } } } } foreach (KeyValuePair item2 in dictionary2) { int num2 = item2.Value; int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, new PrefabGUID(item2.Key)); if (pullReserve > 0) { num2 -= pullReserve; } if (num2 > 0) { if (dictionary.TryGetValue(item2.Key, out var value2)) { dictionary[item2.Key] = value2 + num2; } else { dictionary[item2.Key] = num2; } } } } finally { if (castleMergedInventoryDatas.IsCreated) { castleMergedInventoryDatas.Dispose(); } } } foreach (KeyValuePair item3 in dictionary) { if (totals.TryGetValue(item3.Key, out var value3)) { if (item3.Value > value3) { totals[item3.Key] = item3.Value; } } else { totals[item3.Key] = item3.Value; } } } finally { Suppress = flag; } } private static bool IsIronName(string name) { if (string.IsNullOrEmpty(name)) { return false; } if (name.Equals("Iron Ingot", StringComparison.OrdinalIgnoreCase) || name.IndexOf("Iron Ingot", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (name.IndexOf("IronIngot", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (name.IndexOf("IronBar", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (name.IndexOf("Mineral_IronBar", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } return false; } private static bool IsPlankName(string name) { if (string.IsNullOrEmpty(name)) { return false; } if (name.Equals("Reinforced Plank", StringComparison.OrdinalIgnoreCase) || name.IndexOf("Reinforced Plank", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } return name.IndexOf("ReinforcedPlank", StringComparison.OrdinalIgnoreCase) >= 0; } internal static string PrefabName(int guid) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) try { PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(guid); string text = Core.Localization?.GetPrefabName(val); if (!string.IsNullOrEmpty(text)) { return text; } return val.LookupName(); } catch { return null; } } private static void UnionNameAliases(Dictionary totals) { if (totals == null || totals.Count == 0) { return; } HashSet hashSet = new HashSet { -1750550553 }; HashSet hashSet2 = new HashSet { -1397591435 }; foreach (int item in new List(totals.Keys)) { string name = PrefabName(item); if (IsIronName(name)) { hashSet.Add(item); } if (IsPlankName(name)) { hashSet2.Add(item); } } SpreadMax(totals, hashSet); SpreadMax(totals, hashSet2); } private static void SpreadMax(Dictionary totals, HashSet group) { int num = 0; foreach (int item in group) { if (totals.TryGetValue(item, out var value) && value > num) { num = value; } } if (num <= 0) { return; } foreach (int item2 in group) { totals[item2] = num; } } private static IEnumerable AliasesFor(int guid, Dictionary totals) { yield return guid; if (guid == -1750550553 || guid == -1397591435) { if (totals == null) { yield break; } foreach (int key in totals.Keys) { if (key != guid) { string name = PrefabName(key); if (guid == -1750550553 && IsIronName(name)) { yield return key; } if (guid == -1397591435 && IsPlankName(name)) { yield return key; } } } yield break; } string reqName = PrefabName(guid); if (IsIronName(reqName)) { yield return -1750550553; if (totals != null) { foreach (int key2 in totals.Keys) { if (key2 != guid && IsIronName(PrefabName(key2))) { yield return key2; } } } } if (!IsPlankName(reqName)) { yield break; } yield return -1397591435; if (totals == null) { yield break; } foreach (int key3 in totals.Keys) { if (key3 != guid && IsPlankName(PrefabName(key3))) { yield return key3; } } } private static int CountMergedAmountAliased(NativeArray merged, PrefabGUID type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) int num = CountMergedAmount(merged, type); if (!merged.IsCreated) { return num; } string name = PrefabName(((PrefabGUID)(ref type)).GuidHash); bool flag = ((PrefabGUID)(ref type)).GuidHash == -1750550553 || IsIronName(name); bool flag2 = ((PrefabGUID)(ref type)).GuidHash == -1397591435 || IsPlankName(name); if (!flag && !flag2) { return num; } int num2 = 0; for (int i = 0; i < merged.Length; i++) { PrefabGUID itemType = merged[i].ItemType; if (!((PrefabGUID)(ref itemType)).Equals(type) && ((PrefabGUID)(ref itemType)).GuidHash != 0) { string name2 = PrefabName(((PrefabGUID)(ref itemType)).GuidHash); if ((flag && (((PrefabGUID)(ref itemType)).GuidHash == -1750550553 || IsIronName(name2))) || (flag2 && (((PrefabGUID)(ref itemType)).GuidHash == -1397591435 || IsPlankName(name2)))) { num2 += merged[i].Amount; } } } return num + num2; } internal static void InvalidateBuildAvailable() { bagAvailAt = DateTime.MinValue; bagAvail.Clear(); buildAvail.Clear(); buildAvailAt = DateTime.MinValue; plotAvail.Clear(); } private static void AddStacks(Entity inventory, Dictionary dest) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (inventory == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(inventory)) { return; } ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val)) { return; } for (int i = 0; i < val.Length; i++) { InventoryBuffer val2 = val[i]; int guidHash = ((PrefabGUID)(ref val2.ItemType)).GuidHash; int amount = val[i].Amount; if (guidHash != 0 && amount > 0) { if (dest.TryGetValue(guidHash, out var value)) { dest[guidHash] = value + amount; } else { dest[guidHash] = amount; } } } } private static Dictionary EnsurePlotCounts(int plotId) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) DateTime utcNow = DateTime.UtcNow; if (plotAvail.TryGetValue(plotId, out var value) && (utcNow - value.At).TotalSeconds < 0.25 && value.Counts != null) { return new Dictionary(value.Counts); } Dictionary dictionary = new Dictionary(); ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); foreach (Entity item in Core.Stash.ChestsOnPlot(plotId)) { if (item.Has() || StashRouting.IsNoShare(item) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item, ref val)) { continue; } Enumerator enumerator2 = val.GetEnumerator(); while (enumerator2.MoveNext()) { Entity entity = enumerator2.Current.Entity; if (entity == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity) && entity.Has()) { PrefabGUID val2 = entity.Read(); if (((PrefabGUID)(ref val2)).Equals(StashService.ChestBagGuid)) { AddStacks(entity, dictionary); } } } } plotAvail[plotId] = new PlotCountCache { At = utcNow, Counts = dictionary }; return new Dictionary(dictionary); } private static void EnsureBuildAvailable(Entity standingHeart, Entity character) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) DateTime utcNow = DateTime.UtcNow; if (standingHeart == buildAvailHeart && character == buildAvailChar && (utcNow - buildAvailAt).TotalSeconds < 0.25 && buildAvail.Count > 0) { return; } if (character != bagAvailChar || (utcNow - bagAvailAt).TotalSeconds >= 0.25) { bagAvail.Clear(); bagAvailChar = character; bagAvailAt = utcNow; if (character != Entity.Null) { EntityManager entityManager = Core.EntityManager; Entity val = default(Entity); if (((EntityManager)(ref entityManager)).Exists(character) && InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, character, ref val, 0) && val != Entity.Null) { AddStacks(val, bagAvail); } } } buildAvail.Clear(); foreach (KeyValuePair item in bagAvail) { buildAvail[item.Key] = item.Value; } int num = TerritoryIdFromHeart(standingHeart); if (num < 0) { buildAvailHeart = standingHeart; buildAvailChar = character; buildAvailAt = utcNow; return; } IReadOnlyList readOnlyList = Core.TerritoryService.GetLogisticsTerritoryIds(num); if (readOnlyList == null || readOnlyList.Count == 0) { readOnlyList = new int[1] { num }; } foreach (int item2 in readOnlyList) { Dictionary dictionary = EnsurePlotCounts(item2); Core.TerritoryService.TryGetTerritoryOwnerPlatformId(item2, out var platformId); foreach (KeyValuePair item3 in dictionary) { int num2 = item3.Value; if (item2 != num) { int pullReserve = Core.PlayerSettings.GetPullReserve(platformId, new PrefabGUID(item3.Key)); if (pullReserve > 0) { num2 -= pullReserve; } } if (num2 > 0) { if (buildAvail.TryGetValue(item3.Key, out var value)) { buildAvail[item3.Key] = value + num2; } else { buildAvail[item3.Key] = num2; } } } } buildAvailHeart = standingHeart; buildAvailChar = character; buildAvailAt = utcNow; } private static int CountBuildAvailable(Entity standingHeart, Entity character, PrefabGUID type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) EnsureBuildAvailable(standingHeart, character); if (buildAvail.TryGetValue(((PrefabGUID)(ref type)).GuidHash, out var value)) { return value; } return 0; } private static int CountBuildAvailableAliased(Entity standingHeart, Entity character, PrefabGUID type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) int num = CountBuildAvailable(standingHeart, character, type); string name = PrefabName(((PrefabGUID)(ref type)).GuidHash); bool flag = ((PrefabGUID)(ref type)).GuidHash == -1750550553 || IsIronName(name); bool flag2 = ((PrefabGUID)(ref type)).GuidHash == -1397591435 || IsPlankName(name); if (!flag && !flag2) { return num; } if (flag && ((PrefabGUID)(ref type)).GuidHash != -1750550553) { num += CountBuildAvailable(standingHeart, character, new PrefabGUID(-1750550553)); } if (flag2 && ((PrefabGUID)(ref type)).GuidHash != -1397591435) { num += CountBuildAvailable(standingHeart, character, new PrefabGUID(-1397591435)); } return num; } internal static bool HasEnoughForBuild(EntityManager entityManager, Entity standingHeart, Entity character, NativeParallelHashMap requirements) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!requirements.IsCreated) { return false; } NativeArray keyArray = requirements.GetKeyArray(AllocatorHandle.op_Implicit((Allocator)2)); try { int num = default(int); for (int i = 0; i < keyArray.Length; i++) { PrefabGUID val = keyArray[i]; if (requirements.TryGetValue(val, ref num) && num > 0) { int num2 = CountBuildAvailableAliased(standingHeart, character, val); if (num2 < num) { DestDebugLog.Miss("build", TerritoryIdFromHeart(standingHeart), val, num2, num, "has-enough"); return false; } } } return true; } finally { if (keyArray.IsCreated) { keyArray.Dispose(); } } } internal static bool ConsumeBuildRequirements(EntityManager entityManager, MapZoneCollection mapZoneCollection, Entity standingHeart, Entity character, NativeParallelHashMap requirements) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (!requirements.IsCreated) { return true; } bool result = true; InvalidateBuildAvailable(); NativeArray keyArray = requirements.GetKeyArray(AllocatorHandle.op_Implicit((Allocator)2)); try { int num = default(int); int remainder = default(int); PrefabGUID val2 = default(PrefabGUID); int num2 = default(int); bool flag = default(bool); for (int i = 0; i < keyArray.Length; i++) { PrefabGUID val = keyArray[i]; if (!requirements.TryGetValue(val, ref num) || num <= 0) { continue; } MergedInventoriesUtility.RemoveItemGetRemainder(entityManager, mapZoneCollection, character, val, num, ref remainder, true, true, true); if (remainder > 0) { ConsumeRemainderFromClanDests(standingHeart, val, ref remainder); } if (remainder > 0) { foreach (int item in AliasesFor(((PrefabGUID)(ref val)).GuidHash, null)) { if (item != ((PrefabGUID)(ref val)).GuidHash && remainder > 0) { ((PrefabGUID)(ref val2))..ctor(item); MergedInventoriesUtility.RemoveItemGetRemainder(entityManager, mapZoneCollection, character, val2, remainder, ref num2, true, true, true); remainder = num2; if (remainder > 0) { ConsumeRemainderFromClanDests(standingHeart, val2, ref remainder); } } } } if (remainder > 0) { result = false; ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(59, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ClanTreasuryHUD] consume leftover guid="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((PrefabGUID)(ref val)).GuidHash); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" remainder="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(remainder); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" needed="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); } log.LogWarning(val3); } } return result; } finally { if (keyArray.IsCreated) { keyArray.Dispose(); } } } } internal class ConveyorService { public ConveyorService() { Core.TerritoryService.RegisterTerritoryUpdateCallback(BeltRun.Stations); Core.TerritoryService.RegisterTerritoryUpdateCallback(BeltRun.Salvagers); Core.TerritoryService.RegisterTerritoryUpdateCallback(BeltRun.Spawners); Core.TerritoryService.RegisterTerritoryUpdateCallback(BeltRun.Braziers); } public Dictionary CountTerritoryItems(int territoryId) { return BeltCounts.OfPlot(territoryId); } public Dictionary CountTerritoryItems(IReadOnlyList territoryIds) { return BeltCounts.OfPlots(territoryIds); } } internal static class DebugPeekService { private struct PlayerRow { public ulong steam; public string name; public int plot; public bool admin; public bool connected; } private const float PollSeconds = 0.25f; private static readonly string Dir = Path.Combine(Paths.ConfigPath, "Satisvampory", "debug"); private static readonly string ReqPath = Path.Combine(Dir, "req.json"); private static readonly string ResPath = Path.Combine(Dir, "res.json"); private static string lastId = ""; private static string lastText = ""; internal static IEnumerator Loop() { try { Directory.CreateDirectory(Dir); } catch { } WaitForSeconds wait = new WaitForSeconds(0.25f); while (true) { yield return wait; try { Tick(); } catch (Exception e) { Core.LogException(e, "Loop"); } } } private static void Tick() { if (!Core.HasInitialized || !File.Exists(ReqPath)) { return; } string text; try { text = File.ReadAllText(ReqPath); } catch { return; } if (string.IsNullOrWhiteSpace(text)) { return; } string text2 = ""; string text3 = "help"; int plot = -1; int guid = 0; string text4 = ""; bool apply = false; int users = 30; string dest = ""; int seconds = 0; try { using JsonDocument jsonDocument = JsonDocument.Parse(text); JsonElement rootElement = jsonDocument.RootElement; if (rootElement.TryGetProperty("id", out var value)) { text2 = value.GetString() ?? ""; } if (rootElement.TryGetProperty("op", out var value2)) { text3 = (value2.GetString() ?? "help").Trim().ToLowerInvariant(); } if (rootElement.TryGetProperty("plot", out var value3) && value3.ValueKind == JsonValueKind.Number) { plot = value3.GetInt32(); } if (rootElement.TryGetProperty("guid", out var value4) && value4.ValueKind == JsonValueKind.Number) { guid = value4.GetInt32(); } if (rootElement.TryGetProperty("name", out var value5)) { text4 = value5.GetString() ?? ""; } if (rootElement.TryGetProperty("item", out var value6)) { text4 = value6.GetString() ?? text4; } if (rootElement.TryGetProperty("dest", out var value7)) { dest = value7.GetString() ?? ""; } if (rootElement.TryGetProperty("apply", out var value8) && (value8.ValueKind == JsonValueKind.True || (value8.ValueKind == JsonValueKind.String && value8.GetString() == "true"))) { apply = true; } if (rootElement.TryGetProperty("users", out var value9) && value9.ValueKind == JsonValueKind.Number) { users = value9.GetInt32(); } if (rootElement.TryGetProperty("seconds", out var value10) && value10.ValueKind == JsonValueKind.Number) { seconds = value10.GetInt32(); } } catch (Exception ex) { WriteRes("{\"ok\":false,\"error\":\"bad json: " + Esc(ex.Message) + "\"}"); TryDeleteReq(); return; } if (string.IsNullOrEmpty(text) || !(text == lastText) || string.IsNullOrEmpty(text2) || !(text2 == lastId)) { lastId = text2; lastText = text; string text5; try { text5 = Dispatch(text3, plot, guid, text4, apply, users, dest, seconds); } catch (Exception ex2) { text5 = "{\"ok\":false,\"op\":\"" + Esc(text3) + "\",\"error\":\"" + Esc(ex2.Message) + "\"}"; } WriteRes("{\"id\":\"" + Esc(text2) + "\",\"ok\":true,\"op\":\"" + Esc(text3) + "\",\"data\":" + text5 + "}"); TryDeleteReq(); } } private static string Dispatch(string op, int plot, int guid, string name, bool apply, int users = 30, string dest = "", int seconds = 0) { switch (op) { case "help": return "{\"ops\":[\"help\",\"players\",\"plots\",\"plot\",\"item\",\"covering\",\"upgrade\",\"settings\",\"dest\",\"sim\",\"fair\",\"occupy\",\"guest\",\"cover\",\"unstick\",\"need\",\"selftest\",\"log\",\"perf\",\"logdump\",\"servants\",\"servantstash\",\"thrones\",\"gotothrone\",\"hunt\",\"huntsend\",\"hunttime\",\"revive\",\"rhmax\"],\"req\":\"" + Esc(ReqPath) + "\",\"res\":\"" + Esc(ResPath) + "\",\"hint\":\"{\\\"op\\\":\\\"log\\\",\\\"name\\\":\\\"dupe\\\"}\",\"sim\":\"dry-run covering as if you are standing on plot. apply:true actually moves\",\"log\":\"tail rolling Satisvampory.log (name=filter kind/via/item, plot=N)\",\"perf\":\"last lend-tick timings\",\"logdump\":\"write ring to debug/log.txt\",\"fair\":\"30-player occupy round-robin budget (users:N)\",\"guest\":\"castle-guest isolation contract\",\"cover\":\"force a covering tick now\",\"unstick\":\"clear sticky-fail for plot\",\"plots\":\"all claimed plots (level, owner, cse, occupied, destMode)\",\"upgrade\":\"heart upgrade costs vs have on plot\",\"settings\":\"cs/asm/hf/cse/conveyor/cloop for plot owner\",\"servants\":\"list coffins/servants and loot counts (plot:N optional)\",\"thrones\":\"list thrones with positions, connected players, .s throne picks, last hunt rewrite\",\"gotothrone\":\"debug: move a connected player onto plot N's throne (name:here returns).\",\"hunt\":\"arm next vanilla map click (plot:N name:'1 2')\",\"huntsend\":\"actually send idle servants now (plot, name:'Raven' or '1 2', dest:'Fishing Lake' or last zone)\",\"hunttime\":\"set remaining seconds on an active hunt (plot, name:servant filter, seconds:N)\",\"revive\":\"start revive on dead coffins (plot, name:'Corey Lewie')\",\"rhmax\":\"set repeat max success % (seconds:N). 100 also forces vanilla mission success/injury table\",\"servantstash\":\"stash all returned servants now (plot:N optional)\"}"; case "players": return PeekPlayers(); case "plots": return PeekPlots(); case "plot": if (plot < 0) { plot = FirstStandingPlot(); } return PeekPlot(plot); case "upgrade": case "heartupgrade": if (plot < 0) { plot = FirstStandingPlot(); } return ClanTreasuryLend.DebugUpgrade(plot); case "settings": if (plot < 0) { plot = FirstStandingPlot(); } return PeekSettings(plot); case "item": return PeekItem(plot, guid, name); case "covering": if (plot < 0) { plot = FirstStandingPlot(); } return PeekCovering(plot); case "dest": case "sim": case "why": return SimItem(plot, guid, name, apply); case "tick": case "cover": ClanTreasuryLend.DebugTick(); return "{\"ticked\":true,\"plot\":" + ((plot < 0) ? FirstStandingPlot() : plot) + "}"; case "unstick": return "{\"cleared\":" + ClanTreasuryLend.DebugUnstick(plot) + ",\"plot\":" + plot + "}"; case "servants": return Core.Stash.DebugListServants(plot); case "thrones": return ClanThroneServants.DebugDump(plot); case "gotothrone": case "movethrone": return ClanThroneServants.DebugGoto(plot, name); case "hunt": case "huntsel": return ClanThroneServants.DebugHunt(plot, name); case "huntsend": case "sendhunt": return RepeatHunts.DebugSend(plot, name, dest); case "hunttime": case "missiontime": return RepeatHunts.DebugSetTime(plot, name, (seconds > 0) ? seconds : users); case "rez": case "revive": return RepeatHunts.DebugRevive(plot, name); case "rhmax": return RepeatHunts.DebugRhMax((seconds > 0) ? seconds : ((users > 0) ? users : 99)); case "servantstash": case "asmstash": return Core.Stash.DebugStashAllServants(plot); case "need": if (plot < 0) { plot = FirstStandingPlot(); } return PeekNeed(plot); case "fair": case "occupy": return ClanTreasuryLend.DebugFairness(users); case "guest": return ClanTreasuryLend.DebugGuest(); case "logs": case "log": return DestDebugLog.MailboxTail(plot, name, 80); case "perf": return DestDebugLog.MailboxPerf(); case "logdump": return DestDebugLog.MailboxDump(Path.Combine(Dir, "log.txt")); case "selftest": return "{\"dest\":" + StashRouting.SelfTestDest() + ",\"coveringCap1200\":" + ClanTreasuryLend.CapCovering1x(1200) + ",\"coveringCap40\":" + ClanTreasuryLend.CapCovering1x(40) + ",\"coveringCapOk\":" + ((ClanTreasuryLend.CapCovering1x(1200) == 200 && ClanTreasuryLend.CapCovering1x(40) == 40) ? "true" : "false") + ",\"fair\":" + ClanTreasuryLend.DebugFairness((users <= 0) ? 30 : users) + "}"; default: return "{\"error\":\"unknown op\"}"; } } private static PrefabGUID ResolveItem(int guid, string name) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (guid != 0) { return new PrefabGUID(guid); } if (!string.IsNullOrWhiteSpace(name) && FoundItemConverter.TryResolve(name, out FoundItem item, out List<(PrefabGUID, string)> _) == ItemResolveStatus.Unique) { return item.prefab; } return default(PrefabGUID); } private static string SimItem(int plot, int guid, string name, bool apply) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (plot < 0) { plot = FirstStandingPlot(); } PrefabGUID type = ResolveItem(guid, name); if (((PrefabGUID)(ref type)).GuidHash == 0) { ((PrefabGUID)(ref type))..ctor(-1017402979); } return ClanTreasuryLend.DebugSimulate(plot, type, apply); } private static string PeekNeed(int plot) { if (plot < 0) { return "{\"error\":\"no plot\"}"; } if (Core.ConveyorService == null) { return "{\"error\":\"not ready\"}"; } List list = BeltInspect.Need(plot); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plot\":").Append(plot).Append(",\"lines\":["); for (int i = 0; i < list.Count; i++) { if (i > 0) { stringBuilder.Append(','); } stringBuilder.Append('"').Append(Esc(list[i])).Append('"'); } stringBuilder.Append("]}"); return stringBuilder.ToString(); } internal static string PeekNow(int plot) { if (plot < 0) { plot = FirstStandingPlot(); } string text = PeekPlot(plot); WriteRes("{\"id\":\"peek\",\"ok\":true,\"op\":\"plot\",\"data\":" + text + "}"); return text; } private static int FirstStandingPlot() { foreach (PlayerRow item in Connected()) { if (item.plot >= 0) { return item.plot; } } return -1; } private unsafe static List Connected() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) List list = new List(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has()) { continue; } User val6 = val5.Read(); if (!val6.IsConnected) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val6.LocalCharacter)).GetEntityOnServer(); int plot = -1; if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { plot = Core.TerritoryService.GetStandingTerritoryId(entityOnServer); } } list.Add(new PlayerRow { steam = val6.PlatformId, name = ((object)(*(FixedString64Bytes*)(&val6.CharacterName))/*cast due to .constrained prefix*/).ToString(), plot = plot, admin = val6.IsAdmin, connected = true }); } return list; } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } private static string PeekPlots() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plots\":["); bool flag = true; for (int i = 0; i <= 146; i++) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(i); if (castleHeart == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(castleHeart)) { continue; } int value = -1; if (castleHeart.Has()) { value = castleHeart.Read().Level; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(i, out var platformId); int num = 0; int num2 = 0; foreach (Entity item in Core.Stash.ChestsOnPlot(i)) { if (!item.Has() && !StashRouting.IsNoShare(item)) { num2++; if (ClanTreasuryShare.IsTreasuryLinked(item)) { num++; } } } if (!flag) { stringBuilder.Append(','); } flag = false; stringBuilder.Append("{\"plot\":").Append(i).Append(",\"heartLevel\":") .Append(value) .Append(",\"owner\":\"") .Append(platformId) .Append('"') .Append(",\"cse\":") .Append(Core.PlayerSettings.IsTerritoryClanShareExcluded(i) ? "true" : "false") .Append(",\"occupied\":") .Append(ClanTreasuryLend.DebugIsOccupied(i) ? "true" : "false") .Append(",\"treasuryChests\":") .Append(num) .Append(",\"chests\":") .Append(num2) .Append(",\"destMode\":\"") .Append((num > 0) ? "treasury" : "allShared") .Append('"') .Append('}'); } stringBuilder.Append("]}"); return stringBuilder.ToString(); } private unsafe static string PeekSettings(int plot) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plot\":").Append(plot); if (plot < 0) { stringBuilder.Append(",\"error\":\"no plot\"}"); return stringBuilder.ToString(); } Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); ulong num = 0uL; string s = ""; bool flag = false; bool flag2 = false; bool flag3 = false; if (castleHeart != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { UserOwner val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has()) { User val2 = entityOnServer.Read(); num = val2.PlatformId; s = ((object)(*(FixedString64Bytes*)(&val2.CharacterName))/*cast due to .constrained prefix*/).ToString(); flag = Core.TerritoryService.IsClanShareOn(val2); flag2 = Core.PlayerSettings.IsAutoStashMissionsEnabled(num); flag3 = Core.PlayerSettings.IsConveyorEnabled(num); } } } } bool flag4 = Core.PlayerSettings.IsHeartFeedEnabled(num, plot); bool plotSalvageFlag = Core.PlayerSettings.GetPlotSalvageFlag(num, plot); stringBuilder.Append(",\"owner\":\"").Append(num).Append('"') .Append(",\"name\":\"") .Append(Esc(s)) .Append('"') .Append(",\"cs\":") .Append(flag ? "true" : "false") .Append(",\"cse\":") .Append(Core.PlayerSettings.IsTerritoryClanShareExcluded(plot) ? "true" : "false") .Append(",\"asm\":") .Append(flag2 ? "true" : "false") .Append(",\"hf\":") .Append(flag4 ? "true" : "false") .Append(",\"salvage\":") .Append(plotSalvageFlag ? "true" : "false") .Append(",\"conveyor\":") .Append(flag3 ? "true" : "false") .Append(",\"convloop\":") .Append(Core.PlayerSettings.IsConveyorLoopsAllowed() ? "true" : "false") .Append(",\"occupied\":") .Append(ClanTreasuryLend.DebugIsOccupied(plot) ? "true" : "false") .Append('}'); return stringBuilder.ToString(); } private static string PeekPlayers() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"players\":["); bool flag = true; foreach (PlayerRow item in Connected()) { if (!flag) { stringBuilder.Append(','); } flag = false; stringBuilder.Append("{\"steam\":\"").Append(item.steam).Append("\",\"name\":\"") .Append(Esc(item.name)) .Append("\",\"plot\":") .Append(item.plot) .Append(",\"admin\":") .Append(item.admin ? "true" : "false") .Append('}'); } stringBuilder.Append("]}"); return stringBuilder.ToString(); } private unsafe static string PeekPlot(int plot) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plot\":").Append(plot); if (plot < 0) { stringBuilder.Append(",\"error\":\"no plot\"}"); return stringBuilder.ToString(); } Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); int value = -1; string s = ""; string s2 = ""; if (castleHeart != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { CastleHeart val = castleHeart.Read(); value = val.Level; s = ((object)(*(CastleHeartState*)(&val.State))/*cast due to .constrained prefix*/).ToString(); s2 = ((object)(*(CastleHeartEvent*)(&val.ActiveEvent))/*cast due to .constrained prefix*/).ToString(); } } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(plot, out var platformId); int num = 0; List list = new List(); ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val3 = default(DynamicBuffer); foreach (Entity item in Core.Stash.ChestsOnPlot(plot)) { if (item.Has() || StashRouting.IsNoShare(item)) { continue; } string text = StashRouting.RawName(item); bool flag = ClanTreasuryShare.IsTreasuryLinked(item); if (flag) { num++; } object obj; if (!item.Has()) { obj = "no-ws"; } else { CastleWorkstation val2 = item.Read(); obj = ((object)(*(CastleFloorTypes*)(&val2.MatchingFloorType))/*cast due to .constrained prefix*/).ToString(); } string s3 = (string)obj; string s4 = (item.Has() ? ((object)item.Read()/*cast due to .constrained prefix*/).ToString() : ""); if (!StashRouting.TryGetExternalInventory(item, out var inventory)) { list.Add("{\"name\":\"" + Esc(text) + "\",\"net\":\"" + Esc(s4) + "\",\"treasuryLinked\":" + (flag ? "true" : "false") + ",\"matchingFloor\":\"" + Esc(s3) + "\",\"error\":\"no-inv\"}"); continue; } StringBuilder stringBuilder2 = new StringBuilder(); int num2 = 0; bool flag2 = true; if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val3)) { for (int i = 0; i < val3.Length; i++) { InventoryBuffer val4 = val3[i]; if (((PrefabGUID)(ref val4.ItemType)).GuidHash != 0 && val3[i].Amount > 0) { num2++; if (!flag2) { stringBuilder2.Append(','); } flag2 = false; StringBuilder stringBuilder3 = stringBuilder2.Append("{\"guid\":"); val4 = val3[i]; stringBuilder3.Append(((PrefabGUID)(ref val4.ItemType)).GuidHash).Append(",\"name\":\"").Append(Esc(StashRouting.ItemLabel(val3[i].ItemType))) .Append("\",\"n\":") .Append(val3[i].Amount) .Append('}'); } } } list.Add("{\"name\":\"" + Esc(text) + "\",\"destName\":\"" + Esc(StashRouting.DestName(item)) + "\",\"net\":\"" + Esc(s4) + "\",\"treasuryLinked\":" + (flag ? "true" : "false") + ",\"matchingFloor\":\"" + Esc(s3) + "\",\"unnamed\":" + (StashRouting.IsUnnamedOrGeneric(text) ? "true" : "false") + ",\"overflow\":" + (StashRouting.IsOverflowDestName(text) ? "true" : "false") + ",\"conveyor\":" + (StashRouting.IsConveyorName(text) ? "true" : "false") + ",\"stacks\":" + num2 + ",\"items\":[" + stringBuilder2?.ToString() + "]}"); } string value2 = ((num > 0) ? "treasury" : "allShared"); stringBuilder.Append(",\"owner\":\"").Append(platformId).Append("\",\"heartLevel\":") .Append(value) .Append(",\"heartState\":\"") .Append(Esc(s)) .Append("\",\"heartEvent\":\"") .Append(Esc(s2)) .Append("\",\"destMode\":\"") .Append(value2) .Append("\",\"treasuryChests\":") .Append(num) .Append(",\"holdKitOverflow\":") .Append(ClanTreasuryLend.HoldKitOverflow(plot) ? "true" : "false") .Append(",\"chests\":["); for (int j = 0; j < list.Count; j++) { if (j > 0) { stringBuilder.Append(','); } stringBuilder.Append(list[j]); } stringBuilder.Append("]}"); return stringBuilder.ToString(); } private static string PeekCovering(int plot) { if (plot < 0) { plot = FirstStandingPlot(); } Dictionary dictionary = ClanTreasuryLend.DebugCovering1x(plot); dictionary.TryGetValue(-1017402979, out var value); dictionary.TryGetValue(-1237019921, out var value2); dictionary.TryGetValue(271594022, out var value3); dictionary.TryGetValue(862477668, out var value4); dictionary.TryGetValue(1788016417, out var value5); dictionary.TryGetValue(-1531666018, out var value6); dictionary.TryGetValue(820932258, out var value7); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plot\":").Append(plot).Append(",\"mats\":") .Append(dictionary.Count) .Append(",\"plank1x\":") .Append(value) .Append(",\"copper1x\":") .Append(value2) .Append(",\"be1x\":") .Append(value4) .Append(",\"gbe1x\":") .Append(value3) .Append(",\"brick1x\":") .Append(value5) .Append(",\"stone1x\":") .Append(value6) .Append(",\"gemdust1x\":") .Append(value7) .Append('}'); return stringBuilder.ToString(); } private static string PeekItem(int plot, int guid, string name) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = default(PrefabGUID); FoundItem item; List<(PrefabGUID, string)> candidates; if (guid != 0) { ((PrefabGUID)(ref val))..ctor(guid); } else if (!string.IsNullOrWhiteSpace(name) && FoundItemConverter.TryResolve(name, out item, out candidates) == ItemResolveStatus.Unique) { val = item.prefab; } if (((PrefabGUID)(ref val)).GuidHash == 0) { return "{\"error\":\"item not found\"}"; } if (plot < 0) { plot = FirstStandingPlot(); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"guid\":").Append(((PrefabGUID)(ref val)).GuidHash).Append(",\"name\":\"") .Append(Esc(StashRouting.ItemLabel(val))) .Append("\",\"plot\":") .Append(plot) .Append(",\"chests\":["); bool flag = true; int num = 0; if (plot >= 0) { ServerGameManager serverGameManager = Core.ServerGameManager; foreach (Entity item2 in Core.Stash.ChestsOnPlot(plot)) { if (item2.Has() || StashRouting.IsNoShare(item2) || !StashRouting.TryGetExternalInventory(item2, out var inventory)) { continue; } int inventoryItemCount = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, val); if (inventoryItemCount > 0) { num += inventoryItemCount; if (!flag) { stringBuilder.Append(','); } flag = false; stringBuilder.Append("{\"name\":\"").Append(Esc(StashRouting.RawName(item2))).Append("\",\"n\":") .Append(inventoryItemCount) .Append(",\"treasuryLinked\":") .Append(ClanTreasuryShare.IsTreasuryLinked(item2) ? "true" : "false") .Append('}'); } } } stringBuilder.Append("],\"total\":").Append(num).Append('}'); return stringBuilder.ToString(); } private static void WriteRes(string json) { try { Directory.CreateDirectory(Dir); string text = ResPath + ".tmp"; File.WriteAllText(text, json); File.Copy(text, ResPath, overwrite: true); File.Delete(text); } catch (Exception ex) { Core.Log.LogWarning((object)("[DebugPeek] write res failed: " + ex.Message)); } } private static void TryDeleteReq() { try { File.Delete(ReqPath); } catch { } } private static string Esc(string s) { if (string.IsNullOrEmpty(s)) { return ""; } return s.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\r", " ") .Replace("\n", " "); } } internal static class DestDebugLog { private const long MaxBytes = 2097152L; private const int Backups = 3; private const int RingSize = 256; private const int MailboxLines = 80; private const string FileStem = "Satisvampory"; private static readonly object Gate = new object(); private static string _dir; private static string _path; private static StreamWriter _writer; private static bool _initTried; private static readonly string[] Ring = new string[256]; private static int ringWrite; private static int ringCount; private static readonly Dictionary throttle = new Dictionary(); private static readonly string[] lastPerf = new string[24]; private static int perfWrite; private static int perfCount; private static int unflushed; private static DateTime lastFlushUtc = DateTime.MinValue; private const int FlushEveryLines = 32; private const int FlushEveryMs = 250; public static string LogPath => _path ?? ""; public static string LogDir => _dir ?? ""; public static void Init() { lock (Gate) { EnsureWriter_NoLock(); } } public static void Close() { lock (Gate) { try { FlushWriter_NoLock(force: true); _writer?.Dispose(); } catch { } _writer = null; } } private static void EnsureWriter_NoLock() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown if (_writer != null || (_initTried && _writer == null)) { return; } _initTried = true; try { _dir = Path.Combine(Paths.BepInExRootPath, "Log"); Directory.CreateDirectory(_dir); _path = Path.Combine(_dir, "Satisvampory.log"); _writer = NewWriter(FileMode.Append); _writer.WriteLine(Stamp() + " kind=boot via=boot plot=-1 item= FileVersion=1.0.85"); _writer.Flush(); } catch (Exception ex) { try { ManualLogSource log = Core.Log; if (log != null) { bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Satisvampory] DestDebugLog init failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } catch { } _writer = null; } } private static StreamWriter NewWriter(FileMode mode) { return new StreamWriter(new FileStream(_path, mode, FileAccess.Write, FileShare.ReadWrite), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)) { AutoFlush = false }; } private static void RotateIfNeeded_NoLock() { if (string.IsNullOrEmpty(_path)) { return; } try { FileInfo fileInfo = new FileInfo(_path); if (!fileInfo.Exists || fileInfo.Length < 2097152) { return; } _writer?.Flush(); _writer?.Dispose(); _writer = null; unflushed = 0; lastFlushUtc = DateTime.UtcNow; string path = Path.Combine(_dir, $"{"Satisvampory"}.{3}.log"); if (File.Exists(path)) { File.Delete(path); } for (int num = 2; num >= 1; num--) { string text = Path.Combine(_dir, $"{"Satisvampory"}.{num}.log"); string destFileName = Path.Combine(_dir, $"{"Satisvampory"}.{num + 1}.log"); if (File.Exists(text)) { File.Move(text, destFileName); } } File.Move(_path, Path.Combine(_dir, "Satisvampory.1.log")); _writer = NewWriter(FileMode.Create); } catch { } } private static string Stamp() { return DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); } public static string ChestTag(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!(stash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash)) { string text = StashRouting.DestName(stash); if (string.IsNullOrEmpty(text)) { text = "(unnamed)"; } string text2 = "-"; try { if (stash.Has()) { text2 = ((object)stash.Read()/*cast due to .constrained prefix*/).ToString(); } } catch { } return text.Replace('"', '\'') + "#" + text2; } } return "-"; } public static void Move(string via, int plot, PrefabGUID item, int amount, Entity src, Entity dest, string destClass, int leftover, string belt) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (amount > 0) { Write($"kind=move via={via} plot={plot} item={StashRouting.ItemLabel(item)} amount={amount} src=\"{ChestTag(src)}\" dest=\"{ChestTag(dest)}\" destClass={destClass} leftover={leftover} belt={belt}"); } } public static void Skip(string via, int plot, PrefabGUID item, Entity src, string reason) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(reason)) { Write($"kind=skip via={via} plot={plot} item={StashRouting.ItemLabel(item)} amount=0 src=\"{ChestTag(src)}\" dest=\"-\" skip={reason}"); } } public static void Dupe(string via, int plot, PrefabGUID item, int amount, string detail) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) Write($"kind=dupe via={via} plot={plot} item={StashRouting.ItemLabel(item)} amount={amount} {detail}"); } public static void Miss(string via, int plot, PrefabGUID item, int have, int need, string reason) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) int guidHash = ((PrefabGUID)(ref item)).GuidHash; string key = via + ":" + plot + ":" + guidHash + ":" + reason; int seconds = ((via == "covering") ? 30 : 8); if (Allow(key, seconds)) { Write($"kind=miss via={via} plot={plot} item={StashRouting.ItemLabel(item)} have={have} need={need} reason={reason}"); } } public static void Perf(string via, int occupied, int pulls, int ms, int queue, int players, int skip = 0, int backoff = 0) { string text = $"kind=perf via={via} occupied={occupied} pulls={pulls} ms={ms} queue={queue} players={players} skip={skip} backoff={backoff}"; Write(text); lock (Gate) { lastPerf[perfWrite % lastPerf.Length] = Stamp() + " " + text; perfWrite++; if (perfCount < lastPerf.Length) { perfCount++; } FlushWriter_NoLock(force: true); } } public static void Guest(int plot, ulong steam, string reason) { if (Allow("guest:" + steam + ":" + plot, 30)) { Write($"kind=guest via=occupy plot={plot} steam={steam} reason={reason}"); } } public static void Note(string via, int plot, ulong steam, string detail) { Write($"kind=note via={via} plot={plot} steam={steam} {detail}"); } private static bool Allow(string key, int seconds) { lock (Gate) { DateTime utcNow = DateTime.UtcNow; if (throttle.Count > 240) { throttle.Clear(); } if (throttle.TryGetValue(key, out var value) && (utcNow - value).TotalSeconds < (double)seconds) { return false; } throttle[key] = utcNow; return true; } } public static void Write(string line) { if (string.IsNullOrEmpty(line)) { return; } string text = Stamp() + " " + line; lock (Gate) { Ring[ringWrite % 256] = text; ringWrite++; if (ringCount < 256) { ringCount++; } try { EnsureWriter_NoLock(); if (_writer != null) { RotateIfNeeded_NoLock(); if (_writer != null) { _writer.WriteLine(text); unflushed++; FlushWriter_NoLock(force: false); } } } catch { } } } private static void FlushWriter_NoLock(bool force) { if (_writer != null && (force || unflushed >= 32 || !((DateTime.UtcNow - lastFlushUtc).TotalMilliseconds < 250.0))) { _writer.Flush(); unflushed = 0; lastFlushUtc = DateTime.UtcNow; } } public static string MailboxTail(int plot, string filter, int limit) { if (limit <= 0 || limit > 80) { limit = 80; } string[] array = CopyRing(); StringBuilder stringBuilder = new StringBuilder(); int num = 0; string text = (string.IsNullOrWhiteSpace(filter) ? "" : filter.Trim()); stringBuilder.Append("{\"path\":\"").Append(Esc(LogPath)).Append('"') .Append(",\"bytes\":") .Append(CurrentBytes()) .Append(",\"backups\":") .Append(3) .Append(",\"maxMB\":") .Append(2L) .Append(",\"ring\":") .Append(ringCount) .Append(",\"lines\":["); bool flag = true; for (int i = 0; i < array.Length; i++) { if (num >= limit) { break; } string text2 = array[i]; if (text2 != null && (plot < 0 || text2.IndexOf("plot=" + plot, StringComparison.Ordinal) >= 0 || text2.IndexOf("plot=-1", StringComparison.Ordinal) >= 0) && (text.Length <= 0 || text2.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0)) { if (!flag) { stringBuilder.Append(','); } flag = false; stringBuilder.Append('"').Append(Esc(text2)).Append('"'); num++; } } stringBuilder.Append("],\"matched\":").Append(num).Append('}'); return stringBuilder.ToString(); } public static string MailboxPerf() { string[] array; lock (Gate) { int num = perfCount; int num2 = perfWrite; array = new string[num]; for (int i = 0; i < num; i++) { array[i] = lastPerf[(num2 - num + i) % lastPerf.Length]; } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"queue\":").Append((Core.WorkQueue != null) ? Core.WorkQueue.QueueDepth : 0).Append(",\"path\":\"") .Append(Esc(LogPath)) .Append('"') .Append(",\"lines\":["); for (int j = 0; j < array.Length; j++) { if (j > 0) { stringBuilder.Append(','); } stringBuilder.Append('"').Append(Esc(array[j] ?? "")).Append('"'); } stringBuilder.Append("]}"); return stringBuilder.ToString(); } public static string MailboxDump(string destPath) { string[] array = CopyRing(); try { string directoryName = Path.GetDirectoryName(destPath); if (!string.IsNullOrEmpty(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllLines(destPath, array); } catch (Exception ex) { return "{\"ok\":false,\"error\":\"" + Esc(ex.Message) + "\"}"; } return "{\"ok\":true,\"path\":\"" + Esc(destPath) + "\",\"lines\":" + array.Length + ",\"log\":\"" + Esc(LogPath) + "\",\"bytes\":" + CurrentBytes() + "}"; } private static string[] CopyRing() { lock (Gate) { int num = ringCount; int num2 = ringWrite; string[] array = new string[num]; for (int i = 0; i < num; i++) { array[i] = Ring[(num2 - num + i) % 256]; } return array; } } private static long CurrentBytes() { try { if (!string.IsNullOrEmpty(_path) && File.Exists(_path)) { return new FileInfo(_path).Length; } } catch { } return 0L; } private static string Esc(string s) { if (string.IsNullOrEmpty(s)) { return ""; } return s.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\r", " ") .Replace("\n", " "); } } internal static class DropTracker { private struct PendingPlayerDrop { public float3 Position; public int ItemHash; public int Amount; public DateTime ExpiresAt; } public const float PlayerDropMatchRadius = 15f; public const float PlayerDropWindowSeconds = 6f; public const float DiscoverIntervalSeconds = 0.5f; private static readonly object Gate = new object(); private static readonly List Pending = new List(); private static readonly HashSet PlayerDropped = new HashSet(); private static readonly Dictionary> FreshFor = new Dictionary>(); private static readonly Dictionary SeenAmounts = new Dictionary(); private static readonly List Dead = new List(); private static bool seeded; public static IEnumerator DiscoverLoop() { WaitForSeconds wait = new WaitForSeconds(0.5f); while (true) { yield return wait; if (Core.HasInitialized) { try { Discover(); } catch (Exception e) { Core.LogException(e, "DiscoverLoop"); } } } } public static void SeedExisting() { lock (Gate) { SeenAmounts.Clear(); PlayerDropped.Clear(); FreshFor.Clear(); Pending.Clear(); seeded = false; SnapshotExistingNoTags(); seeded = true; } } public static void NotePlayerDrop(float3 position, PrefabGUID item, int amount) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) lock (Gate) { Pending.Add(new PendingPlayerDrop { Position = position, ItemHash = ((PrefabGUID)(ref item)).GuidHash, Amount = amount, ExpiresAt = DateTime.UtcNow.AddSeconds(6.0) }); } } public static void Discover() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { return; } lock (Gate) { if (!seeded) { SnapshotExistingNoTags(); seeded = true; return; } ExpirePending(); HashSet nowSeen = new HashSet(); ForEachPickup(delegate(Entity drop, ItemPickup pickup, float3 pos) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) nowSeen.Add(drop); int itemAmount = pickup.ItemAmount; if (!SeenAmounts.ContainsKey(drop)) { SeenAmounts[drop] = itemAmount; if (MatchesPendingPlayerDrop(pos, pickup.ItemId, itemAmount)) { PlayerDropped.Add(drop); } TagFreshForPlayersAt(drop, pos); } else { if (itemAmount > SeenAmounts[drop] && MatchesPendingPlayerDrop(pos, pickup.ItemId, itemAmount)) { PlayerDropped.Add(drop); } SeenAmounts[drop] = itemAmount; } }); Dead.Clear(); foreach (Entity key in SeenAmounts.Keys) { if (!nowSeen.Contains(key)) { Dead.Add(key); } } foreach (Entity item in Dead) { ForgetUnlocked(item); } } } public static bool IsPlayerDropped(Entity drop) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) lock (Gate) { return PlayerDropped.Contains(drop); } } public static bool IsFreshFor(Entity drop, ulong platformId) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) lock (Gate) { HashSet value; return FreshFor.TryGetValue(drop, out value) && value.Contains(platformId); } } public static void Forget(Entity drop) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) lock (Gate) { ForgetUnlocked(drop); } } private static void ForgetUnlocked(Entity drop) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) SeenAmounts.Remove(drop); PlayerDropped.Remove(drop); FreshFor.Remove(drop); } private static void SnapshotExistingNoTags() { ForEachPickup(delegate(Entity drop, ItemPickup pickup, float3 _) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) SeenAmounts[drop] = pickup.ItemAmount; }); } private static void ForEachPickup(Action action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val4.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!(current == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(current) && current.Has() && current.Has()) { action(current, current.Read(), current.Read().Value); } } } } finally { val4.Dispose(); ((EntityQuery)(ref val3)).Dispose(); } } private static void ExpirePending() { DateTime utcNow = DateTime.UtcNow; for (int num = Pending.Count - 1; num >= 0; num--) { if (Pending[num].ExpiresAt <= utcNow) { Pending.RemoveAt(num); } } } private static bool MatchesPendingPlayerDrop(float3 pos, PrefabGUID item, int amount) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) float num = 225f; foreach (PendingPlayerDrop item2 in Pending) { if (!(math.lengthsq(pos - item2.Position) > num) && (item2.ItemHash == 0 || item2.ItemHash == ((PrefabGUID)(ref item)).GuidHash)) { return true; } } return false; } private static void TagFreshForPlayersAt(Entity drop, float3 spawnPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { HashSet hashSet = null; Enumerator enumerator = val4.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(current) || !current.Has()) { continue; } User val5 = current.Read(); if (!val5.IsConnected) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val5.LocalCharacter)).GetEntityOnServer(); if (entityOnServer == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entityOnServer) || !entityOnServer.Has()) { continue; } float num = Core.PlayerSettings.GetRadius(val5.PlatformId); if (num < 1f) { num = 10f; } if (!(math.lengthsq(entityOnServer.Read().Value - spawnPos) > num * num)) { if (hashSet == null) { hashSet = new HashSet(); } hashSet.Add(val5.PlatformId); } } if (hashSet != null) { FreshFor[drop] = hashSet; } } finally { val4.Dispose(); ((EntityQuery)(ref val3)).Dispose(); } } } internal static class EmbeddedJson { public static Dictionary Load(string resourceName) { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (stream == null) { Console.WriteLine("Resource not found!"); return new Dictionary(); } using StreamReader streamReader = new StreamReader(stream); return JsonSerializer.Deserialize>(streamReader.ReadToEnd()) ?? new Dictionary(); } } internal static class FindBuff { public static bool TryApply(Entity user, Entity character, PrefabGUID prefab, float duration, bool immortal) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (BuffUtility.TryGetBuff(Core.Server.EntityManager, character, PrefabIdentifier.op_Implicit(prefab), ref val)) { return false; } Core.Server.GetExistingSystemManaged().ApplyBuff(new FromCharacter { User = user, Character = character }, new ApplyBuffDebugEvent { BuffPrefabGUID = prefab }); Entity buff = default(Entity); if (!BuffUtility.TryGetBuff(Core.Server.EntityManager, character, PrefabIdentifier.op_Implicit(prefab), ref buff)) { return false; } StripSpawnListeners(buff); if (immortal) { MakePersist(buff); } ApplyDuration(buff, duration); return true; } public static void Clear(Entity character, PrefabGUID prefab) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (BuffUtility.TryGetBuff(Core.EntityManager, character, PrefabIdentifier.op_Implicit(prefab), ref val)) { DestroyUtility.Destroy(Core.EntityManager, val, (DestroyDebugReason)13, (string)null, 0); } } public static void Refresh(Entity user, Entity target, PrefabGUID prefab, float duration, Buffs.BuffCreated callback) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!BuffUtility.HasBuff(Core.EntityManager, target, PrefabIdentifier.op_Implicit(prefab))) { TryApply(user, target, prefab, duration, immortal: true); InvokeIfPresent(target, prefab, callback); } else { Core.StartCoroutine(ClearThenApply(user, target, prefab, duration, callback)); } } private static IEnumerator ClearThenApply(Entity user, Entity target, PrefabGUID prefab, float duration, Buffs.BuffCreated callback) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Clear(target, prefab); while (BuffUtility.HasBuff(Core.EntityManager, target, PrefabIdentifier.op_Implicit(prefab))) { yield return null; } TryApply(user, target, prefab, duration, immortal: true); InvokeIfPresent(target, prefab, callback); } private static void InvokeIfPresent(Entity target, PrefabGUID prefab, Buffs.BuffCreated callback) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Entity buffEntity = default(Entity); if (callback != null && BuffUtility.TryGetBuff(Core.Server.EntityManager, target, PrefabIdentifier.op_Implicit(prefab), ref buffEntity)) { callback(buffEntity); } } private static void StripSpawnListeners(Entity buff) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (buff.Has()) { buff.Remove(); } if (buff.Has()) { buff.Remove(); } } private static void MakePersist(Entity buff) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) buff.Add(); DropRemoveOnEvent(buff); } private static void DropRemoveOnEvent(Entity buff) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (buff.Has()) { buff.Remove(); } if (buff.Has()) { buff.Remove(); } } private static void ApplyDuration(Entity buff, float duration) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (duration > -1f && duration != 0f) { if (!buff.Has()) { buff.Add(); buff.Write(new LifeTime { EndAction = (LifeTimeEndAction)2 }); } LifeTime componentData = buff.Read(); componentData.Duration = duration; buff.Write(componentData); } else if (duration == -1f) { if (buff.Has()) { LifeTime componentData2 = buff.Read(); componentData2.Duration = -1f; componentData2.EndAction = (LifeTimeEndAction)0; buff.Write(componentData2); } DropRemoveOnEvent(buff); } } } internal sealed class FindReport { private readonly FindSpotlight glow; public FindReport(FindSpotlight glow) { this.glow = glow; } private static string FormatCurrentPlotLine(int standing) { if (standing < 0) { return "Current plot: none (not standing on a castle)"; } return "Current plot: " + Core.TerritoryService.FormatPlotLabel(standing) + ""; } private static List OrderPlotsCurrentFirst(IReadOnlyList plotIds, int standing) { List list = new List(plotIds.Count); if (standing >= 0) { for (int i = 0; i < plotIds.Count; i++) { if (plotIds[i] == standing) { list.Add(standing); break; } } } for (int j = 0; j < plotIds.Count; j++) { if (plotIds[j] != standing) { list.Add(plotIds[j]); } } return list; } private void ReplyPlotHeader(User user, int plotId, int standing) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) string text = ((plotId == standing) ? " (here)" : ""); Utilities.SendSystemMessageToClient(Core.EntityManager, user, "" + Core.TerritoryService.FormatPlotLabel(plotId) + "" + text); } public void Items(Entity charEntity, PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) Entity userEntity = charEntity.Read().UserEntity; User val = userEntity.Read(); glow.Clear(userEntity); int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(charEntity); bool flag = Core.TerritoryService.IsClanShareOn(val); IReadOnlyList logisticsTerritoryIdsForCharacter = Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(charEntity); if (logisticsTerritoryIdsForCharacter.Count == 0) { if (flag) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, "Unable to search — no clan castles available (ClanShare on)."); } else { Utilities.SendSystemMessageToClient(Core.EntityManager, val, "Unable to search for items outside territories!"); } return; } string value = item.PrefabName(); string message = (flag ? ("Find Item Report — ClanShare ON\n" + FormatCurrentPlotLine(standingTerritoryId) + "\n--------------------------------") : ("Find Item Report\n" + FormatCurrentPlotLine(standingTerritoryId) + "\n--------------------------------")); Utilities.SendSystemMessageToClient(Core.EntityManager, val, message); ServerGameManager serverGameManager = Core.ServerGameManager; bool flag2 = false; int num = 0; foreach (int item4 in OrderPlotsCurrentFirst(logisticsTerritoryIdsForCharacter, standingTerritoryId)) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(item4); if (castleHeart == Entity.Null || !((ServerGameManager)(ref serverGameManager)).IsAllies(castleHeart, charEntity) || TerritoryService.IsHeartRaided(castleHeart)) { continue; } List<(Entity, int)> list = new List<(Entity, int)>(); foreach (Entity item5 in Core.Stash.ChestsOnPlot(item4)) { flag2 = true; if (StashRouting.TryGetExternalInventory(item5, out var inventory)) { int inventoryItemCount = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, item); if (inventoryItemCount > 0) { list.Add((item5, inventoryItemCount)); } } } bool flag3 = item4 == standingTerritoryId; if (list.Count == 0) { if (flag && flag3) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, "" + Core.TerritoryService.FormatPlotLabel(item4) + " (here): none"); } continue; } if (flag) { ReplyPlotHeader(val, item4, standingTerritoryId); } string value2 = (flag ? " " : ""); foreach (var item6 in list) { Entity item2 = item6.Item1; int item3 = item6.Item2; num += item3; Utilities.SendSystemMessageToClient(Core.EntityManager, val, $"{value2}{item3}x {value} found in {item2.EntityName()}"); glow.Mark(item2, userEntity); } } if (!flag2) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, flag ? "No available stashes found on clan plots!" : "No available stashes found in your current territory!"); return; } Utilities.SendSystemMessageToClient(Core.EntityManager, val, $"Total {value} found: {num}"); } public unsafe void Chests(Entity charEntity, string chestName) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) Entity userEntity = charEntity.Read().UserEntity; User val = userEntity.Read(); glow.Clear(userEntity); int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(charEntity); bool flag = Core.TerritoryService.IsClanShareOn(val); IReadOnlyList logisticsTerritoryIdsForCharacter = Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(charEntity); if (logisticsTerritoryIdsForCharacter.Count == 0) { if (flag) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, "Unable to search — no clan castles available (ClanShare on)."); } else { Utilities.SendSystemMessageToClient(Core.EntityManager, val, "Unable to search for chests outside territories!"); } return; } string message = (flag ? ("Find Chest Report — ClanShare ON\n" + FormatCurrentPlotLine(standingTerritoryId) + "\n--------------------------------") : ("Find Chest Report\n" + FormatCurrentPlotLine(standingTerritoryId) + "\n--------------------------------")); Utilities.SendSystemMessageToClient(Core.EntityManager, val, message); bool flag2 = false; int num = 0; string value = chestName.ToLower(); foreach (int item4 in OrderPlotsCurrentFirst(logisticsTerritoryIdsForCharacter, standingTerritoryId)) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(item4); if (castleHeart == Entity.Null) { continue; } ServerGameManager serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).IsAllies(castleHeart, charEntity) || TerritoryService.IsHeartRaided(castleHeart)) { continue; } List<(Entity, string)> list = new List<(Entity, string)>(); foreach (Entity item5 in Core.Stash.ChestsOnPlot(item4)) { NameableInteractable val2 = item5.Read(); string text = ((object)(*(FixedString64Bytes*)(&val2.Name))/*cast due to .constrained prefix*/).ToString(); if (text.ToLower().Contains(value)) { string item = text.Replace(chestName, "" + chestName + "", StringComparison.OrdinalIgnoreCase); list.Add((item5, item)); } } bool flag3 = item4 == standingTerritoryId; if (list.Count == 0) { if (flag && flag3) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, "" + Core.TerritoryService.FormatPlotLabel(item4) + " (here): none"); } continue; } flag2 = true; if (flag) { ReplyPlotHeader(val, item4, standingTerritoryId); } string text2 = (flag ? " " : ""); foreach (var item6 in list) { Entity item2 = item6.Item1; string item3 = item6.Item2; num++; Utilities.SendSystemMessageToClient(Core.EntityManager, val, text2 + "Found chest: " + item3 + ""); glow.Mark(item2, userEntity); } } if (!flag2) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, flag ? "No matching stashes found on clan plots!" : "No matching stashes found in your current territory!"); return; } Utilities.SendSystemMessageToClient(Core.EntityManager, val, $"Total chests matching {chestName}: {num}"); } } internal sealed class FindSpotlight { private static readonly PrefabGUID Glow = new PrefabGUID(-2014639169); private const float Seconds = 15f; private readonly Dictionary chests)> active = new Dictionary)>(); public void Clear(Entity userEntity) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!active.TryGetValue(userEntity, out (double, List) value)) { return; } active.Remove(userEntity); if (!(value.Item1 < Core.ServerTime)) { for (int i = 0; i < value.Item2.Count; i++) { Buffs.RemoveBuff(value.Item2[i], Glow); } } } public void Mark(Entity chest, Entity userEntity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!active.TryGetValue(userEntity, out (double, List) value)) { value = (Core.ServerTime + 15.0, new List()); active[userEntity] = value; } value.Item2.Add(chest); Buffs.RemoveAndAddBuff(userEntity, chest, Glow, 15f, delegate(Entity buff) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkedEntity localCharacter = userEntity.Read().LocalCharacter; buff.Write(new SpellTarget { Target = localCharacter }); buff.Write(new EntityOwner { Owner = ((NetworkedEntity)(ref localCharacter)).GetEntityOnServer() }); buff.Write(new EntityCreator { Creator = NetworkedEntity.op_Implicit(((NetworkedEntity)(ref localCharacter)).GetEntityOnServer()) }); }); } } internal sealed class HeartBoundIndex { private readonly Dictionary> buckets = new Dictionary>(); private readonly HashSet tracked = new HashSet(); private readonly bool skipDisabled; public HeartBoundIndex(bool skipDisabledWhenListing = true) { skipDisabled = skipDisabledWhenListing; } public static HeartBoundIndex Scan(bool includeDisabled, params ComponentType[] required) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) HeartBoundIndex heartBoundIndex = new HeartBoundIndex(); EntityQueryBuilder val = default(EntityQueryBuilder); ((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2)); if (includeDisabled) { ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); } for (int i = 0; i < required.Length; i++) { ((EntityQueryBuilder)(ref val)).AddAll(required[i]); } EntityManager entityManager = Core.EntityManager; EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val); ((EntityQueryBuilder)(ref val)).Dispose(); NativeArray val3 = default(NativeArray); try { val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int j = 0; j < val3.Length; j++) { heartBoundIndex.Track(val3[j]); } return heartBoundIndex; } finally { if (val3.IsCreated) { val3.Dispose(); } ((EntityQuery)(ref val2)).Dispose(); } } private static Entity HeartOf(Entity station) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!(station == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(station) && station.Has()) { CastleHeartConnection val = station.Read(); return ((NetworkedEntity)(ref val.CastleHeartEntity)).GetEntityOnServer(); } } return Entity.Null; } public void Track(Entity station) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (station == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(station) || !tracked.Add(station)) { return; } Entity val = HeartOf(station); if (val == Entity.Null) { tracked.Remove(station); return; } if (!buckets.TryGetValue(val, out var value)) { value = new List(); buckets[val] = value; } value.Add(station); } public void Untrack(Entity station) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (tracked.Remove(station)) { Entity val = HeartOf(station); if (!(val == Entity.Null) && buckets.TryGetValue(val, out var value)) { value.Remove(station); } } } public void Rebuild(bool includeDisabled, params ComponentType[] required) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) buckets.Clear(); tracked.Clear(); HeartBoundIndex heartBoundIndex = Scan(includeDisabled, required); foreach (KeyValuePair> bucket in heartBoundIndex.buckets) { buckets[bucket.Key] = bucket.Value; } foreach (Entity item in heartBoundIndex.tracked) { tracked.Add(item); } } public IEnumerable OnTerritory(int territoryId) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(territoryId); if (castleHeart == Entity.Null || !buckets.TryGetValue(castleHeart, out var list)) { yield break; } for (int i = list.Count - 1; i >= 0; i--) { Entity val = list[i]; if (!(val == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val)) { if (!skipDisabled || !val.Has()) { yield return val; } continue; } } list.RemoveAt(i); tracked.Remove(val); } } public IEnumerable OccupiedTerritoryIds() { foreach (Entity key in buckets.Keys) { if (key == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(key) || !key.Has()) { continue; } Entity castleTerritoryEntity = key.Read().CastleTerritoryEntity; if (!(castleTerritoryEntity == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleTerritoryEntity) && castleTerritoryEntity.Has()) { yield return castleTerritoryEntity.Read().CastleTerritoryIndex; } } } } } internal static class HuntLoginNote { private struct HaulRow { public DateTime Utc; public int Plot; public List<(string name, int amount)> Items; } private class FileDto { public Dictionary Logout { get; set; } public List Haul { get; set; } } private class HaulDto { public string Utc { get; set; } public int Plot { get; set; } public List Items { get; set; } } private class ItemDto { public string N { get; set; } public int A { get; set; } } private const int MaxAgeHours = 72; private const int MaxChat = 500; private static readonly TimeSpan MaxAge = TimeSpan.FromHours(72.0); private static readonly string PathFile = Path.Combine(Paths.ConfigPath, "Satisvampory", "hunt-haul.json"); private static readonly JsonSerializerOptions JsonOpts = new JsonSerializerOptions { WriteIndented = false }; private static readonly HashSet seen = new HashSet(); private static readonly Dictionary logoutAt = new Dictionary(); private static readonly List haul = new List(); private static bool loaded; private static bool seeded; public static IEnumerator Loop() { Load(); yield return (object)new WaitForSeconds(6f); SeedConnected(); WaitForSeconds wait = new WaitForSeconds(1f); while (true) { yield return wait; try { Tick(); } catch (Exception e) { Core.LogException(e, "HuntLoginNote"); } } } public static void FlushLogouts() { try { if (!Core.HasInitialized) { return; } Core.TerritoryService.EachUser(delegate(Entity _, User user) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (user.IsConnected) { logoutAt[user.PlatformId] = DateTime.UtcNow; } }); Save(); } catch { } } public static void RecordHaul(int plot, Dictionary loot) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (loot == null || loot.Count == 0) { return; } Load(); List<(string, int)> list = new List<(string, int)>(loot.Count); foreach (KeyValuePair item in loot) { if (item.Value > 0) { PrefabGUID key = item.Key; if (((PrefabGUID)(ref key)).GuidHash != 0) { list.Add((StashRouting.ItemLabel(item.Key), item.Value)); } } } if (list.Count != 0) { haul.Add(new HaulRow { Utc = DateTime.UtcNow, Plot = plot, Items = list }); Prune(); Save(); } } private static void SeedConnected() { seen.Clear(); Core.TerritoryService.EachUser(delegate(Entity _, User user) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (user.IsConnected) { seen.Add(user.PlatformId); } }); seeded = true; } private static void Tick() { //IL_0140: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { return; } Load(); HashSet now = new HashSet(); List joining = new List(); Core.TerritoryService.EachUser(delegate(Entity _, User user) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (user.IsConnected) { now.Add(user.PlatformId); if (seeded && !seen.Contains(user.PlatformId)) { joining.Add(user); } } }); foreach (ulong item in seen) { if (!now.Contains(item)) { logoutAt[item] = DateTime.UtcNow; } } if (seen.Count != now.Count) { Save(); } else { foreach (ulong item2 in now) { if (!seen.Contains(item2)) { Save(); break; } } } seen.Clear(); foreach (ulong item3 in now) { seen.Add(item3); } for (int num = 0; num < joining.Count; num++) { Core.StartCoroutine(NoteSoon(joining[num].PlatformId)); } } private static IEnumerator NoteSoon(ulong steamId) { yield return (object)new WaitForSeconds(3f); try { SendNote(steamId); } catch (Exception e) { Core.LogException(e, "HuntLoginNote.Send"); } } private static void SendNote(ulong steamId) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) User user = default(User); bool found = false; Core.TerritoryService.EachUser(delegate(Entity _, User u) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!found && u.IsConnected && u.PlatformId == steamId) { user = u; found = true; } }); if (!found) { return; } List list = PlotsFor(user); List list2 = new List(); for (int num = 0; num < list.Count; num++) { string text = PlotLine(list[num]); if (!string.IsNullOrEmpty(text)) { list2.Add(text); } } double hours; bool fromLogout; DateTime since = Since(steamId, out hours, out fromLogout); string text2 = HaulLine(list, since, hours, fromLogout); if (list2.Count == 0 && string.IsNullOrEmpty(text2)) { return; } if (list2.Count == 0) { Tell(user, text2); } else { for (int num2 = 0; num2 < list2.Count; num2++) { Tell(user, list2[num2]); } if (!string.IsNullOrEmpty(text2)) { Tell(user, text2); } } DestDebugLog.Note("throne", (list.Count > 0) ? list[0] : (-1), steamId, "login servants=" + list2.Count + " haulHours=" + hours.ToString("0.0", CultureInfo.InvariantCulture)); } private static List PlotsFor(User user) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) List plots = new List(); if (Core.TerritoryService.IsClanShareOn(user)) { IReadOnlyList clanLogisticsTerritoryIds = Core.TerritoryService.GetClanLogisticsTerritoryIds(user); if (clanLogisticsTerritoryIds != null && clanLogisticsTerritoryIds.Count > 0) { plots.AddRange(clanLogisticsTerritoryIds); plots.Sort(); return plots; } } Core.TerritoryService.EachKnownPlot(delegate(int id) { if (Core.TerritoryService.TryGetTerritoryOwnerPlatformId(id, out var platformId) && platformId == user.PlatformId) { plots.Add(id); } }); plots.Sort(); return plots; } private unsafe static string PlotLine(int plot) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) List list = new List(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val5) && val5.Has() && Core.TerritoryService.GetTerritoryId(val5) == plot) { ServantCoffinstation val6 = val5.Read(); string text = ((object)(*(FixedString64Bytes*)(&val6.ServantName))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrWhiteSpace(text) && (int)val6.State != 0) { list.Add(text + " " + StatusOf(val5, val6, plot)); } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } if (list.Count == 0) { return ""; } return "Servants (" + Core.TerritoryService.FormatPlotLabel(plot) + "): " + string.Join(", ", list); } private unsafe static string StatusOf(Entity coffin, ServantCoffinstation st, int plot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if ((int)st.State == 8) { return "dead"; } if ((int)st.State == 9) { return "reviving"; } Entity entityOnServer = ((NetworkedEntity)(ref st.ConnectedServant)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { if (((PrefabGUID)(ref st.Injury)).GuidHash != 0) { return "injured"; } if (TryHunt(entityOnServer, plot, out var dest, out var remain)) { string text = "hunt"; if (!string.IsNullOrWhiteSpace(dest)) { text = text + " " + dest; } if (remain >= 0.0) { text = text + " " + FormatRemain(remain); } return text; } return "home"; } } return ((object)(*(ServantCoffinState*)(&st.State))/*cast due to .constrained prefix*/).ToString(); } private static bool TryHunt(Entity servant, int plot, out string dest, out double remain) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) dest = ""; remain = -1.0; if (servant.Has() && !servant.Read().IsOnMission) { return false; } Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); if (castleHeart == Entity.Null || !castleHeart.Has()) { if (servant.Has()) { return servant.Read().IsOnMission; } return false; } DynamicBuffer val = castleHeart.ReadBuffer(); for (int i = 0; i < val.Length; i++) { ActiveServantMission val2 = val[i]; if (!(((NetworkedEntity)(ref val2.Servant1)).GetEntityOnServer() != servant) || !(((NetworkedEntity)(ref val2.Servant2)).GetEntityOnServer() != servant) || !(((NetworkedEntity)(ref val2.Servant3)).GetEntityOnServer() != servant)) { remain = Remain(val2); dest = RepeatHunts.DestForMission(val2.MissionID); return true; } } if (servant.Has()) { return servant.Read().IsOnMission; } return false; } private static double Remain(ActiveServantMission mission) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) long ticks = DateTime.UtcNow.Ticks; double num = (double)(mission.MissionStartTimeTicks + (long)(mission.MissionLengthSeconds * 10000000f) - ticks) / 10000000.0; if (double.IsNaN(num) || double.IsInfinity(num) || num > (double)(mission.MissionLengthSeconds + 120f)) { num = 0.0; } if (num < 0.0) { num = 0.0; } return num; } private static string FormatRemain(double seconds) { int num = (int)Math.Floor(seconds); if (num >= 3600) { return num / 3600 + "h " + num % 3600 / 60 + "m"; } if (num >= 60) { return num / 60 + "m"; } return num + "s"; } private static DateTime Since(ulong steamId, out double hours, out bool fromLogout) { DateTime utcNow = DateTime.UtcNow; DateTime dateTime = utcNow - MaxAge; fromLogout = logoutAt.TryGetValue(steamId, out var value) && value > dateTime; DateTime dateTime2 = (fromLogout ? value : dateTime); hours = (utcNow - dateTime2).TotalHours; if (hours < 0.0) { hours = 0.0; } return dateTime2; } private static string HaulLine(List plots, DateTime since, double hours, bool fromLogout) { HashSet hashSet = new HashSet(plots); Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); for (int i = 0; i < haul.Count; i++) { HaulRow haulRow = haul[i]; if (haulRow.Utc < since || (hashSet.Count > 0 && !hashSet.Contains(haulRow.Plot)) || haulRow.Items == null) { continue; } for (int j = 0; j < haulRow.Items.Count; j++) { (string, int) tuple = haulRow.Items[j]; if (!string.IsNullOrEmpty(tuple.Item1) && tuple.Item2 > 0) { dictionary.TryGetValue(tuple.Item1, out var value); dictionary[tuple.Item1] = value + tuple.Item2; } } } string text = (fromLogout ? ("since logout (" + FormatHours(hours) + ")") : ("last " + FormatHours(hours))); if (dictionary.Count == 0) { return "Haul " + text + ": none"; } List> list = new List>(dictionary); list.Sort((KeyValuePair a, KeyValuePair b) => b.Value.CompareTo(a.Value)); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Haul ").Append(text).Append(':'); int num = 0; for (int num2 = 0; num2 < list.Count; num2++) { string text2 = " " + list[num2].Value.ToString("N0", CultureInfo.InvariantCulture) + " " + list[num2].Key; if (num2 + 1 < list.Count) { text2 += ","; } if (stringBuilder.Length + text2.Length > 500) { stringBuilder.Append(" …"); break; } stringBuilder.Append(text2); num++; } return stringBuilder.ToString(); } private static string FormatHours(double hours) { if (hours < 1.0) { return Math.Max(1, (int)Math.Round(hours * 60.0)) + "m"; } if (hours < 10.0) { return hours.ToString("0.0", CultureInfo.InvariantCulture) + "h"; } return ((int)Math.Round(hours)).ToString(CultureInfo.InvariantCulture) + "h"; } private static void Tell(User user, string line) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(line) && user.IsConnected) { if (line.Length > 500) { line = line.Substring(0, 499) + "…"; } Utilities.SendSystemMessageToClient(Core.EntityManager, user, line); } } private static void Load() { if (loaded) { return; } loaded = true; try { if (!File.Exists(PathFile)) { return; } FileDto fileDto = JsonSerializer.Deserialize(File.ReadAllText(PathFile)); if (fileDto == null) { return; } if (fileDto.Logout != null) { foreach (KeyValuePair item in fileDto.Logout) { if (ulong.TryParse(item.Key, out var result) && DateTime.TryParse(item.Value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out var result2)) { logoutAt[result] = result2.ToUniversalTime(); } } } if (fileDto.Haul != null) { for (int i = 0; i < fileDto.Haul.Count; i++) { HaulDto haulDto = fileDto.Haul[i]; if (!DateTime.TryParse(haulDto.Utc, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out var result3)) { continue; } List<(string, int)> list = new List<(string, int)>(); if (haulDto.Items != null) { for (int j = 0; j < haulDto.Items.Count; j++) { ItemDto itemDto = haulDto.Items[j]; if (itemDto != null && !string.IsNullOrEmpty(itemDto.N) && itemDto.A > 0) { list.Add((itemDto.N, itemDto.A)); } } } haul.Add(new HaulRow { Utc = result3.ToUniversalTime(), Plot = haulDto.Plot, Items = list }); } } Prune(); } catch (Exception ex) { Core.Log.LogWarning((object)("HuntLoginNote load: " + ex.Message)); } } private static void Prune() { DateTime floor = DateTime.UtcNow - MaxAge; haul.RemoveAll((HaulRow r) => r.Utc < floor); List list = new List(); foreach (KeyValuePair item in logoutAt) { if (item.Value < floor) { list.Add(item.Key); } } for (int num = 0; num < list.Count; num++) { logoutAt.Remove(list[num]); } } private static void Save() { try { string directoryName = Path.GetDirectoryName(PathFile); if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } FileDto fileDto = new FileDto { Logout = new Dictionary(), Haul = new List(haul.Count) }; foreach (KeyValuePair item in logoutAt) { fileDto.Logout[item.Key.ToString(CultureInfo.InvariantCulture)] = item.Value.ToUniversalTime().ToString("o"); } for (int i = 0; i < haul.Count; i++) { HaulRow haulRow = haul[i]; List list = new List(); if (haulRow.Items != null) { for (int j = 0; j < haulRow.Items.Count; j++) { list.Add(new ItemDto { N = haulRow.Items[j].name, A = haulRow.Items[j].amount }); } } fileDto.Haul.Add(new HaulDto { Utc = haulRow.Utc.ToUniversalTime().ToString("o"), Plot = haulRow.Plot, Items = list }); } string text = PathFile + ".tmp"; File.WriteAllText(text, JsonSerializer.Serialize(fileDto, JsonOpts)); File.Copy(text, PathFile, overwrite: true); File.Delete(text); } catch (Exception ex) { Core.Log.LogDebug((object)("HuntLoginNote save: " + ex.Message)); } } } internal static class Il2CppEntity { private static EntityManager Em => Core.Server.EntityManager; public unsafe static void Write(Entity entity, T data) where T : struct { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); byte[] array = ToBytes(data); int num = Marshal.SizeOf(); fixed (byte* ptr = array) { EntityManager em = Em; ((EntityManager)(ref em)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num); } } private static byte[] ToBytes(T value) where T : struct { int num = Marshal.SizeOf(value); byte[] array = new byte[num]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(value, intPtr, fDeleteOld: true); Marshal.Copy(intPtr, array, 0, num); Marshal.FreeHGlobal(intPtr); return array; } public unsafe static T Read(Entity entity) where T : struct { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager em = Em; return Marshal.PtrToStructure(new IntPtr(((EntityManager)(ref em)).GetComponentDataRawRO(entity, val.TypeIndex))); } public static DynamicBuffer Buffer(Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) EntityManager em = Em; return ((EntityManager)(ref em)).GetBuffer(entity, false); } public static bool Has(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) EntityManager em = Em; return ((EntityManager)(ref em)).HasComponent(entity, new ComponentType(Il2CppType.Of(), (AccessMode)0)); } public static void Add(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) EntityManager em = Em; ((EntityManager)(ref em)).AddComponent(entity, new ComponentType(Il2CppType.Of(), (AccessMode)0)); } public static void Remove(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) EntityManager em = Em; ((EntityManager)(ref em)).RemoveComponent(entity, new ComponentType(Il2CppType.Of(), (AccessMode)0)); } public unsafe static string LookupName(PrefabGUID prefab) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) PrefabLookupMap prefabLookupMap = Core.Server.GetExistingSystemManaged()._PrefabLookupMap; string text = default(string); if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetName(prefab, ref text)) { return "GUID Not Found"; } string text2 = text; PrefabGUID val = prefab; return text2 + " " + ((object)(*(PrefabGUID*)(&val))/*cast due to .constrained prefix*/).ToString(); } public static string PrefabName(PrefabGUID prefab) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) string prefabName = Core.Localization.GetPrefabName(prefab); if (!string.IsNullOrEmpty(prefabName)) { return prefabName; } return LookupName(prefab); } public unsafe static string EntityName(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) NameableInteractable val = Il2CppEntity.Read(entity); string text = ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrEmpty(text) && Has(entity)) { text = PrefabName(Il2CppEntity.Read(entity)); } if (!string.IsNullOrEmpty(text)) { return text; } return ((object)(*(Entity*)(&entity))/*cast due to .constrained prefix*/).ToString(); } } internal static class InventoryCountService { public const int MinTerritoryId = 0; public const int MaxTerritoryId = 146; public static readonly PrefabGUID ChestBagGuid = new PrefabGUID(1183666186); public static int CountForCap(Entity character, User user, PrefabGUID item, CapMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) int num = CountInPlayerBags(character, item); if (mode != CapMode.Guild) { return num; } return num + CountInClanStashes(character, user, item); } public static int CountInPlayerBags(Entity character, PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (!InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, character, ref val, 0)) { return 0; } if (!(val == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val)) { ServerGameManager serverGameManager = Core.ServerGameManager; return ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(val, item); } } return 0; } public static bool TryGetPlayerInventory(Entity character, out Entity inventory) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) inventory = Entity.Null; if (InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, character, ref inventory, 0) && inventory != Entity.Null) { EntityManager entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).Exists(inventory); } return false; } public static HashSet GetCarriedGuidHashes(Entity character) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); if (!TryGetPlayerInventory(character, out var inventory)) { return hashSet; } ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val)) { return hashSet; } for (int i = 0; i < val.Length; i++) { InventoryBuffer val2 = val[i]; if (((PrefabGUID)(ref val2.ItemType)).GuidHash != 0) { val2 = val[i]; hashSet.Add(((PrefabGUID)(ref val2.ItemType)).GuidHash); } } return hashSet; } private static int CountInClanStashes(Entity character, User user, PrefabGUID item) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (int item2 in Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(character)) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(item2); if (!(castleHeart == Entity.Null)) { num += CountStashesOnHeart(castleHeart, item); } } return num; } private static int CountStashesOnHeart(Entity castleHeart, PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) if (!castleHeart.Has()) { return 0; } SharedCastleInventoryConnection val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.SharedInventoryManager)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasBuffer(entityOnServer)) { return 0; } int num = 0; entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(entityOnServer, false); DynamicBuffer val2 = default(DynamicBuffer); for (int i = 0; i < buffer.Length; i++) { Entity inventorySource = buffer[i].InventorySource; if (inventorySource == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(inventorySource) || inventorySource.Has() || inventorySource.Has()) { continue; } ServerGameManager serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventorySource, ref val2)) { continue; } for (int j = 0; j < val2.Length; j++) { Entity entity = val2[j].Entity; if (entity == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity) && entity.Has()) { PrefabGUID val3 = entity.Read(); if (((PrefabGUID)(ref val3)).Equals(ChestBagGuid)) { int num2 = num; serverGameManager = Core.ServerGameManager; num = num2 + ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(entity, item); } } } } return num; } } return 0; } } internal static class InventoryMove { public static bool IsExternalInventory(Entity child) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (child == Entity.Null || !child.Has()) { return false; } PrefabGUID val = child.Read(); return ((PrefabGUID)(ref val)).Equals(StashService.ChestBagGuid); } public static Dictionary> CollectOccupiedChests(int plot) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) Dictionary> dictionary = new Dictionary>(100); HashSet hashSet = new HashSet(32); ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); foreach (Entity item in Core.Stash.ChestsOnPlot(plot)) { if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item, ref val)) { continue; } int length = val.Length; int num = 0; while (num < length) { Entity entity = val[num++].Entity; if (!IsExternalInventory(entity)) { continue; } hashSet.Clear(); DynamicBuffer val2 = entity.ReadBuffer(); for (int i = 0; i < val2.Length; i++) { PrefabGUID itemType = val2[i].ItemType; if (((PrefabGUID)(ref itemType)).GuidHash != 0 && hashSet.Add(itemType)) { if (!dictionary.TryGetValue(itemType, out var value)) { value = (dictionary[itemType] = new List()); } value.Add(entity); } } } } return dictionary; } public static void DrainInventoryToMatches(Entity inventory, Dictionary> matches, List overflows) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val)) { return; } int slotIndex = 0; while (slotIndex < val.Length) { InventoryBuffer val2 = val[slotIndex]; PrefabGUID itemType = val2.ItemType; if (((PrefabGUID)(ref itemType)).IsEmpty()) { slotIndex++; continue; } ref NetworkedEntity itemEntity = ref val2.ItemEntity; object obj = NetworkedEntity.Empty; bool entityBacked = !((object)Unsafe.As(ref itemEntity)/*cast due to .constrained prefix*/).Equals(obj); int num = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, itemType); if (matches.TryGetValue(itemType, out var value)) { num = PushIntoList(serverGameManager, inventory, itemType, num, entityBacked, value, ref slotIndex); } if (num > 0) { num = PushIntoOverflows(serverGameManager, inventory, itemType, num, entityBacked, overflows, ref slotIndex); } slotIndex++; } } private static int PushIntoList(ServerGameManager sgm, Entity from, PrefabGUID item, int remaining, bool entityBacked, List dests, ref int slotIndex) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) int num = dests.Count; while (num > 0) { num--; Entity val = dests[num]; EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val)) { dests.RemoveAt(num); continue; } int num2 = (entityBacked ? RelocateEntities(from, val, item, remaining, ref slotIndex) : CopyStacks(sgm, from, val, item, remaining)); remaining -= num2; if (remaining <= 0) { break; } dests.RemoveAt(num); } return remaining; } private static int PushIntoOverflows(ServerGameManager sgm, Entity from, PrefabGUID item, int remaining, bool entityBacked, List overflows, ref int slotIndex) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (overflows == null || overflows.Count == 0) { return remaining; } ItemData data = default(ItemData); PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity entity = default(Entity); if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(item, ref entity)) { data = entity.Read(); } DynamicBuffer val = default(DynamicBuffer); foreach (Entity overflow in overflows) { EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(overflow) || !((ServerGameManager)(ref sgm)).TryGetBuffer(overflow, ref val)) { continue; } Enumerator enumerator2 = val.GetEnumerator(); while (enumerator2.MoveNext()) { InventoryInstanceElement current2 = enumerator2.Current; if (OverflowAccepts(current2, item, data)) { NetworkedEntity externalInventoryEntity = current2.ExternalInventoryEntity; Entity entityOnServer = ((NetworkedEntity)(ref externalInventoryEntity)).GetEntityOnServer(); int num = (entityBacked ? RelocateEntities(from, entityOnServer, item, remaining, ref slotIndex) : CopyStacks(sgm, from, entityOnServer, item, remaining)); remaining -= num; } } if (remaining <= 0) { break; } } return remaining; } private static bool OverflowAccepts(InventoryInstanceElement instance, PrefabGUID item, ItemData data) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (instance.RestrictedType != PrefabGUID.Empty && instance.RestrictedType != item) { return false; } if (instance.RestrictedCategory != 0L && (int)(instance.RestrictedCategory & data.ItemCategory) == 0) { return false; } return true; } public unsafe static void DrainInventoryByName(Entity territoryHint, Entity inventory, string overflowToken) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = Core.ServerGameManager; Dictionary> dictionary = new Dictionary>(100); (Entity, Entity) slot = (Entity.Null, Entity.Null); (Entity, Entity) slot2 = (Entity.Null, Entity.Null); try { int num = Core.TerritoryService.GetTerritoryId(territoryHint); if (num < 0) { num = Core.TerritoryService.GetStandingTerritoryId(territoryHint); } IEnumerable obj = ((num >= 0) ? Core.Stash.ChestsOnPlot(num) : Core.Stash.IslandChests(territoryHint)); if (num < 0) { DestDebugLog.Miss("servant", -1, default(PrefabGUID), 0, 0, "no-plot"); } foreach (Entity item in obj) { object obj2; if (!item.Has()) { obj2 = ""; } else { NameableInteractable val = item.Read(); obj2 = ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString().ToLower(); } string plate = (string)obj2; if (!TryClaimOverflow(serverGameManager, item, plate, overflowToken, ref slot)) { TryClaimOverflowDest(serverGameManager, item, plate, ref slot2); IndexChestContents(serverGameManager, item, dictionary); } } DynamicBuffer val2 = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val2)) { return; } for (int i = 0; i < val2.Length; i++) { PrefabGUID itemType = val2[i].ItemType; int num2 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, itemType); if (dictionary.TryGetValue(itemType, out var value)) { foreach (var item2 in value) { num2 -= CopyStacks(serverGameManager, inventory, item2.Item2, itemType, num2); if (num2 <= 0) { break; } } } if (num2 > 0 && slot.Item1 != Entity.Null) { num2 -= CopyStacks(serverGameManager, inventory, slot.Item2, itemType, num2); } if (num2 > 0 && slot2.Item1 != Entity.Null) { CopyStacks(serverGameManager, inventory, slot2.Item2, itemType, num2); } } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(23, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Servant stash aborted: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } log.LogError(val3); } } private static bool TryClaimOverflow(ServerGameManager sgm, Entity chest, string plate, string token, ref (Entity chest, Entity inv) slot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (slot.chest != Entity.Null) { return false; } if (string.IsNullOrEmpty(token) || !plate.Contains(token)) { return false; } Entity val = default(Entity); if (!InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, chest, ref val, 0)) { return true; } if (((ServerGameManager)(ref sgm)).HasFullInventory(val)) { return true; } slot = (chest: chest, inv: val); return true; } private static void TryClaimOverflowDest(ServerGameManager sgm, Entity chest, string plate, ref (Entity chest, Entity inv) slot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (!(slot.chest != Entity.Null) && StashRouting.IsOverflowDestName(plate) && InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, chest, ref val, 0) && !((ServerGameManager)(ref sgm)).HasFullInventory(val)) { slot = (chest: chest, inv: val); } } private static void IndexChestContents(ServerGameManager sgm, Entity chest, Dictionary> matches) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref sgm)).TryGetBuffer(chest, ref val)) { return; } Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity entity = enumerator.Current.Entity; if (!IsExternalInventory(entity)) { continue; } DynamicBuffer val2 = entity.ReadBuffer(); for (int i = 0; i < val2.Length; i++) { PrefabGUID itemType = val2[i].ItemType; if (((PrefabGUID)(ref itemType)).GuidHash == 0) { continue; } if (!matches.TryGetValue(itemType, out List<(Entity, Entity)> value)) { value = (matches[itemType] = new List<(Entity, Entity)>()); } else { bool flag = false; for (int j = 0; j < value.Count; j++) { if (value[j].Item1 == chest) { flag = true; break; } } if (flag) { continue; } } value.Add((chest, entity)); } } } public static int CopyStacks(ServerGameManager sgm, Entity from, Entity to, PrefabGUID item, int amount) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (amount <= 0) { return 0; } Core.WorkQueue?.BeginSelfTransfer(); try { if (!((ServerGameManager)(ref sgm)).TryRemoveInventoryItem(from, item, amount)) { return 0; } AddItemResponse val = ((ServerGameManager)(ref sgm)).TryAddInventoryItem(to, item, amount); int num; if ((int)val.Result == 0) { num = amount; } else { ((ServerGameManager)(ref sgm)).TryAddInventoryItem(from, item, val.RemainingAmount); num = amount - val.RemainingAmount; } if (num > 0 && to.Has() && (Core.WorkQueue == null || !Core.WorkQueue.IsSelfTransferring)) { Core.WorkQueue?.EnqueueOwner(to.Read().InventoryOwner); } return num; } finally { Core.WorkQueue?.EndSelfTransfer(); } } public static int RelocateEntities(Entity from, Entity to, PrefabGUID item, int amount, ref int destSlot) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (amount <= 0) { return 0; } int num = 0; Core.WorkQueue?.BeginSelfTransfer(); try { DynamicBuffer val = from.ReadBuffer(); DynamicBuffer dst = to.ReadBuffer(); for (int i = 0; i < val.Length; i++) { if (num >= amount) { break; } InventoryBuffer row = val[i]; if (((PrefabGUID)(ref row.ItemType)).Equals(item)) { if (!TryParkInEmpty(dst, ref destSlot, row, out var vacated)) { MarkEmptyIfNeeded(from); return num; } val[i] = vacated; BindContainer(row, to); destSlot++; num++; } } MarkEmptyIfNeeded(from); return num; } finally { if (num > 0 && to.Has()) { Core.WorkQueue?.EnqueueOwner(to.Read().InventoryOwner); } Core.WorkQueue?.EndSelfTransfer(); } } private static bool TryParkInEmpty(DynamicBuffer dst, ref int destSlot, InventoryBuffer row, out InventoryBuffer vacated) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) vacated = default(InventoryBuffer); while (destSlot < dst.Length) { InventoryBuffer val = dst[destSlot]; if (((PrefabGUID)(ref val.ItemType)).Equals(PrefabGUID.Empty)) { vacated = dst[destSlot]; dst[destSlot] = row; return true; } destSlot++; } return false; } private static void BindContainer(InventoryBuffer row, Entity destInventory) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Entity entityOnServer = ((NetworkedEntity)(ref row.ItemEntity)).GetEntityOnServer(); if (entityOnServer.Has()) { InventoryItem componentData = entityOnServer.Read(); componentData.ContainerEntity = destInventory; entityOnServer.Write(componentData); } } private static void MarkEmptyIfNeeded(Entity inventory) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) DynamicBuffer val = inventory.ReadBuffer(); for (int i = 0; i < val.Length; i++) { if (val[i].Amount != 0) { return; } } InventoryOwner componentData = inventory.Read(); componentData.HasItems = false; inventory.Write(componentData); Entity inventoryOwner = inventory.Read().InventoryOwner; InventoryOwner componentData2 = inventoryOwner.Read(); componentData2.HasItems = false; inventoryOwner.Write(componentData2); } public static AddItemSettings BuildAddSettings() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) AddItemSettings result = new AddItemSettings { EntityManager = Core.EntityManager }; ServerGameManager serverGameManager = Core.ServerGameManager; result.ItemDataMap = ((ServerGameManager)(ref serverGameManager)).ItemLookupMap; return result; } public static void Tell(EntityManager em, User user, string text) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) FixedString512Bytes val = default(FixedString512Bytes); ((FixedString512Bytes)(ref val))..ctor(text); ServerChatUtils.SendSystemMessageToClient(em, user, ref val); } public static bool EnclosedFloorsMatch(Entity room, CastleFloorTypes wanted) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Invalid comparison between Unknown and I4 if (!room.Has() || !room.Has()) { return false; } CastleRoom val = room.Read(); if (!((CastleRoom)(ref val)).IsEnclosedRoom) { return false; } EntityManager entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(room, false); int length = buffer.Length; for (int i = 0; i < length; i++) { CastleRoomFloorsBuffer val2 = buffer[i]; Entity entityOnServer = ((NetworkedEntity)(ref val2.FloorEntity)).GetEntityOnServer(); if (!((Entity)(ref entityOnServer)).Equals(Entity.Null)) { if (!entityOnServer.Has()) { return false; } CastleFloorTypes floorType = entityOnServer.Read().FloorType; if (floorType != wanted || (int)floorType == 13) { return false; } } } return true; } } internal static class ItemGroupService { public readonly record struct GroupMember(PrefabGUID Prefab, string Name, int GuidHash); public const string GroupOre = "ore"; public const string GroupFlowers = "flowers"; public const string GroupMushrooms = "mushrooms"; public const string GroupTailoring = "tailoring"; public const string GroupHides = "hides"; public const string GroupWood = "wood"; public const string GroupGems = "gems"; public const string GroupAlchemy = "alchemy"; public const string GroupBlood = "blood"; public const string GroupBones = "bones"; public const string GroupIngots = "ingots"; public const string GroupPlanks = "planks"; public const string GroupStone = "stone"; public const string GroupCoins = "coins"; public const string GroupFish = "fish"; public const string GroupKnowledge = "knowledge"; public const string GroupMinerals = "minerals"; public const string GroupConsumables = "consumables"; public const string GroupWeapons = "weapons"; public const string GroupArmor = "armor"; public const string GroupJewels = "jewels"; public const string GroupMagic = "magic"; public const string GroupSoulshards = "soulshards"; public const string GroupBags = "bags"; public const string GroupSaddles = "saddles"; public const string GroupRelics = "relics"; private static readonly Dictionary builtInCanonical = new Dictionary(StringComparer.OrdinalIgnoreCase) { ["ore"] = "ore", ["flowers"] = "flowers", ["herb"] = "flowers", ["herbs"] = "flowers", ["mushrooms"] = "mushrooms", ["tailoring"] = "tailoring", ["thread"] = "tailoring", ["threads"] = "tailoring", ["hides"] = "hides", ["hide"] = "hides", ["leather"] = "hides", ["leathers"] = "hides", ["wood"] = "wood", ["gems"] = "gems", ["gem"] = "gems", ["alchemy"] = "alchemy", ["blood"] = "blood", ["bones"] = "bones", ["bone"] = "bones", ["ingots"] = "ingots", ["ingot"] = "ingots", ["planks"] = "planks", ["plank"] = "planks", ["stone"] = "stone", ["stones"] = "stone", ["coins"] = "coins", ["coin"] = "coins", ["fish"] = "fish", ["knowledge"] = "knowledge", ["scroll"] = "knowledge", ["scrolls"] = "knowledge", ["paper"] = "knowledge", ["book"] = "knowledge", ["books"] = "knowledge", ["minerals"] = "minerals", ["mineral"] = "minerals", ["material"] = "minerals", ["materials"] = "minerals", ["tech"] = "minerals", ["consumables"] = "consumables", ["consumable"] = "consumables", ["potion"] = "consumables", ["potions"] = "consumables", ["weapons"] = "weapons", ["weapon"] = "weapons", ["armor"] = "armor", ["armour"] = "armor", ["jewels"] = "jewels", ["jewel"] = "jewels", ["magic"] = "magic", ["soulshards"] = "soulshards", ["soulshard"] = "soulshards", ["shard"] = "soulshards", ["shards"] = "soulshards", ["bags"] = "bags", ["bag"] = "bags", ["saddles"] = "saddles", ["saddle"] = "saddles", ["relics"] = "relics", ["relic"] = "relics" }; private static readonly Dictionary> builtInMembers = new Dictionary>(StringComparer.OrdinalIgnoreCase); private static readonly List missingRequested = new List(); private static readonly Dictionary destGroupByHash = new Dictionary(); private static readonly List catalogRows = new List(); private static readonly Dictionary exactAliasToHash = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly HashSet builtInAliasKeys = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary catalogAliasByHash = new Dictionary(); public static int BloodEssenceHash { get; private set; } public static int GreaterBloodEssenceHash { get; private set; } public static int PrimalBloodEssenceHash { get; private set; } public static int AncestralBloodEssenceHash { get; private set; } public static IReadOnlyList MissingRequestedNames => missingRequested; public static IEnumerable BuiltInNames => new string[26] { "ore", "flowers", "mushrooms", "tailoring", "hides", "wood", "planks", "gems", "alchemy", "blood", "bones", "ingots", "stone", "coins", "fish", "knowledge", "minerals", "consumables", "weapons", "armor", "jewels", "magic", "soulshards", "bags", "saddles", "relics" }; public static bool IsGreaterBloodEssence(PrefabGUID item) { if (((PrefabGUID)(ref item)).GuidHash != 0 && GreaterBloodEssenceHash != 0) { return ((PrefabGUID)(ref item)).GuidHash == GreaterBloodEssenceHash; } return false; } public static bool TryExactEssenceAlias(string s, out int hash) { return TryExactItemAlias(s, out hash); } public static bool TryExactItemAlias(string s, out int hash) { hash = 0; if (string.IsNullOrWhiteSpace(s)) { return false; } if (exactAliasToHash.TryGetValue(FoundItemConverter.Normalize(s), out hash)) { return hash != 0; } return false; } public static bool IsBuiltInAlias(string alias) { if (!string.IsNullOrWhiteSpace(alias)) { return builtInAliasKeys.Contains(FoundItemConverter.Normalize(alias)); } return false; } public static bool IsReservedAlias(string alias) { if (string.IsNullOrWhiteSpace(alias)) { return true; } string text = FoundItemConverter.Normalize(alias); if (text.Length < 2 || text.Length > 16) { return true; } if (text.IndexOf(' ') >= 0) { return true; } if (TryGetBuiltInCanonical(text, out var _)) { return true; } bool flag; switch (text) { case "spoil": case "trash": case "salvage": case "storage": case "overflow": case "spoils": case "ns": flag = true; break; default: flag = false; break; } if (flag) { return true; } if (text.Length >= 2 && (text[0] == 's' || text[0] == 'r') && text.Skip(1).All(char.IsDigit)) { return true; } return false; } public static IReadOnlyList<(string Alias, string Name, bool BuiltIn)> ListExactAliases() { List<(string, string, bool)> rows = new List<(string, string, bool)>(); HashSet seen = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (string builtInAliasKey in builtInAliasKeys) { if (exactAliasToHash.TryGetValue(builtInAliasKey, out var value)) { Add(builtInAliasKey, value, builtIn: true); } } if (Core.PlayerSettings.TryItemAliases(out var map, out var names) && map != null) { foreach (KeyValuePair item3 in map) { string value2; string item = ((names != null && names.TryGetValue(item3.Key, out value2)) ? value2 : item3.Key); if (!seen.Contains(item3.Key)) { rows.Add((item3.Key, item, false)); } } } rows.Sort(((string, string, bool) a, (string, string, bool) b) => string.Compare(a.Item1, b.Item1, StringComparison.OrdinalIgnoreCase)); return rows; void Add(string alias, int hash, bool builtIn) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrWhiteSpace(alias) && hash != 0 && seen.Add(alias)) { string value3; string text = (catalogAliasByHash.TryGetValue(hash, out value3) ? value3 : alias); if (FoundItemConverter.TryGetExact(alias, out var item2)) { PrefabGUID prefab = item2.prefab; if (((PrefabGUID)(ref prefab)).GuidHash == hash) { text = item2.prefab.PrefabName() ?? text; } } rows.Add((alias, text, builtIn)); } } } public static bool TryGetDestGroup(int guidHash, out string group) { if (destGroupByHash.TryGetValue(guidHash, out group)) { return !string.IsNullOrEmpty(group); } return false; } public static bool IsMachineSpendItem(int guidHash) { if (guidHash == 0 || !TryGetDestGroup(guidHash, out var group)) { return false; } if (group != "weapons" && group != "armor" && group != "jewels" && group != "magic" && group != "bags" && group != "saddles" && group != "relics") { return group != "soulshards"; } return false; } public static bool IsFishOrFeedPlaceholder(string prefab, string loc) { return IsRecipePlaceholder(prefab, loc); } public static bool IsGbeAliasText(string s) { if (TryExactEssenceAlias(s, out var hash)) { return hash == GreaterBloodEssenceHash; } return false; } public static string CatalogAliases(int guidHash) { if (guidHash == 0) { return ""; } if (catalogAliasByHash.TryGetValue(guidHash, out var value)) { return value; } return ""; } public static void Initialize() { builtInMembers.Clear(); missingRequested.Clear(); destGroupByHash.Clear(); catalogRows.Clear(); BloodEssenceHash = 0; GreaterBloodEssenceHash = 0; PrimalBloodEssenceHash = 0; AncestralBloodEssenceHash = 0; exactAliasToHash.Clear(); builtInAliasKeys.Clear(); catalogAliasByHash.Clear(); foreach (string builtInName in BuiltInNames) { builtInMembers[builtInName] = new List(); } ScanPrefabCollection(); ResolveNamedItem("Blood Essence", "BE", delegate(int v) { BloodEssenceHash = v; }); ResolveNamedItem("Greater Blood Essence", "GBE", delegate(int v) { GreaterBloodEssenceHash = v; }, "greater blood"); ResolveNamedItem("Primal Blood Essence", "PBE", delegate(int v) { PrimalBloodEssenceHash = v; }, "primal blood"); ResolveNamedItem("Ancestral Blood Essence", "ABE", delegate(int v) { AncestralBloodEssenceHash = v; }, "ancestral blood"); ResolveNamedItem("Greater Stygian Shard", "GSS", null, "greater stygian"); ResolveNamedItem("Greater Stygian Shards", "GSS", null, "greater stygian"); ResolveNamedItem("Siege Golem Stone", "SGS", null); ResolveNamedItem("Dark Silver Ingot", "DSI", null, "dark silver"); ResolveNamedItem("Onyx Tear", "OT", null); ApplyAdminAliases(); foreach (KeyValuePair> builtInMember in builtInMembers) { string text = string.Join(", ", builtInMember.Value.Select((GroupMember m) => m.Name + " (" + m.GuidHash + ")")); Core.Log.LogInfo((object)("Item group '" + builtInMember.Key + "' (" + builtInMember.Value.Count + "): " + text)); } DumpItemCatalog(); if (missingRequested.Count > 0) { Core.Log.LogWarning((object)("Item groups unresolved " + missingRequested.Count + " ItemData names: " + string.Join(", ", missingRequested))); } Core.Log.LogInfo((object)("Item aliases BE=" + BloodEssenceHash + " GBE=" + GreaterBloodEssenceHash + " PBE=" + PrimalBloodEssenceHash + " ABE=" + AncestralBloodEssenceHash + " (dest works without item-catalog.csv)")); } private static void ResolveNamedItem(string locName, string alias, Action setHash, params string[] extraAliases) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (!TryFindItemPrefab(locName, alias, out var prefab)) { Core.Log.LogWarning((object)(alias + " alias: " + locName + " not found in PrefabCollection by name")); if (string.Equals(alias, "ABE", StringComparison.OrdinalIgnoreCase)) { LogEssenceItemCandidates(); } return; } setHash?.Invoke(((PrefabGUID)(ref prefab)).GuidHash); BindAlias(alias, prefab, builtIn: true); BindAlias(locName, prefab, builtIn: true); if (extraAliases != null) { for (int i = 0; i < extraAliases.Length; i++) { BindAlias(extraAliases[i], prefab, builtIn: true); } } } private static bool TryFindItemPrefab(string locName, string alias, out PrefabGUID prefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) prefab = default(PrefabGUID); PrefabGUID val; if (FoundItemConverter.TryGetExact(locName, out var item)) { val = item.prefab; if (((PrefabGUID)(ref val)).GuidHash != 0 && FoundItemConverter.Normalize(item.prefab.PrefabName() ?? "").Equals(locName, StringComparison.OrdinalIgnoreCase)) { prefab = item.prefab; return true; } } if (FoundItemConverter.ExactItemNames != null) { foreach (KeyValuePair exactItemName in FoundItemConverter.ExactItemNames) { if (exactItemName.Key.Equals(locName, StringComparison.OrdinalIgnoreCase)) { val = exactItemName.Value; if (((PrefabGUID)(ref val)).GuidHash != 0) { prefab = exactItemName.Value; return true; } } } } string want = FoundItemConverter.Normalize(locName); if (TryMatchSpawnable(want, alias, out prefab)) { return true; } if (TryMatchItemDataPrefabs(want, alias, out prefab)) { return true; } return false; } private static bool AliasSpawnMatch(string want, string alias, string spawn, string loc) { string text = FoundItemConverter.Normalize(spawn ?? ""); if (FoundItemConverter.Normalize(loc ?? "").Equals(want, StringComparison.OrdinalIgnoreCase) || text.Equals(want, StringComparison.OrdinalIgnoreCase)) { return true; } string text2 = (spawn ?? "").Replace(" ", "").ToLowerInvariant(); if ((alias ?? "").ToLowerInvariant() == "abe") { if (text2.IndexOf("bloodessence", StringComparison.Ordinal) >= 0 && text2.IndexOf("ancestral", StringComparison.Ordinal) >= 0) { return true; } if (text2.IndexOf("item_bloodessence_t04", StringComparison.Ordinal) >= 0) { return true; } } return false; } private static bool TryMatchSpawnable(string want, string alias, out PrefabGUID prefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) prefab = default(PrefabGUID); if (Core.PrefabCollectionSystem == null) { return false; } try { Enumerator enumerator = Core.PrefabCollectionSystem._SpawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; PrefabGUID value = current.Value; if (((PrefabGUID)(ref value)).GuidHash != 0) { string text = current.Key ?? ""; string text2 = ""; try { text2 = current.Value.PrefabName() ?? ""; } catch { text2 = ""; } if (AliasSpawnMatch(want, alias, text, text2) && PrefabHasItemData(current.Value)) { prefab = current.Value; Core.Log.LogInfo((object)(alias + " alias matched spawn " + text + " guid=" + ((PrefabGUID)(ref prefab)).GuidHash + " loc=" + text2)); return true; } } } } catch (Exception ex) { Core.Log.LogWarning((object)(alias + " alias spawnable scan: " + ex.Message)); } return false; } private static bool TryMatchItemDataPrefabs(string want, string alias, out PrefabGUID prefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) prefab = default(PrefabGUID); EntityManager entityManager = Core.EntityManager; EntityManager val = default(EntityManager); if (entityManager == val) { return false; } EntityQueryBuilder val2 = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityQueryBuilder val3 = ((EntityQueryBuilder)(ref val2)).WithOptions((EntityQueryOptions)3); val = Core.EntityManager; EntityQuery val4 = ((EntityManager)(ref val)).CreateEntityQuery(ref val3); ((EntityQueryBuilder)(ref val3)).Dispose(); NativeArray val5 = default(NativeArray); try { val5 = ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val5.Length; i++) { Entity val6 = val5[i]; if (val6 == Entity.Null || !val6.Has()) { continue; } PrefabGUID val7 = val6.Read(); if (((PrefabGUID)(ref val7)).GuidHash != 0) { string text = ""; try { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; ((PrefabLookupMap)(ref prefabLookupMap)).TryGetName(val7, ref text); } catch { text = ""; } string text2 = ""; try { text2 = val7.PrefabName() ?? ""; } catch { text2 = ""; } if (AliasSpawnMatch(want, alias, text, text2)) { prefab = val7; Core.Log.LogInfo((object)(alias + " alias matched ItemData " + text + " guid=" + ((PrefabGUID)(ref val7)).GuidHash + " loc=" + text2)); return true; } } } } catch (Exception ex) { Core.Log.LogWarning((object)(alias + " alias ItemData scan: " + ex.Message)); } finally { if (val5.IsCreated) { val5.Dispose(); } ((EntityQuery)(ref val4)).Dispose(); } return false; } private static bool PrefabHasItemData(PrefabGUID prefab) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) try { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity val = default(Entity); return ((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(prefab, ref val) && val != Entity.Null && val.Has(); } catch { return false; } } private static void LogEssenceItemCandidates() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (Core.PrefabCollectionSystem == null) { return; } int num = 0; try { Enumerator enumerator = Core.PrefabCollectionSystem._SpawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; string text = current.Key ?? ""; if ((text.IndexOf("Essence", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Ancestral", StringComparison.OrdinalIgnoreCase) >= 0) && PrefabHasItemData(current.Value)) { string text2 = ""; try { text2 = current.Value.PrefabName() ?? ""; } catch { } ManualLogSource log = Core.Log; string[] obj2 = new string[6] { "ABE candidate spawn=", text, " guid=", null, null, null }; PrefabGUID value = current.Value; obj2[3] = ((PrefabGUID)(ref value)).GuidHash.ToString(); obj2[4] = " loc="; obj2[5] = text2; log.LogInfo((object)string.Concat(obj2)); num++; if (num >= 40) { break; } } } } catch (Exception ex) { Core.Log.LogWarning((object)("ABE candidate scan: " + ex.Message)); } } private static void BindAlias(string alias, PrefabGUID prefab, bool builtIn) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(alias) || ((PrefabGUID)(ref prefab)).GuidHash == 0) { return; } string text = FoundItemConverter.Normalize(alias); if (!string.IsNullOrEmpty(text)) { FoundItemConverter.RegisterExactAlias(alias, prefab); exactAliasToHash[text] = ((PrefabGUID)(ref prefab)).GuidHash; if (builtIn) { builtInAliasKeys.Add(text); } if (text.Length <= 4 && text.IndexOf(' ') < 0) { catalogAliasByHash[((PrefabGUID)(ref prefab)).GuidHash] = alias.ToUpperInvariant(); } } } public static void ApplyAdminAliases() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!Core.PlayerSettings.TryItemAliases(out var map, out var _) || map == null) { return; } PrefabGUID prefab = default(PrefabGUID); foreach (KeyValuePair item in map) { if (!string.IsNullOrWhiteSpace(item.Key) && item.Value != 0 && !builtInAliasKeys.Contains(FoundItemConverter.Normalize(item.Key))) { ((PrefabGUID)(ref prefab))..ctor(item.Value); FoundItemConverter.RegisterExactAlias(item.Key, prefab); exactAliasToHash[FoundItemConverter.Normalize(item.Key)] = item.Value; } } } public static string BindAdminAlias(string alias, PrefabGUID prefab, string displayName) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) string text = FoundItemConverter.Normalize(alias); if (IsReservedAlias(text)) { return "Alias must be 2–16 letters/digits with no spaces, and cannot be a dest word (blood, stone, salvage, s1, …)."; } if (builtInAliasKeys.Contains(text)) { return "Cannot overwrite built-in alias " + text + "."; } if (((PrefabGUID)(ref prefab)).GuidHash == 0) { return "Unknown item."; } string text2 = Core.PlayerSettings.SetItemAlias(text, ((PrefabGUID)(ref prefab)).GuidHash, displayName); if (!string.IsNullOrEmpty(text2)) { return text2; } FoundItemConverter.RegisterExactAlias(text, prefab); exactAliasToHash[text] = ((PrefabGUID)(ref prefab)).GuidHash; return null; } public static string UnbindAdminAlias(string alias) { string text = FoundItemConverter.Normalize(alias); if (builtInAliasKeys.Contains(text)) { return "Cannot delete built-in alias " + text + "."; } if (!Core.PlayerSettings.RemoveItemAlias(text)) { return "No admin alias " + text + "."; } FoundItemConverter.UnregisterExactAlias(text); exactAliasToHash.Remove(text); return null; } private static void ScanPrefabCollection() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) HashSet seen = new HashSet(); if (Core.PrefabCollectionSystem == null) { Core.Log.LogWarning((object)"Item groups: PrefabCollectionSystem is null; dest catalog empty this boot"); return; } try { Enumerator enumerator = Core.PrefabCollectionSystem._SpawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; ConsiderPrefab(current.Key, current.Value, seen); } } catch (Exception ex) { Core.Log.LogWarning((object)("Item groups spawnable scan failed: " + ex.Message)); } } private unsafe static void ConsiderPrefab(string prefabName, PrefabGUID prefab, HashSet seen) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected I8, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (((PrefabGUID)(ref prefab)).GuidHash == 0 || !seen.Add(((PrefabGUID)(ref prefab)).GuidHash)) { return; } Entity val = Entity.Null; ItemCategory val2 = (ItemCategory)0; try { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(prefab, ref val) || !(val != Entity.Null) || !val.Has()) { return; } val2 = val.Read().ItemCategory; } catch { return; } string text = ""; try { text = prefab.PrefabName() ?? ""; } catch { text = ""; } if (string.IsNullOrEmpty(text) || text.IndexOf("GUID Not Found", StringComparison.OrdinalIgnoreCase) >= 0) { text = prefabName ?? ""; } if (ShouldSkipPrefab(prefabName, text)) { return; } string text2 = AssignDestGroup(prefabName ?? "", text, val2); string s = ""; long num = 0L; try { num = (long)val2; s = ((object)(*(ItemCategory*)(&val2))/*cast due to .constrained prefix*/).ToString(); } catch { } if (!string.IsNullOrEmpty(text2)) { destGroupByHash[((PrefabGUID)(ref prefab)).GuidHash] = text2; AddMember(text2, prefab, text); foreach (string item in ExtraDestGroups(prefabName ?? "", text, text2)) { AddMember(item, prefab, text); } } else if (!IsRecipePlaceholder(prefabName, text)) { missingRequested.Add((string.IsNullOrEmpty(text) ? prefabName : text) + " [" + prefabName + " " + ((PrefabGUID)(ref prefab)).GuidHash + "]"); } catalogRows.Add(string.Join(",", Csv(prefabName ?? ""), Csv(text), ((PrefabGUID)(ref prefab)).GuidHash.ToString(), Csv(s), num.ToString(), Csv(text2 ?? ""), Csv(CatalogAliases(((PrefabGUID)(ref prefab)).GuidHash)))); } private static bool ShouldSkipPrefab(string prefab, string loc) { string text = prefab ?? ""; if (text.Length == 0) { return true; } if (text.EndsWith("_Base", StringComparison.OrdinalIgnoreCase) || text.EndsWith("_Trader_Template", StringComparison.OrdinalIgnoreCase) || text.EndsWith("_Debug", StringComparison.OrdinalIgnoreCase)) { return true; } if (text.StartsWith("Item_Any", StringComparison.OrdinalIgnoreCase) || text.StartsWith("Item_Dummy", StringComparison.OrdinalIgnoreCase) || text.StartsWith("Item_EquipBuff", StringComparison.OrdinalIgnoreCase) || text.StartsWith("Item_Base_", StringComparison.OrdinalIgnoreCase)) { return true; } if (text.IndexOf("MapZone", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("CastleKey", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("CastleUpkeep", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("PaintingFrame", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Transmog", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (text.IndexOf("_Kit_", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("_Passive_", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (text.StartsWith("Item_Building_", StringComparison.OrdinalIgnoreCase)) { string text2 = text.ToLowerInvariant(); if (text2.Contains("explosive") || text2.Contains("emp") || text2.Contains("plants") || text2.Contains("sapling")) { return false; } return true; } return false; } private static void AddMember(string group, PrefabGUID prefab, string loc) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(group)) { if (!builtInMembers.TryGetValue(group, out var value)) { value = new List(); builtInMembers[group] = value; } if (!value.Any((GroupMember m) => m.GuidHash == ((PrefabGUID)(ref prefab)).GuidHash)) { value.Add(new GroupMember(prefab, loc, ((PrefabGUID)(ref prefab)).GuidHash)); } } } private static IEnumerable ExtraDestGroups(string prefabName, string locName, string primary) { string pl = (prefabName ?? "").ToLowerInvariant(); string nl = (locName ?? "").ToLowerInvariant(); if ((pl.Contains("claymold") || nl.Contains("clay mold")) && primary != "minerals") { yield return "minerals"; } if ((pl.Contains("copperwires") || nl.Contains("copper wire")) && primary != "ingots") { yield return "ingots"; } } private static bool IsRecipePlaceholder(string prefab, string loc) { string text = prefab ?? ""; string text2 = loc ?? ""; if (text.StartsWith("FakeItem_", StringComparison.OrdinalIgnoreCase)) { return true; } if (text.StartsWith("Item_Any", StringComparison.OrdinalIgnoreCase)) { return true; } string text3 = text2.Trim(); if (text3.StartsWith("Any ", StringComparison.OrdinalIgnoreCase) || text3.Equals("Any", StringComparison.OrdinalIgnoreCase)) { return true; } if (text3.Equals("Feed Prisoner", StringComparison.OrdinalIgnoreCase)) { return true; } return false; } private static bool ContainsFold(string hay, string needle) { if (string.IsNullOrEmpty(hay) || string.IsNullOrEmpty(needle)) { return false; } return hay.IndexOf(needle, StringComparison.OrdinalIgnoreCase) >= 0; } private static bool IsHeartAlchemyName(string loc, string prefab) { string hay = prefab ?? ""; string hay2 = loc ?? ""; if (ContainsFold(hay, "Item_Consumable_Heart")) { return true; } if (ContainsFold(hay2, "Bleeding Heart")) { return false; } if (!ContainsFold(hay2, "Tainted Heart") && !ContainsFold(hay2, "Unsullied Heart") && !ContainsFold(hay2, "Exquisite Heart") && !ContainsFold(hay2, "Pristine Heart")) { return ContainsFold(hay2, "Defiled Heart"); } return true; } private static bool IsAlchemyReagentName(string loc, string prefab) { string[] obj = new string[16] { "grave dust", "gravedust", "scourgestone", "scourge stone", "spectral dust", "spectraldust", "witchdust", "witch dust", "vampiric dust", "vampiricdust", "demon fragment", "demonfragment", "mutant grease", "mutantgrease", "onyx tear", "onyxtear" }; string hay = loc + " " + prefab; string[] array = obj; foreach (string needle in array) { if (ContainsFold(hay, needle)) { return true; } } return false; } private static bool IsExplosiveOrEmp(string loc, string prefab) { string hay = loc + " " + prefab; if (ContainsFold(hay, "explosive box") || ContainsFold(hay, "explosivebox") || ContainsFold(hay, "explosives")) { return true; } if (ContainsFold(prefab ?? "", "Item_Building_EMP")) { return true; } string text = FoundItemConverter.Normalize(loc ?? ""); if (!text.Equals("emp", StringComparison.OrdinalIgnoreCase) && !text.Equals("minor explosive box", StringComparison.OrdinalIgnoreCase)) { return text.Equals("major explosive box", StringComparison.OrdinalIgnoreCase); } return true; } private static string AssignDestGroup(string prefabName, string locName, ItemCategory cat) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_0660: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_0690: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) string text = prefabName ?? ""; string text2 = locName ?? ""; string text3 = text.ToLowerInvariant(); string text4 = text2.ToLowerInvariant(); if ((cat & 1) != 0 || text3.StartsWith("item_weapon_")) { return "weapons"; } if (text3.StartsWith("item_magicsource_soulshard") || text4.StartsWith("soul shard") || (cat & 0x40000000) != 0) { return "soulshards"; } if (text3.StartsWith("item_newbag_") || (cat & 0x40000) != 0) { return "bags"; } if (text3.StartsWith("item_saddle_") || (cat & 0x80000) != 0) { return "saddles"; } if ((cat & 0x4000) != 0 || text3.Contains("_relic")) { return "relics"; } if (text3.Equals("item_ingredient_crystal") || text4.Equals("crystal")) { if ((cat & 0x4000000) == 0) { return "gems"; } return "minerals"; } if (text3.Contains("copperwires") || text4.Contains("copper wire")) { return "minerals"; } if (text3.Equals("item_ingredient_coal") || text4.Equals("coal")) { return "minerals"; } if (text3.Equals("item_ingredient_chitin") || text3.Equals("item_ingredient_scales") || text4.Equals("chitin") || text4.Equals("scales")) { return "minerals"; } if (text3.Contains("claymold") || text4.Contains("clay mold")) { return "alchemy"; } if (text3.Contains("ironbody") || text4.Equals("iron body")) { return "ingots"; } if (text3.Equals("item_ingredient_document") || text4.Equals("document")) { return "knowledge"; } if (text3.Contains("barreldisguise") || text4.Contains("barrel disguise")) { return "consumables"; } if ((cat & 0x80) != 0 || text4.Contains("blood essence") || text3.Contains("bloodessence")) { return "blood"; } if ((cat & 0x8000) != 0 || text4.Contains("coin") || text3.Contains("coin")) { return "coins"; } if ((cat & 0x1000) != 0) { return "knowledge"; } if (text4.Contains("gem dust") || text4.Contains("gemdust") || text3.Contains("gemdust")) { return "gems"; } if ((cat & 4) != 0) { return "gems"; } if (text4.Contains("radium") || text3.Contains("radium")) { return "ingots"; } if (text3.Contains("nethershard") || text4.Contains("stygian shard")) { return "alchemy"; } if (IsHeartAlchemyName(text2, text)) { return "alchemy"; } if (IsAlchemyReagentName(text2, text)) { return "alchemy"; } if (IsExplosiveOrEmp(text2, text)) { return "alchemy"; } if ((cat & 2) != 0) { return "armor"; } if ((cat & 0x800000) != 0) { return "jewels"; } if ((cat & 0x10000000) != 0) { return "magic"; } if ((cat & 0x100000) != 0 || text3.Contains("item_ingredient_fish") || text3.Contains("_fish_")) { if (text4.Contains("fish bone") || text4.Contains("fishbone") || text3.Contains("fishbone")) { return "bones"; } if (text4.Contains("fish oil") || text3.Contains("fishoil")) { return "minerals"; } return "fish"; } if (text4.Contains("shroom") || text4.Contains("mushroom") || text4.Contains("clarion") || text3.Contains("shroom") || text3.Contains("hellsclarion") || text3.Contains("clarion")) { return "mushrooms"; } if (text4.Contains("hide") || text4.Contains("leather") || text3.Contains("hide") || text3.Contains("leather")) { return "hides"; } if (text4.Contains("bone") || text3.Contains("bone")) { return "bones"; } if (text4.EndsWith(" ore") || text4.Equals("ore") || text.Contains("Ore") || text4.Equals("quartz") || text3.Contains("quartz") || text4.Equals("clay") || (text4.Contains("clay") && !text4.Contains("mold"))) { return "ore"; } if (text4.Contains("ingot") || text3.Contains("ingot") || text4.Contains("iron bar") || text3.Contains("ironbar") || text4.Contains("emberglass") || text3.Contains("emberglass")) { return "ingots"; } if ((cat & 0x8000000) != 0 || text4.Contains("plank") || text3.Contains("plank") || text4.Contains("sawdust") || text3.Contains("sawdust") || text4.Contains("sculptured wood") || text3.Contains("sculpturedwood")) { return "planks"; } if ((cat & 0x20) != 0 || text4.Equals("lumber") || text3.Contains("item_ingredient_lumber") || text4.Contains("wood") || text4.Contains("oak") || text3.Contains("item_ingredient_wood") || text3.Contains("sapling")) { return "wood"; } if ((cat & 0x40) != 0 || text4.Equals("stone") || text4.Contains("stone brick") || text4.Contains("stone dust") || text3.Contains("stonebrick") || text3.Contains("stonedust") || text3.Contains("ingredient_stone")) { return "stone"; } if ((cat & 0x2000000) != 0) { return "tailoring"; } if (text4.Contains("cotton") || text4.Contains("thread")) { return "tailoring"; } if ((cat & 0x20000) != 0 || (cat & 0x10) != 0) { return "flowers"; } if ((cat & 0x1000000) != 0) { return "alchemy"; } if ((cat & 0x20000000) != 0) { return "consumables"; } if ((cat & 0x2000) != 0) { return "blood"; } if ((cat & 0x10000) != 0) { return "consumables"; } if ((cat & 0x4000000) != 0) { return "minerals"; } return null; } public static int DumpItemCatalog() { try { List list = new List(); list.Add("prefab_name,localized_name,guid_hash,itemcategory,itemcategory_flags,dest_group,aliases"); list.AddRange(catalogRows); string contents = string.Join("\n", list) + "\n"; string text = Path.Combine(Paths.BepInExRootPath, "Log"); Directory.CreateDirectory(text); File.WriteAllText(Path.Combine(text, "item-catalog.csv"), contents); string text2 = Path.Combine(Paths.BepInExRootPath, "Satisvampory-src"); if (Directory.Exists(text2)) { File.WriteAllText(Path.Combine(text2, "item-catalog.csv"), contents); } Core.Log.LogInfo((object)("Item catalog dumped " + catalogRows.Count + " ItemData prefabs")); return catalogRows.Count; } catch (Exception ex) { Core.Log.LogWarning((object)("Item catalog dump failed: " + ex.Message)); return 0; } } private static string Csv(string s) { if (s == null) { s = ""; } if (s.IndexOfAny(new char[3] { ',', '"', '\n' }) >= 0) { return "\"" + s.Replace("\"", "\"\"") + "\""; } return s; } public static string NormalizeName(string name) { return FoundItemConverter.Normalize(name); } public static bool IsBuiltInName(string name) { return builtInCanonical.ContainsKey(NormalizeName(name)); } public static bool TryGetBuiltInCanonical(string name, out string canonical) { return builtInCanonical.TryGetValue(NormalizeName(name), out canonical); } public static bool IsExactItemName(string name) { FoundItem item; return FoundItemConverter.TryGetExact(name, out item); } public static IReadOnlyList GetBuiltInMembers(string name) { if (builtInMembers.TryGetValue(NormalizeName(name), out var value)) { return value; } return Array.Empty(); } public static bool IsHardcodedMember(string groupName, int guidHash) { if (!TryGetBuiltInCanonical(groupName, out var canonical)) { return false; } if (builtInMembers.TryGetValue(canonical, out var value)) { return value.Any((GroupMember m) => m.GuidHash == guidHash); } return false; } public static bool IsDeletedBuiltIn(ulong ownerPlatformId, string name) { if (TryGetBuiltInCanonical(name, out var canonical)) { return Core.PlayerSettings.IsDeletedGroup(ownerPlatformId, canonical); } return false; } public static bool HasCastleOverlay(ulong ownerPlatformId, string name) { if (TryGetBuiltInCanonical(name, out var canonical)) { return Core.PlayerSettings.HasGroupOverlay(ownerPlatformId, canonical); } return false; } public static void EnsureCastleOverlay(ulong ownerPlatformId, string name) { if (TryGetBuiltInCanonical(name, out var canonical) && !Core.PlayerSettings.IsDeletedGroup(ownerPlatformId, canonical) && !Core.PlayerSettings.HasGroupOverlay(ownerPlatformId, canonical)) { List source = ResolveMembers(ownerPlatformId, canonical); Core.PlayerSettings.WriteGroupOverlay(ownerPlatformId, canonical, source.Select((GroupMember m) => (m.GuidHash.ToString(), Name: m.Name))); } } public unsafe static bool TryGetStandingCastleSettingsOwner(ChatCommandContext ctx, out ulong ownerPlatformId, out string ownerName, bool replyIfMissing = true) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) ownerPlatformId = 0uL; ownerName = null; int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(ctx.Event.SenderCharacterEntity); if (standingTerritoryId < 0) { if (replyIfMissing) { ctx.Reply("You must stand on a castle plot to view or set its reserves and production caps."); } return false; } Entity castleHeart = Core.TerritoryService.GetCastleHeart(standingTerritoryId); if (!(castleHeart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { UserOwner val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has()) { User val2 = entityOnServer.Read(); ownerPlatformId = val2.PlatformId; ownerName = ((object)(*(FixedString64Bytes*)(&val2.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrWhiteSpace(ownerName)) { ownerName = ownerPlatformId.ToString(); } return true; } } if (replyIfMissing) { ctx.Reply("You must stand on a castle plot to view or set its reserves and production caps."); } return false; } } if (replyIfMissing) { ctx.Reply("You must stand on a castle plot to view or set its reserves and production caps."); } return false; } public unsafe static bool TryGetCastleSettingsOwner(ChatCommandContext ctx, bool forSet, out ulong ownerPlatformId, out string ownerName, bool replyIfMissing = true) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) ownerPlatformId = 0uL; ownerName = null; if (Core.TerritoryService.GetStandingTerritoryId(ctx.Event.SenderCharacterEntity) >= 0) { return TryGetStandingCastleSettingsOwner(ctx, out ownerPlatformId, out ownerName, replyIfMissing); } User user = ctx.Event.User; if (!Core.TerritoryService.IsClanShareOn(user)) { if (replyIfMissing) { ctx.Reply("You must stand on a castle plot to view or set its reserves and production caps."); } return false; } if (Core.TerritoryService.TryFindOwnedTerritory(user.PlatformId, out var _, out var owner)) { ownerPlatformId = owner.PlatformId; ownerName = ((object)(*(FixedString64Bytes*)(&owner.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrWhiteSpace(ownerName)) { ownerName = ownerPlatformId.ToString(); } return true; } if (forSet) { if (replyIfMissing) { ctx.Reply("Stand on a castle to set reserve/cap, or own a castle plot."); } return false; } ownerPlatformId = user.PlatformId; ownerName = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrWhiteSpace(ownerName)) { ownerName = ownerPlatformId.ToString(); } return true; } public static bool TryResolveGroup(ulong ownerPlatformId, string name, out string resolvedName, out bool isBuiltIn) { resolvedName = NormalizeName(name); isBuiltIn = TryGetBuiltInCanonical(resolvedName, out var canonical); if (isBuiltIn) { resolvedName = canonical; if (Core.PlayerSettings.IsDeletedGroup(ownerPlatformId, canonical)) { return false; } return true; } return Core.PlayerSettings.HasItemGroup(ownerPlatformId, resolvedName); } public static List ResolveMembers(ulong ownerPlatformId, string name) { //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) List list = new List(); HashSet hashSet = new HashSet(); string name2 = NormalizeName(name); if (TryGetBuiltInCanonical(name2, out var canonical)) { name2 = canonical; if (Core.PlayerSettings.IsDeletedGroup(ownerPlatformId, canonical)) { return list; } if (Core.PlayerSettings.HasGroupOverlay(ownerPlatformId, canonical)) { { PrefabGUID val = default(PrefabGUID); foreach (var item in Core.PlayerSettings.ListItemGroupMembers(ownerPlatformId, canonical)) { if (!int.TryParse(item.guid, out var result) || !hashSet.Add(result)) { continue; } ((PrefabGUID)(ref val))..ctor(result); string text = item.name; if (string.IsNullOrEmpty(text)) { string text2 = val.PrefabName(); if (text2 == null) { (text2, _) = item; } text = text2; } list.Add(new GroupMember(val, text, result)); } return list; } } foreach (GroupMember builtInMember in GetBuiltInMembers(canonical)) { if (hashSet.Add(builtInMember.GuidHash)) { list.Add(builtInMember); } } } PrefabGUID val2 = default(PrefabGUID); foreach (var item2 in Core.PlayerSettings.ListItemGroupMembers(ownerPlatformId, name2)) { if (!int.TryParse(item2.guid, out var result2) || !hashSet.Add(result2)) { continue; } ((PrefabGUID)(ref val2))..ctor(result2); string text3 = item2.name; if (string.IsNullOrEmpty(text3)) { string text4 = val2.PrefabName(); if (text4 == null) { (text4, _) = item2; } text3 = text4; } list.Add(new GroupMember(val2, text3, result2)); } return list; } public static List ParseItemTokens(string input) { List list = new List(); if (string.IsNullOrWhiteSpace(input)) { return list; } int i = 0; while (i < input.Length) { for (; i < input.Length && char.IsWhiteSpace(input[i]); i++) { } if (i >= input.Length) { break; } if (input[i] == '"' || input[i] == '\'') { char c = input[i++]; int num = i; for (; i < input.Length && input[i] != c; i++) { } list.Add(input.Substring(num, i - num)); if (i < input.Length) { i++; } } else { int num2 = i; for (; i < input.Length && !char.IsWhiteSpace(input[i]); i++) { } list.Add(input.Substring(num2, i - num2)); } } return list; } public static string FormatMemberNames(IEnumerable names, int maxLen = 180) { string text = string.Join(", ", names); if (text.Length <= maxLen) { return text; } int num = text.LastIndexOf(',', maxLen); if (num <= 0) { num = maxLen; } return text.Substring(0, num).TrimEnd(',', ' ') + ", ..."; } } internal class LocalizationService { private readonly Dictionary localization; private readonly Dictionary prefabNames; private static readonly HashSet BookTier1 = new HashSet { 1455590675, -651642571 }; private static readonly HashSet BookTier2 = new HashSet { 1150376281, 686122001 }; private const int DarkmatterPistols = -1265586439; public LocalizationService() { localization = EmbeddedJson.Load("Satisvampory.Localization.English.json"); prefabNames = EmbeddedJson.Load("Satisvampory.Data.PrefabNames.json"); } public string GetLocalization(string guid) { if (!localization.TryGetValue(guid, out var value)) { return ""; } return value; } public string GetLocalization(LocalizationKey key) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return GetLocalization(((object)((AssetGuid)(ref key.Key)).ToGuid()/*cast due to .constrained prefix*/).ToString()); } public string GetPrefabName(PrefabGUID itemPrefabGUID) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!prefabNames.TryGetValue(itemPrefabGUID._Value, out var value)) { return null; } string label = GetLocalization(value); if (itemPrefabGUID._Value == -1265586439) { label = "Darkmatter Pistols"; } label = Annotate(itemPrefabGUID, label); if (BookTier1.Contains(itemPrefabGUID._Value)) { return label + " Tier 1"; } if (BookTier2.Contains(itemPrefabGUID._Value)) { return label + " Tier 2"; } return label; } private static string Annotate(PrefabGUID guid, string label) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity entity = default(Entity); if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(guid, ref entity)) { return label; } if (entity.Has() && (int)entity.Read().ItemType == 5) { label = "Book " + label; } if (entity.Has() && entity.Read().TierIndex != 0) { label += $" Jewel Tier {entity.Read().TierIndex + 1}"; } if (entity.Has()) { label += $" Tier {entity.Read().TierIndex + 1}"; } if (entity.Has()) { label += " Shattered"; } return label; } } internal enum PendingItemCommand { None, Pull, ReserveShow, ReserveSet, ReserveClear, CapShow, CapSet, CapClear, GroupAdd, GroupRemove, FindItem, AdminStash, Conv, ExcludeToggle, BagCapShow, BagCapSet, AliasAdd } internal sealed class PendingItemChoice { public List<(PrefabGUID Prefab, string Name)> Candidates; public PendingItemCommand Command; public bool CommandAttached; public int Amount; public string GroupName; public DateTime ExpiresUtc; } internal static class PendingItemChoiceService { private static readonly Dictionary pending = new Dictionary(); private static readonly TimeSpan Ttl = TimeSpan.FromMinutes(2.0); public const int MaxListed = 25; public static void BeginAmbiguous(ulong platformId, List<(PrefabGUID Prefab, string Name)> candidates) { if (candidates == null) { candidates = new List<(PrefabGUID, string)>(); } pending[platformId] = new PendingItemChoice { Candidates = candidates, Command = PendingItemCommand.None, CommandAttached = false, Amount = 0, GroupName = null, ExpiresUtc = DateTime.UtcNow + Ttl }; } public static void AttachCommand(ulong platformId, PendingItemCommand command, int amount = 0, string groupName = null) { if (pending.TryGetValue(platformId, out var value) && value != null) { if (DateTime.UtcNow > value.ExpiresUtc) { pending.Remove(platformId); return; } value.Command = command; value.CommandAttached = true; value.Amount = amount; value.GroupName = groupName; value.ExpiresUtc = DateTime.UtcNow + Ttl; } } public static void ReplyNumberedList(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.Event.User.PlatformId; if (!pending.TryGetValue(platformId, out var value) || value?.Candidates == null || value.Candidates.Count == 0) { ctx.Reply("Multiple matches. Be more specific."); return; } ctx.Reply("Multiple matches. Type .l (or .l pick ) to choose:"); int num = Math.Min(value.Candidates.Count, 25); for (int i = 0; i < num; i++) { string value2 = value.Candidates[i].Name; if (string.IsNullOrEmpty(value2)) { value2 = value.Candidates[i].Prefab.PrefabName(); } ctx.Reply($" {i + 1}. {value2}"); } if (value.Candidates.Count > 25) { ctx.Reply(" ..."); } } public static bool TryPick(ulong platformId, int index, out PendingItemChoice choice, out (PrefabGUID Prefab, string Name) picked, out string error) { choice = null; picked = default((PrefabGUID, string)); error = null; if (!pending.TryGetValue(platformId, out var value) || value == null) { error = "No pending item choice. Search again if a name had multiple matches."; return false; } if (DateTime.UtcNow > value.ExpiresUtc) { pending.Remove(platformId); error = "That item choice expired. Search again."; return false; } if (!value.CommandAttached || value.Candidates == null || value.Candidates.Count == 0) { pending.Remove(platformId); error = "No pending item choice. Search again if a name had multiple matches."; return false; } if (index < 1 || index > value.Candidates.Count) { error = $"Invalid choice. Pick a number from 1 to {value.Candidates.Count}."; return false; } choice = value; picked = value.Candidates[index - 1]; pending.Remove(platformId); return true; } } internal static class PlayerActionGate { public readonly struct Context { public readonly Entity Character; public readonly Entity UserEntity; public readonly User User; public readonly int StandingPlot; public readonly Entity Heart; public Context(Entity character, Entity userEntity, User user, int standingPlot, Entity heart) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Character = character; UserEntity = userEntity; User = user; StandingPlot = standingPlot; Heart = heart; } } private static readonly PrefabGUID Downed = new PrefabGUID(-1992158531); private static readonly PrefabGUID BatForm = new PrefabGUID(1205505492); public static bool TryOpen(Entity character, string verb, bool requireAlliedHeart, out Context ctx, out string deny) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Invalid comparison between Unknown and I4 //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) ctx = default(Context); deny = null; if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && character.Has()) { Entity userEntity = character.Read().UserEntity; User val = userEntity.Read(); int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(character); Entity val2 = ((standingTerritoryId >= 0) ? Core.TerritoryService.GetCastleHeart(standingTerritoryId) : Entity.Null); ctx = new Context(character, userEntity, val, standingTerritoryId, val2); Entity val3 = default(Entity); if (BuffUtility.TryGetBuff(Core.EntityManager, character, PrefabIdentifier.op_Implicit(Downed), ref val3)) { deny = "Unable to " + verb + " while downed!"; return false; } if (character.Has() && character.Read().IsDead) { deny = "Unable to " + verb + " when dead!"; return false; } if (BuffUtility.TryGetBuff(Core.EntityManager, character, PrefabIdentifier.op_Implicit(BatForm), ref val3)) { deny = "Cannot " + verb + " items while in batform."; return false; } if (BuffUtility.TryGetBuff(Core.EntityManager, character, PrefabIdentifier.op_Implicit(Const.Buff_InCombat_PvPVampire), ref val3)) { deny = "Unable to " + verb + " while in PvP combat."; return false; } if (requireAlliedHeart) { bool flag = Core.TerritoryService.IsClanShareOn(val); if (standingTerritoryId < 0 && !flag) { deny = "Unable to " + verb + " outside territories!"; return false; } if (flag && Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(character).Count == 0) { deny = "Unable to " + verb + " — no clan castles available (ClanShare on)."; return false; } if (standingTerritoryId >= 0) { if (val2 == Entity.Null) { deny = "There is no heart on this territory!"; return false; } ServerGameManager serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).IsAllies(val2, character)) { deny = "You aren't allies with the heart on this territory!"; return false; } if (val2.Has() && (int)val2.Read().ActiveEvent >= 2) { deny = $"Unable to {verb} while castle is {val2.Read().ActiveEvent}"; return false; } } } return true; } } deny = "No character."; return false; } public static bool TryOpenForStash(Entity character, out Context ctx, out string deny) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Invalid comparison between Unknown and I4 //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) ctx = default(Context); deny = null; if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && character.Has()) { Entity userEntity = character.Read().UserEntity; User val = userEntity.Read(); int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(character); Entity val2 = ((standingTerritoryId >= 0) ? Core.TerritoryService.GetCastleHeart(standingTerritoryId) : Entity.Null); ctx = new Context(character, userEntity, val, standingTerritoryId, val2); Entity val3 = default(Entity); if (BuffUtility.TryGetBuff(Core.EntityManager, character, PrefabIdentifier.op_Implicit(Downed), ref val3)) { deny = "Unable to stash while downed!"; return false; } if (character.Has() && character.Read().IsDead) { deny = "Unable to stash when dead!"; return false; } if (BuffUtility.TryGetBuff(Core.EntityManager, character, PrefabIdentifier.op_Implicit(Const.Buff_InCombat_PvPVampire), ref val3)) { deny = "Unable to stash while in PvP combat."; return false; } bool flag = Core.TerritoryService.IsClanShareOn(val); bool flag2 = Core.PlayerSettings.IsRrGlobalEnabled(val.PlatformId); if (standingTerritoryId < 0) { if (!flag2) { deny = "Unable to stash outside territories! (RR global off)"; return false; } if (!flag || Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(character).Count == 0) { deny = "Unable to stash outside territories — no clan plots (need ClanShare)."; return false; } return true; } if (val2 == Entity.Null) { deny = "There is no heart on this territory!"; return false; } ServerGameManager serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).IsAllies(val2, character)) { deny = "You aren't allies with the heart on this territory!"; return false; } if (val2.Has() && (int)val2.Read().ActiveEvent >= 2) { deny = $"Unable to stash while castle is {val2.Read().ActiveEvent}"; return false; } if (flag && Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(character).Count == 0) { deny = "Unable to stash -- no clan castles available (ClanShare on)."; return false; } return true; } } deny = "No character."; return false; } public static void Deny(User user, string message) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(message)) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, message); } } } internal static class PlayerDeposit { private const int ActionBarSlots = 8; public static void FromCharacter(Entity character, PlayerActionGate.Context ctx) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) User user = ctx.User; int plot = ctx.StandingPlot; bool flag = Core.TerritoryService.IsClanShareOn(user); ulong platformId = 0uL; if (plot >= 0) { Core.TerritoryService.TryGetTerritoryOwnerPlatformId(plot, out platformId); } else { IReadOnlyList logisticsTerritoryIdsForCharacter = Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(character); if (logisticsTerritoryIdsForCharacter.Count > 0) { Core.TerritoryService.TryGetTerritoryOwnerPlatformId(logisticsTerritoryIdsForCharacter[0], out platformId); } } List<(Entity, Entity)> list = new List<(Entity, Entity)>(100); bool flag2 = false; foreach (Entity item3 in flag ? Core.Stash.IslandChests(character) : Core.Stash.ChestsOnPlot(plot)) { if (StashRouting.TryGetExternalInventory(item3, out var inventory)) { string text = StashRouting.RawName(item3); if (StashRouting.IsNoShareName(text)) { StashRouting.LogDestPick(StashRouting.SkipLabel(text), plot, default(PrefabGUID), text, "stash-filter"); } else if (!StashRouting.IsSpecialName(text)) { flag2 = true; list.Add((item3, inventory)); } } } if (!flag2) { PlayerActionGate.Deny(user, "Unable to stash as no available stashes found in your current territory!"); } else { Entity val = default(Entity); if (!InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, character, ref val, 0)) { return; } ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer slots = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val, ref slots)) { return; } AddItemSettings addItemSettings = Utilities.GetAddItemSettings(); HashSet hashSet = new HashSet(); Dictionary<(Entity, PrefabGUID), int> dictionary = new Dictionary<(Entity, PrefabGUID), int>(); Dictionary dictionary2 = new Dictionary(); IReadOnlyList source; if (!flag) { IReadOnlyList readOnlyList = new int[1] { plot }; source = readOnlyList; } else { source = Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(character); } Entity[] overflow = (from s in source.Where((int id) => !TerritoryService.IsHeartRaided(Core.TerritoryService.GetCastleHeart(id))).SelectMany(Core.Stash.OverflowChests) orderby StashRouting.IsSpecialName(StashRouting.RawName(s)) ? 1 : 0, (plot < 0 || Core.TerritoryService.GetTerritoryId(s) != plot) ? 1 : 0 select s).ToArray(); for (int num = 8; num < slots.Length; num++) { InventoryBuffer row = slots[num]; PrefabGUID itemType = row.ItemType; if (((PrefabGUID)(ref itemType)).GuidHash != 0) { Entity entityOnServer = ((NetworkedEntity)(ref row.ItemEntity)).GetEntityOnServer(); if (!((Entity)(ref entityOnServer)).Equals(Entity.Null)) { PlaceUnique(row, num, val, list, overflow, platformId, plot, hashSet, dictionary, dictionary2); } else { PlaceStack(ref row, num, val, list, overflow, platformId, plot, addItemSettings, hashSet, dictionary, dictionary2, slots); } } } if (dictionary.Count > 0) { PlayerActionGate.Deny(user, "Stashed items from your inventory to the current territory!"); } else { PlayerActionGate.Deny(user, "No items were able to stash from your inventory!"); } if (Core.PlayerSettings.IsSilentStashEnabled(user.PlatformId)) { return; } foreach (KeyValuePair<(Entity, PrefabGUID), int> item4 in dictionary) { item4.Deconstruct(out var key, out var value); (Entity, PrefabGUID) tuple = key; Entity item = tuple.Item1; PrefabGUID item2 = tuple.Item2; int value2 = value; Utilities.SendSystemMessageToClient(Core.EntityManager, user, $"Stashed {value2}x {item2.PrefabName()} to {item.EntityName()}{StashRouting.FormatBeltChat(item, item2)}"); StashRouting.LogBeltTo(item, item2, plot, "stash"); } foreach (PrefabGUID item5 in hashSet) { if (dictionary2.TryGetValue(item5, out var value3)) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, $"Unable to stash {value3}x {item5.PrefabName()} due to insufficient space in stashes!"); } } } } private static void PlaceUnique(InventoryBuffer row, int slot, Entity bag, List<(Entity stash, Entity inventory)> dests, Entity[] overflow, ulong ownerId, int plot, HashSet movedTypes, Dictionary<(Entity stash, PrefabGUID item), int> moved, Dictionary leftover) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) PrefabGUID itemType = row.ItemType; List<(Entity, Entity)> list = StashRouting.OrderDepositDests(dests, itemType, ownerId, plot); for (int i = 0; i < list.Count; i++) { try { (Entity, Entity) tuple = list[i]; DynamicBuffer val = tuple.Item2.ReadBuffer(); for (int j = 0; j < val.Length; j++) { InventoryBuffer val2 = val[j]; if (((PrefabGUID)(ref val2.ItemType)).Equals(PrefabGUID.Empty)) { val[j] = row; Entity entityOnServer = ((NetworkedEntity)(ref row.ItemEntity)).GetEntityOnServer(); if (entityOnServer.Has()) { InventoryItem componentData = entityOnServer.Read(); (componentData.ContainerEntity, _) = tuple; entityOnServer.Write(componentData); } Credit(tuple.Item1, itemType, 1, plot, ownerId, movedTypes, moved); InventoryUtilitiesServer.ClearSlot(Core.EntityManager, bag, slot); return; } } } catch (Exception e) { Core.LogException(e, "Item Entity Storage"); } } if (!TryOverflowUnique(row, slot, bag, overflow, itemType, plot, ownerId, movedTypes, moved)) { leftover.TryGetValue(itemType, out var value); leftover[itemType] = value + 1; } } private static bool TryOverflowUnique(InventoryBuffer row, int slot, Entity bag, Entity[] overflow, PrefabGUID item, int plot, ulong ownerId, HashSet movedTypes, Dictionary<(Entity stash, PrefabGUID item), int> moved) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I8 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if (overflow == null || overflow.Length == 0) { return false; } ItemData val = default(ItemData); PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity entity = default(Entity); if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(item, ref entity)) { val = entity.Read(); } bool flag = (long)val.ItemCategory == 1073741824; ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val3 = default(DynamicBuffer); for (int i = 0; i < overflow.Length; i++) { try { Entity val2 = overflow[i]; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val2, ref val3)) { continue; } Entity val4 = Entity.Null; Enumerator enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { InventoryInstanceElement current = enumerator.Current; if ((!(current.RestrictedType != PrefabGUID.Empty) || !(current.RestrictedType != val.ItemTypeGUID)) && (current.RestrictedCategory == 0L || (int)(current.RestrictedCategory & val.ItemCategory) != 0) && (!flag || current.RestrictedCategory != 0L)) { NetworkedEntity externalInventoryEntity = current.ExternalInventoryEntity; val4 = ((NetworkedEntity)(ref externalInventoryEntity)).GetEntityOnServer(); } } if (val4 == Entity.Null) { continue; } DynamicBuffer val5 = val4.ReadBuffer(); for (int j = 0; j < val5.Length; j++) { InventoryBuffer val6 = val5[j]; if (((PrefabGUID)(ref val6.ItemType)).Equals(PrefabGUID.Empty)) { val5[j] = row; Entity entityOnServer = ((NetworkedEntity)(ref row.ItemEntity)).GetEntityOnServer(); if (entityOnServer.Has()) { InventoryItem componentData = entityOnServer.Read(); componentData.ContainerEntity = val2; entityOnServer.Write(componentData); } movedTypes.Add(item); moved.TryGetValue((val2, item), out var value); moved[(val2, item)] = value + 1; InventoryUtilitiesServer.ClearSlot(Core.EntityManager, bag, slot); return true; } } } catch (Exception e) { Core.LogException(e, "Overflow Item Entity Storage"); } } return false; } private static void PlaceStack(ref InventoryBuffer row, int slot, Entity bag, List<(Entity stash, Entity inventory)> dests, Entity[] overflow, ulong ownerId, int plot, AddItemSettings add, HashSet movedTypes, Dictionary<(Entity stash, PrefabGUID item), int> moved, Dictionary leftover, DynamicBuffer slots) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) PrefabGUID itemType = row.ItemType; List<(Entity, Entity)> list = StashRouting.OrderDepositDests(dests, itemType, ownerId, plot); for (int i = 0; i < list.Count; i++) { if (row.Amount <= 0) { break; } try { (Entity, Entity) tuple = list[i]; AddItemResponse val = InventoryUtilitiesServer.TryAddItem(add, tuple.Item2, row); if (((AddItemResponse)(ref val)).Success) { int amount = row.Amount - val.RemainingAmount; Credit(tuple.Item1, itemType, amount, plot, ownerId, movedTypes, moved); row.Amount = val.RemainingAmount; if (!((AddItemResponse)(ref val)).ItemsRemaining) { InventoryUtilitiesServer.ClearSlot(Core.EntityManager, bag, slot); return; } } } catch (Exception e) { Core.LogException(e, "Item Storage"); } } if (row.Amount > 0) { TryOverflowStack(ref row, slot, bag, overflow, itemType, plot, ownerId, add, movedTypes, moved); } if (row.Amount > 0) { slots[slot] = row; leftover.TryGetValue(itemType, out var value); leftover[itemType] = value + row.Amount; } } private static void TryOverflowStack(ref InventoryBuffer row, int slot, Entity bag, Entity[] overflow, PrefabGUID item, int plot, ulong ownerId, AddItemSettings add, HashSet movedTypes, Dictionary<(Entity stash, PrefabGUID item), int> moved) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I8 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) if (overflow == null || overflow.Length == 0 || row.Amount <= 0) { return; } ItemData val = default(ItemData); PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity entity = default(Entity); if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(item, ref entity)) { val = entity.Read(); } bool flag = (long)val.ItemCategory == 1073741824; ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val3 = default(DynamicBuffer); for (int i = 0; i < overflow.Length; i++) { if (row.Amount <= 0) { break; } try { Entity val2 = overflow[i]; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val2, ref val3)) { continue; } Entity val4 = Entity.Null; Enumerator enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { InventoryInstanceElement current = enumerator.Current; if ((!(current.RestrictedType != PrefabGUID.Empty) || !(current.RestrictedType != val.ItemTypeGUID)) && (current.RestrictedCategory == 0L || (int)(current.RestrictedCategory & val.ItemCategory) != 0) && (!flag || current.RestrictedCategory != 0L)) { NetworkedEntity externalInventoryEntity = current.ExternalInventoryEntity; val4 = ((NetworkedEntity)(ref externalInventoryEntity)).GetEntityOnServer(); } } if (val4 == Entity.Null) { continue; } AddItemResponse val5 = InventoryUtilitiesServer.TryAddItem(add, val4, row); if (((AddItemResponse)(ref val5)).Success) { int num = row.Amount - val5.RemainingAmount; movedTypes.Add(item); moved.TryGetValue((val2, item), out var value); moved[(val2, item)] = value + num; DestDebugLog.Move("stash", plot, item, num, Entity.Null, val2, "overflow", Core.PlayerSettings.GetPullReserve(ownerId, item), "stays"); row.Amount = val5.RemainingAmount; if (!((AddItemResponse)(ref val5)).ItemsRemaining) { InventoryUtilitiesServer.ClearSlot(Core.EntityManager, bag, slot); break; } } } catch (Exception e) { Core.LogException(e, "Overflow Item Storage"); } } } private static void Credit(Entity stash, PrefabGUID item, int amount, int plot, ulong ownerId, HashSet movedTypes, Dictionary<(Entity stash, PrefabGUID item), int> moved) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (amount > 0) { movedTypes.Add(item); moved.TryGetValue((stash, item), out var value); moved[(stash, item)] = value + amount; StashRouting.DepositRank depositRank = StashRouting.RankDeposit(stash, item, ownerId, hasItem: true); StashRouting.LogDestPickAlways(depositRank.Label + " class=" + depositRank.Class, plot, item, StashRouting.DestName(stash), "stash"); Entity val = StashRouting.PredictNextBeltDest(stash, item); string belt = ((val == Entity.Null) ? "stays" : StashRouting.RawName(val)); DestDebugLog.Move("stash", plot, item, amount, Entity.Null, stash, depositRank.Label + "/c" + depositRank.Class, Core.PlayerSettings.GetPullReserve(ownerId, item), belt); } } } internal enum CapMode { Bags, Guild } internal enum AutoFilter { Around, All } internal enum NotifyMode { Off, Manual, On } internal class PlayerSettingsService { internal const int WorldId = 0; private static readonly string ConfigDir = Path.Combine(Paths.ConfigPath, "Satisvampory"); private static readonly string SettingsFile = Path.Combine(ConfigDir, "playerSettings.json"); private static readonly JsonSerializerOptions JsonOpts = new JsonSerializerOptions { WriteIndented = true, IncludeFields = true }; private SettingsRow defaultSettings = new SettingsRow(); private Dictionary playerSettings = new Dictionary(); private bool saveDirty; private DateTime lastSaveUtc = DateTime.MinValue; private const double SaveDebounceSeconds = 1.5; internal Dictionary Rows => playerSettings; internal SettingsRow Blank => defaultSettings; public bool IsSortStashEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.SortStash, requireGlobal: true); } public bool ToggleSortStash(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.SortStash, delegate(SettingsRow s, bool v) { s.SortStash = v; return s; }); } public bool TogglePull() { return FlipFlag(0uL, (SettingsRow s) => s.Pull, delegate(SettingsRow s, bool v) { s.Pull = v; return s; }); } public bool IsPullEnabled() { return !ReadFlag(0uL, (SettingsRow s) => s.Pull); } public bool ToggleTrash() { return FlipFlag(0uL, (SettingsRow s) => s.Trash, delegate(SettingsRow s, bool v) { s.Trash = v; return s; }); } public bool IsTrashEnabled() { return !ReadFlag(0uL, (SettingsRow s) => s.Trash); } public bool IsCraftPullEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.CraftPull, requireGlobal: true); } public bool ToggleCraftPull(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.CraftPull, delegate(SettingsRow s, bool v) { s.CraftPull = v; return s; }); } public bool IsDontPullLastEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.DontPullLast); } public bool ToggleDontPullLast(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.DontPullLast, delegate(SettingsRow s, bool v) { s.DontPullLast = v; return s; }); } public bool IsAutoStashMissionsEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.AutoStashMissions, requireGlobal: true); } public bool ToggleAutoStashMissions(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.AutoStashMissions, delegate(SettingsRow s, bool v) { s.AutoStashMissions = v; return s; }); } public bool IsRepeatHuntEnabled() { if (TryRow(0uL, out var settings)) { return settings.RepeatHunt; } return false; } public bool ToggleRepeatHunt() { bool num = FlipFlag(0uL, (SettingsRow s) => s.RepeatHunt, delegate(SettingsRow s, bool v) { s.RepeatHunt = v; return s; }); if (num) { RepeatHunts.CaptureActiveMissions(); } RepeatHunts.PublishClientState(); return num; } public int GetRepeatHuntMaxSuccess() { if (!TryRow(0uL, out var settings) || settings.RepeatHuntMaxSuccess <= 0) { return 99; } if (settings.RepeatHuntMaxSuccess > 100) { return 100; } return settings.RepeatHuntMaxSuccess; } public int SetRepeatHuntMaxSuccess(int percent) { if (percent < 1) { percent = 1; } if (percent > 100) { percent = 100; } SettingsRow value = Snapshot(0uL, create: true); value.RepeatHuntMaxSuccess = percent; playerSettings[0uL] = value; MarkDirty(); RepeatHunts.PublishClientState(); return percent; } public bool TryWorldOffPlots(out List off) { off = null; if (!TryRow(0uL, out var settings)) { return false; } off = settings.RepeatHuntOffPlots; return true; } public bool IsRepeatHuntPlotOn(int plot) { if (!IsRepeatHuntEnabled()) { return false; } if (!TryRow(0uL, out var settings) || settings.RepeatHuntOffPlots == null) { return true; } return !settings.RepeatHuntOffPlots.Contains("t" + plot); } public void SetRepeatHuntPlot(int plot, bool on) { SettingsRow value = Snapshot(0uL, create: true); List list = ((value.RepeatHuntOffPlots != null) ? new List(value.RepeatHuntOffPlots) : new List()); string item = "t" + plot; if (on) { list.Remove(item); } else if (!list.Contains(item)) { list.Add(item); } value.RepeatHuntOffPlots = list; playerSettings[0uL] = value; MarkDirty(); if (on) { RepeatHunts.CaptureActiveMissions(plot); } RepeatHunts.PublishClientState(); } public bool TryItemAliases(out Dictionary map, out Dictionary names) { map = null; names = null; if (!TryRow(0uL, out var settings)) { return false; } map = settings.ItemAliases; names = settings.ItemAliasNames; return true; } public string SetItemAlias(string alias, int guidHash, string displayName) { if (string.IsNullOrWhiteSpace(alias) || guidHash == 0) { return "Need an alias and an item."; } SettingsRow value = Snapshot(0uL, create: true); ref SettingsRow reference = ref value; if (reference.ItemAliases == null) { Dictionary dictionary = (reference.ItemAliases = new Dictionary()); } reference = ref value; if (reference.ItemAliasNames == null) { Dictionary dictionary3 = (reference.ItemAliasNames = new Dictionary()); } value.ItemAliases[alias] = guidHash; value.ItemAliasNames[alias] = (string.IsNullOrWhiteSpace(displayName) ? alias : displayName); playerSettings[0uL] = value; MarkDirty(); return null; } public bool RemoveItemAlias(string alias) { SettingsRow value = Snapshot(0uL, create: true); ref SettingsRow reference = ref value; if (reference.ItemAliases == null) { Dictionary dictionary = (reference.ItemAliases = new Dictionary()); } reference = ref value; if (reference.ItemAliasNames == null) { Dictionary dictionary3 = (reference.ItemAliasNames = new Dictionary()); } bool num = value.ItemAliases.Remove(alias); value.ItemAliasNames.Remove(alias); playerSettings[0uL] = value; if (num) { MarkDirty(); } return num; } public bool IsConveyorEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.Conveyor, requireGlobal: true); } public bool IsSalvageEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.Salvage, requireGlobal: true); } public bool ToggleSalvage(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.Salvage, delegate(SettingsRow s, bool v) { s.Salvage = v; return s; }); } public bool IsUnitSpawnerEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.UnitSpawner); } public bool ToggleUnitSpawner(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.UnitSpawner, delegate(SettingsRow s, bool v) { s.UnitSpawner = v; return s; }); } public bool IsBrazierEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.Brazier); } public bool IsSolarEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.Named); } public bool ToggleSolar(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.Named, delegate(SettingsRow s, bool v) { s.Named = v; return s; }); } public bool ToggleBrazier(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.Brazier, delegate(SettingsRow s, bool v) { s.Brazier = v; return s; }); } public bool ToggleSilentPull(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.SilentPull, delegate(SettingsRow s, bool v) { s.SilentPull = v; return s; }); } public bool IsSilentPullEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.SilentPull); } public bool ToggleSilentStash(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.SilentStash, delegate(SettingsRow s, bool v) { s.SilentStash = v; return s; }); } public bool IsSilentStashEnabled(ulong playerId) { return ReadFlag(playerId, (SettingsRow s) => s.SilentStash); } public bool ToggleConveyor(ulong playerId = 0uL) { return FlipFlag(playerId, (SettingsRow s) => s.Conveyor, delegate(SettingsRow s, bool v) { s.Conveyor = v; return s; }); } public PlayerSettingsService() { Hydrate(); if (!TryRow(0uL, out var settings)) { Put(0uL, SgAllOn(new SettingsRow())); } else if (!settings.AppliedSgAllOn) { Put(0uL, SgAllOn(settings)); } FlushSettings(force: true); } private static SettingsRow SgAllOn(SettingsRow s) { bool flag = (s.AppliedSgAllOn = true); bool flag3 = (s.RrGlobalAllow = flag); bool flag5 = (s.Trash = flag3); bool flag7 = (s.Named = flag5); bool flag9 = (s.Brazier = flag7); bool flag11 = (s.UnitSpawner = flag9); bool flag13 = (s.Salvage = flag11); bool flag15 = (s.Conveyor = flag13); bool flag17 = (s.AutoStashMissions = flag15); bool flag19 = (s.CraftPull = flag17); bool sortStash = (s.Pull = flag19); s.SortStash = sortStash; return s; } private void Hydrate() { try { if (!Directory.Exists(ConfigDir)) { Directory.CreateDirectory(ConfigDir); } if (File.Exists(SettingsFile)) { playerSettings = JsonSerializer.Deserialize>(File.ReadAllText(SettingsFile)) ?? new Dictionary(); } SettingsExtras.ImportGroundScoop(this); } catch { if (playerSettings == null) { playerSettings = new Dictionary(); } } } internal void MarkDirty() { saveDirty = true; ClanTreasuryLend.BumpSettings(); } internal bool TryRow(ulong id, out SettingsRow settings) { return playerSettings.TryGetValue(id, out settings); } public void FlushSettings(bool force = false) { if (!saveDirty || (!force && (DateTime.UtcNow - lastSaveUtc).TotalSeconds < 1.5)) { return; } try { if (!Directory.Exists(ConfigDir)) { Directory.CreateDirectory(ConfigDir); } string text = SettingsFile + ".tmp"; File.WriteAllText(text, JsonSerializer.Serialize(playerSettings, JsonOpts)); File.Copy(text, SettingsFile, overwrite: true); File.Delete(text); saveDirty = false; lastSaveUtc = DateTime.UtcNow; } catch { } } internal SettingsRow GetOrCreate(ulong platformId) { if (!playerSettings.TryGetValue(platformId, out var value)) { value = new SettingsRow(); } ref SettingsRow reference = ref value; if (reference.ScoopExcludes == null) { List list = (reference.ScoopExcludes = new List()); } reference = ref value; if (reference.ScoopExcludeNames == null) { Dictionary dictionary = (reference.ScoopExcludeNames = new Dictionary()); } reference = ref value; if (reference.ScoopCaps == null) { Dictionary dictionary3 = (reference.ScoopCaps = new Dictionary()); } reference = ref value; if (reference.ScoopCapNames == null) { Dictionary dictionary = (reference.ScoopCapNames = new Dictionary()); } if (string.IsNullOrEmpty(value.ScoopMode)) { value.ScoopMode = "bags"; } if (string.IsNullOrEmpty(value.AutoFilter)) { value.AutoFilter = "all"; } if (string.IsNullOrEmpty(value.NotifyMode)) { value.NotifyMode = "manual"; } if (value.Radius < 1f) { value.Radius = 10f; } reference = ref value; if (reference.ItemAliases == null) { Dictionary dictionary3 = (reference.ItemAliases = new Dictionary()); } reference = ref value; if (reference.ItemAliasNames == null) { Dictionary dictionary = (reference.ItemAliasNames = new Dictionary()); } return value; } internal void Put(ulong platformId, SettingsRow settings) { playerSettings[platformId] = settings; MarkDirty(); } internal SettingsRow Snapshot(ulong id, bool create) { if (!playerSettings.TryGetValue(id, out var value)) { if (!create) { return defaultSettings; } return new SettingsRow(); } return value; } private bool ReadFlag(ulong id, Func read, bool requireGlobal = false) { if (!requireGlobal) { return read(Snapshot(id, create: false)); } if (read(Snapshot(id, create: false))) { return read(Snapshot(0uL, create: false)); } return false; } private bool FlipFlag(ulong id, Func read, Func write) { SettingsRow settingsRow = Snapshot(id, create: true); bool flag = !read(settingsRow); playerSettings[id] = write(settingsRow, flag); MarkDirty(); return flag; } internal SettingsRow GetGlobalMutable() { if (!TryRow(0uL, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ClanShareByClan == null) { Dictionary dictionary = (reference.ClanShareByClan = new Dictionary()); } reference = ref settings; if (reference.ClanShareExcludedTerritories == null) { List list = (reference.ClanShareExcludedTerritories = new List()); } reference = ref settings; if (reference.StarterKitSeeded == null) { List list = (reference.StarterKitSeeded = new List()); } reference = ref settings; if (reference.StarterKitChestSeeded == null) { List list = (reference.StarterKitChestSeeded = new List()); } reference = ref settings; if (reference.StarterKitChestOptOut == null) { List list = (reference.StarterKitChestOptOut = new List()); } reference = ref settings; if (reference.HeartFuelSeeded == null) { List list = (reference.HeartFuelSeeded = new List()); } reference = ref settings; if (reference.HeartFuelOptOut == null) { List list = (reference.HeartFuelOptOut = new List()); } reference = ref settings; if (reference.ItemAliases == null) { Dictionary dictionary3 = (reference.ItemAliases = new Dictionary()); } reference = ref settings; if (reference.ItemAliasNames == null) { Dictionary dictionary5 = (reference.ItemAliasNames = new Dictionary()); } return settings; } public SettingsRow GetSettings(ulong playerId) { if (!TryRow(playerId, out var settings)) { return new SettingsRow(); } return settings; } public SettingsRow GetGlobalSettings() { return playerSettings[0uL]; } public bool IsRrGlobalEnabled(ulong playerId) { return SettingsExtras.IsRrGlobalEnabled(playerId); } public bool ToggleRrGlobal(ulong playerId = 0uL) { return SettingsExtras.ToggleRrGlobal(playerId); } public bool IsRrGlobalServerAllowed() { return SettingsExtras.IsRrGlobalServerAllowed(); } public int GetPullReserve(ulong playerId, PrefabGUID item = default(PrefabGUID)) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.GetPullReserve(playerId, item); } public int SetPullReserve(ulong playerId, int amount) { return SettingsExtras.SetPullReserve(playerId, amount); } public int SetItemReserve(ulong playerId, PrefabGUID item, string itemName, int amount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.SetItemReserve(playerId, item, itemName, amount); } public bool ClearItemReserve(ulong playerId, PrefabGUID item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.ClearItemReserve(playerId, item); } public IEnumerable<(string name, int amount)> ListItemReserves(ulong playerId) { return SettingsExtras.ListItemReserves(playerId); } public int GetItemReserveOverrideCount(ulong playerId) { return SettingsExtras.GetItemReserveOverrideCount(playerId); } public bool TryGetItemCap(ulong playerId, PrefabGUID item, out int cap) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.TryGetItemCap(playerId, item, out cap); } public int SetItemCap(ulong playerId, PrefabGUID item, string itemName, int amount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.SetItemCap(playerId, item, itemName, amount); } public bool ClearItemCap(ulong playerId, PrefabGUID item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.ClearItemCap(playerId, item); } public IEnumerable<(string name, int amount)> ListItemCaps(ulong playerId) { return SettingsExtras.ListItemCaps(playerId); } public int GetItemCapOverrideCount(ulong playerId) { return SettingsExtras.GetItemCapOverrideCount(playerId); } public bool IsConveyorLoopsAllowed() { return SettingsExtras.IsConveyorLoopsAllowed(); } public bool ToggleConveyorLoops() { return SettingsExtras.ToggleConveyorLoops(); } public bool IsGlobalSalvageEnabled() { return SettingsExtras.IsGlobalSalvageEnabled(); } public bool GetPlotSalvageFlag(ulong heartOwnerId, int territoryId) { return SettingsExtras.GetPlotSalvageFlag(heartOwnerId, territoryId); } public bool TogglePlotSalvage(ulong heartOwnerId, int territoryId) { return SettingsExtras.TogglePlotSalvage(heartOwnerId, territoryId); } public bool IsHeartFeedEnabled(ulong heartOwnerId, int territoryId) { return SettingsExtras.IsHeartFeedEnabled(heartOwnerId, territoryId); } public bool ToggleHeartFeed(ulong heartOwnerId, int territoryId) { return SettingsExtras.ToggleHeartFeed(heartOwnerId, territoryId); } public bool IsHeartFuelSeeded(string heartKey) { return SettingsExtras.IsHeartFuelSeeded(heartKey); } public void MarkHeartFuelSeeded(params string[] heartKeys) { SettingsExtras.MarkHeartFuelSeeded(heartKeys); } public bool IsHeartFuelOptOut(string heartKey) { return SettingsExtras.IsHeartFuelOptOut(heartKey); } public void SetHeartFuelOptOut(bool optedOut, params string[] heartKeys) { SettingsExtras.SetHeartFuelOptOut(optedOut, heartKeys); } public bool IsAutoEnabled(ulong platformId) { return SettingsExtras.IsAutoEnabled(platformId); } public bool ToggleAuto(ulong platformId) { return SettingsExtras.ToggleAuto(platformId); } public static bool TryParseAutoFilter(string value, out AutoFilter filter) { return SettingsExtras.TryParseAutoFilter(value, out filter); } public AutoFilter GetAutoFilter(ulong platformId) { return SettingsExtras.GetAutoFilter(platformId); } public AutoFilter SetAutoFilter(ulong platformId, AutoFilter filter) { return SettingsExtras.SetAutoFilter(platformId, filter); } public void SetAutoOnWithFilter(ulong platformId, AutoFilter filter) { SettingsExtras.SetAutoOnWithFilter(platformId, filter); } public static bool TryParseNotifyMode(string value, out NotifyMode mode) { return SettingsExtras.TryParseNotifyMode(value, out mode); } public NotifyMode GetNotifyMode(ulong platformId) { return SettingsExtras.GetNotifyMode(platformId); } public NotifyMode SetNotifyMode(ulong platformId, NotifyMode mode) { return SettingsExtras.SetNotifyMode(platformId, mode); } public float GetRadius(ulong platformId) { return SettingsExtras.GetRadius(platformId); } public float SetRadius(ulong platformId, float radius) { return SettingsExtras.SetRadius(platformId, radius); } public CapMode GetCapMode(ulong platformId) { return SettingsExtras.GetCapMode(platformId); } public CapMode SetCapMode(ulong platformId, CapMode mode) { return SettingsExtras.SetCapMode(platformId, mode); } public bool IsExcluded(ulong platformId, PrefabGUID item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.IsExcluded(platformId, item); } public bool ToggleExclude(ulong platformId, PrefabGUID item, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.ToggleExclude(platformId, item, name); } public IReadOnlyList<(PrefabGUID prefab, string name)> ListExcludes(ulong platformId) { return SettingsExtras.ListExcludes(platformId); } public int GetCap(ulong platformId, PrefabGUID item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.GetCap(platformId, item); } public void SetScoopCap(ulong platformId, PrefabGUID item, int cap, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SettingsExtras.SetScoopCap(platformId, item, cap, name); } public void ClearAllScoopCaps(ulong platformId) { SettingsExtras.ClearAllScoopCaps(platformId); } public IReadOnlyList<(PrefabGUID prefab, string name, int cap)> ListScoopCaps(ulong platformId) { return SettingsExtras.ListScoopCaps(platformId); } public bool IsClanShareEnabled(ulong playerId) { return SettingsExtras.IsClanShareEnabled(playerId); } public bool ToggleClanShare(ulong playerId) { return SettingsExtras.ToggleClanShare(playerId); } public bool TryGetClanShareFlag(string clanKey, out bool enabled) { return SettingsExtras.TryGetClanShareFlag(clanKey, out enabled); } public void SetClanShareForClan(string clanKey, bool enabled) { SettingsExtras.SetClanShareForClan(clanKey, enabled); } public bool ToggleClanShareForClan(string clanKey, bool current) { return SettingsExtras.ToggleClanShareForClan(clanKey, current); } public bool IsTerritoryClanShareExcluded(int territoryId) { return SettingsExtras.IsTerritoryClanShareExcluded(territoryId); } public bool ToggleTerritoryClanShareExclude(int territoryId) { return SettingsExtras.ToggleTerritoryClanShareExclude(territoryId); } public bool IsStarterKitSeeded(string key) { return SettingsExtras.IsStarterKitSeeded(key); } public void MarkStarterKitSeeded(params string[] keys) { SettingsExtras.MarkStarterKitSeeded(keys); } public bool IsStarterKitChestSeeded(string key) { return SettingsExtras.IsStarterKitChestSeeded(key); } public void MarkStarterKitChestSeeded(params string[] keys) { SettingsExtras.MarkStarterKitChestSeeded(keys); } public bool IsStarterKitChestOptOut(string key) { return SettingsExtras.IsStarterKitChestOptOut(key); } public void SetStarterKitChestOptOut(bool optedOut, params string[] keys) { SettingsExtras.SetStarterKitChestOptOut(optedOut, keys); } public bool HasItemGroup(ulong playerId, string name) { return SettingsExtras.HasItemGroup(playerId, name); } public IEnumerable<(string name, int count)> ListCustomGroups(ulong playerId) { return SettingsExtras.ListCustomGroups(playerId); } public IEnumerable<(string guid, string name)> ListItemGroupMembers(ulong playerId, string name) { return SettingsExtras.ListItemGroupMembers(playerId, name); } public bool CreateItemGroup(ulong playerId, string name) { return SettingsExtras.CreateItemGroup(playerId, name); } public bool DeleteItemGroup(ulong playerId, string name) { return SettingsExtras.DeleteItemGroup(playerId, name); } public bool AddItemToGroup(ulong playerId, string name, PrefabGUID item, string itemName) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.AddItemToGroup(playerId, name, item, itemName); } public bool RemoveItemFromGroup(ulong playerId, string name, PrefabGUID item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return SettingsExtras.RemoveItemFromGroup(playerId, name, item); } public int ApplyGroupAmounts(ulong playerId, IReadOnlyList<(PrefabGUID guid, string name)> items, bool isCap, int amount) { return SettingsExtras.ApplyGroupAmounts(playerId, items, isCap, amount); } public bool IsDeletedGroup(ulong playerId, string name) { return SettingsExtras.IsDeletedGroup(playerId, name); } public bool HasGroupOverlay(ulong playerId, string name) { return SettingsExtras.HasGroupOverlay(playerId, name); } public void WriteGroupOverlay(ulong playerId, string name, IEnumerable<(string guid, string itemName)> members) { SettingsExtras.WriteGroupOverlay(playerId, name, members); } public bool DeleteBuiltInGroup(ulong playerId, string name) { return SettingsExtras.DeleteBuiltInGroup(playerId, name); } public bool RestoreBuiltInGroup(ulong playerId, string name) { return SettingsExtras.RestoreBuiltInGroup(playerId, name); } public List RestoreAllBuiltInGroups(ulong playerId, IEnumerable builtInNames) { return SettingsExtras.RestoreAllBuiltInGroups(playerId, builtInNames); } } internal static class PlayerWithdraw { public static void Pull(Entity character, PrefabGUID item, int quantity) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) if (Core.PlayerSettings.IsPullEnabled()) { User user = (User)(character.Has() ? character.Read().UserEntity.Read() : default(User)); Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Pulling is globally disabled."); return; } ItemData val = default(ItemData); if (!Core.GameDataSystem.ItemHashLookupMap.TryGetValue(item, ref val)) { User user2 = character.Read().UserEntity.Read(); Utilities.SendSystemMessageToClient(Core.EntityManager, user2, "Invalid item specified."); return; } if (!PlayerActionGate.TryOpen(character, "pull", requireAlliedHeart: true, out var ctx, out var deny)) { if (ctx.UserEntity != Entity.Null) { PlayerActionGate.Deny(ctx.User, deny); } return; } Entity to = default(Entity); if (!InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, character, ref to, 0)) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("No inventory found for character "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(character); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogWarning(val2); return; } bool flag2 = Core.PlayerSettings.IsSilentPullEnabled(ctx.User.PlatformId); int num = quantity; bool flag3 = false; int slot = 0; bool full = false; HashSet hashSet = new HashSet(); ServerGameManager serverGameManager = Core.ServerGameManager; for (int i = 0; i < 3; i++) { if (num <= 0) { break; } if (full) { break; } foreach (Entity item2 in Core.Stash.IslandChests(character)) { if (num <= 0) { break; } if (item2.Has() || StashRouting.SourcePass(item2) != i || !StashRouting.TryGetExternalInventory(item2, out var inventory) || !hashSet.Add(inventory)) { continue; } flag3 = true; int inventoryItemCount = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, item); if (inventoryItemCount <= 0) { continue; } int amount = Mathf.Min(inventoryItemCount, num); int num2 = Take(serverGameManager, inventory, to, item, amount, ref slot, ref full); if (num2 <= 0) { if (full) { break; } continue; } if (!flag2) { Utilities.SendSystemMessageToClient(Core.EntityManager, ctx.User, $"{num2}x {item.PrefabName()} fetched from {item2.EntityName()}"); } DestDebugLog.Move("pull", ctx.StandingPlot, item, num2, item2, Entity.Null, "player", 0, "stays"); num -= num2; if (num <= 0 || full) { break; } } } if (!flag3) { PlayerActionGate.Deny(ctx.User, "Unable to pull as no available stashes found in your current territory!"); } else if (num <= 0) { PlayerActionGate.Deny(ctx.User, $"Pulled {quantity}x {item.PrefabName()} from containers."); } else { PlayerActionGate.Deny(ctx.User, $"Was able to only pull {quantity - num}x out of desired {quantity}x {item.PrefabName()} from containers."); DestDebugLog.Miss("pull", ctx.StandingPlot, item, quantity - num, quantity, "short steam=" + ctx.User.PlatformId); } if (full) { PlayerActionGate.Deny(ctx.User, "Inventory is full, unable to pull more items."); } if (flag3) { PlayerActionGate.Deny(ctx.User, $"Remaining in stores: {CountStores(character, item)}"); } } private static int Take(ServerGameManager sgm, Entity from, Entity to, PrefabGUID item, int amount, ref int slot, ref bool full) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (SlotIsEntity(sgm, from, item)) { if (Utilities.TransferItemEntities(from, to, item, amount, ref slot, out var amountTransferred)) { full = true; } return amountTransferred; } return Utilities.TransferItems(sgm, from, to, item, amount); } private static bool SlotIsEntity(ServerGameManager sgm, Entity inventory, PrefabGUID item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref sgm)).TryGetBuffer(inventory, ref val)) { return false; } for (int i = 0; i < val.Length; i++) { InventoryBuffer val2 = val[i]; if (!((PrefabGUID)(ref val2.ItemType)).Equals(item)) { continue; } val2 = val[i]; Entity entityOnServer = ((NetworkedEntity)(ref val2.ItemEntity)).GetEntityOnServer(); if (!((Entity)(ref entityOnServer)).Equals(Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { return true; } } } return false; } internal static int CountStores(Entity character, PrefabGUID item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) int num = 0; ServerGameManager serverGameManager = Core.ServerGameManager; foreach (Entity item2 in Core.Stash.IslandChests(character)) { if (!item2.Has() && !StashRouting.IsNoShare(item2) && StashRouting.TryGetExternalInventory(item2, out var inventory)) { num += ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, item); } } return num; } internal static int CountTakeable(Entity character, PrefabGUID item, ulong leftoverOwnerId) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) int num = 0; int pullReserve = Core.PlayerSettings.GetPullReserve(leftoverOwnerId, item); ServerGameManager serverGameManager = Core.ServerGameManager; foreach (Entity item2 in Core.Stash.IslandChests(character)) { if (!item2.Has() && !StashRouting.IsNoShare(item2) && StashRouting.TryGetExternalInventory(item2, out var inventory)) { int inventoryItemCount = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, item); if (inventoryItemCount > pullReserve) { num += inventoryItemCount - pullReserve; } } } return num; } public static void Recipe(Entity character, Entity workstation, PrefabGUID recipe) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) if (!TryBag(character, out var user, out var bag)) { return; } ServerGameManager serverGameManager = Core.ServerGameManager; Entity val = StationInventory(workstation); double num = FloorMul(workstation); Entity val2 = default(Entity); if (!Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(recipe, ref val2) || !val2.Has()) { return; } DynamicBuffer val3 = val2.ReadBuffer(); int num2 = -1; Enumerator enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { RecipeRequirementBuffer current = enumerator.Current; int num3 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(bag, current.Guid); if (val != Entity.Null) { num3 += ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(val, current.Guid); } int num4 = (int)Math.Round((double)current.Amount * num, MidpointRounding.ToPositiveInfinity); int num5 = ((num4 <= 0) ? int.MaxValue : (num3 / num4)); num2 = ((num2 < 0) ? num5 : Mathf.Min(num2, num5)); } string text = RecipeLabel(val2); bool fetchedAny = false; bool fetchedAll = true; int num6 = num2 + 1; int pullReserve = Core.PlayerSettings.GetPullReserve(user.PlatformId); bool silent = Core.PlayerSettings.IsSilentPullEnabled(user.PlatformId); enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { RecipeRequirementBuffer current2 = enumerator.Current; Retrieve(character, workstation, user, bag, val, text, pullReserve, silent, ref fetchedAll, ref fetchedAny, current2.Guid, current2.Amount, num6, num, "crafting"); } if (!fetchedAny) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Couldn't find any materials for crafting additional " + text + "!"); } Utilities.SendSystemMessageToClient(Core.EntityManager, user, $"Have enough materials for crafting {(fetchedAll ? num6 : num2)}x {text}."); } public static void Repair(Entity character, PrefabGUID recipe, float repairNeeded, PrefabGUID repairing) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) User val = character.Read().UserEntity.Read(); Entity val2 = default(Entity); if (recipe == PrefabGUID.Empty) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, repairing.PrefabName() + " has no repair recipe."); } else if (!Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(recipe, ref val2) || !val2.Has()) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, repairing.PrefabName() + " has an invalid repair recipe."); } else { Entity val3 = default(Entity); if (!InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, character, ref val3, 0)) { return; } ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val4 = val2.ReadBuffer(); bool flag = false; Enumerator enumerator = val4.GetEnumerator(); while (enumerator.MoveNext()) { ItemRepairBuffer current = enumerator.Current; if (((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(val3, current.Guid) < current.Stacks) { flag = true; break; } } if (!flag) { return; } if (Core.PlayerSettings.IsPullEnabled()) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, "Pulling is globally disabled."); return; } if (!PlayerActionGate.TryOpen(character, "pull", requireAlliedHeart: true, out var ctx, out var deny)) { if (ctx.UserEntity != Entity.Null) { PlayerActionGate.Deny(ctx.User, deny); } return; } string recipeName = RecipeLabel(val2); bool fetchedAny = false; bool fetchedAll = true; int pullReserve = Core.PlayerSettings.GetPullReserve(val.PlatformId); bool silent = Core.PlayerSettings.IsSilentPullEnabled(val.PlatformId); enumerator = val4.GetEnumerator(); while (enumerator.MoveNext()) { ItemRepairBuffer current2 = enumerator.Current; int perCraft = (int)Math.Ceiling((float)current2.Stacks * (1f - repairNeeded)); Retrieve(character, Entity.Null, val, val3, Entity.Null, recipeName, pullReserve, silent, ref fetchedAll, ref fetchedAny, current2.Guid, perCraft, 1, 1.0, "repairing", excludeTreasuryRoom: true); } } } public static void Forge(Entity character, Entity workstation, Entity item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (!TryBag(character, out var user, out var bag)) { return; } ServerGameManager serverGameManager = Core.ServerGameManager; Entity val = StationInventory(workstation); double num = FloorMul(workstation); DynamicBuffer val2 = item.ReadBuffer(); int num2 = -1; Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { ShatteredItemRepairCost current = enumerator.Current; int num3 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(bag, current.ItemId); if (val != Entity.Null) { num3 += ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(val, current.ItemId); } int num4 = (int)Math.Round((double)current.Amount * num, MidpointRounding.ToPositiveInfinity); int num5 = ((num4 <= 0) ? int.MaxValue : (num3 / num4)); num2 = ((num2 < 0) ? num5 : Mathf.Min(num2, num5)); } string text = item.Read().PrefabName(); bool fetchedAny = false; bool fetchedAll = true; int num6 = num2 + 1; int pullReserve = Core.PlayerSettings.GetPullReserve(user.PlatformId); bool silent = Core.PlayerSettings.IsSilentPullEnabled(user.PlatformId); enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { ShatteredItemRepairCost current2 = enumerator.Current; Retrieve(character, workstation, user, bag, val, text, pullReserve, silent, ref fetchedAll, ref fetchedAny, current2.ItemId, current2.Amount, num6, num, "forging"); } if (!fetchedAny) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Couldn't find any materials for forging additional " + text + "!"); } Utilities.SendSystemMessageToClient(Core.EntityManager, user, $"Have enough materials for forging {(fetchedAll ? num6 : num2)}x {text}."); } public static void ForgeUpgrade(Entity character, Entity workstation, Entity item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (TryBag(character, out var user, out var bag)) { ServerGameManager serverGameManager = Core.ServerGameManager; Entity val = StationInventory(workstation); DynamicBuffer val2 = item.ReadBuffer(); UpgradeableLegendaryItem val3 = item.Read(); UpgradeableLegendaryItemTiers val4 = val2[((UpgradeableLegendaryItem)(ref val3)).NextTier]; int num = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(bag, val4.TierPrefab); if (val != Entity.Null) { num += ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(val, val4.TierPrefab); } string text = item.Read().PrefabName(); bool fetchedAny = false; bool fetchedAll = true; int num2 = num + 1; int pullReserve = Core.PlayerSettings.GetPullReserve(user.PlatformId); bool silent = Core.PlayerSettings.IsSilentPullEnabled(user.PlatformId); Retrieve(character, workstation, user, bag, val, text, pullReserve, silent, ref fetchedAll, ref fetchedAny, val4.TierPrefab, 1, num2, 1.0, "upgrading"); if (!fetchedAny) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Couldn't find any materials for upgrading additional " + text + "!"); } Utilities.SendSystemMessageToClient(Core.EntityManager, user, $"Have enough materials for upgrading {(fetchedAll ? num2 : num)}x {text}."); } } private static bool TryBag(Entity character, out User user, out Entity bag) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) user = character.Read().UserEntity.Read(); if (!InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, character, ref bag, 0)) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No inventory found for character "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(character); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogWarning(val); return false; } return true; } private static Entity StationInventory(Entity workstation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (workstation == Entity.Null) { return Entity.Null; } if (!StashRouting.TryGetExternalInventory(workstation, out var inventory)) { return Entity.Null; } return inventory; } private static double FloorMul(Entity workstation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (workstation == Entity.Null || !workstation.Has()) { return 1.0; } if (!((Enum)workstation.Read().WorkstationLevel).HasFlag((Enum)(object)(WorkstationLevel)2)) { return 1.0; } return 0.75; } private static string RecipeLabel(Entity recipeEnt) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) string result = recipeEnt.Read().LookupName(); if (recipeEnt.Has()) { DynamicBuffer val = recipeEnt.ReadBuffer(); if (val.Length > 0) { result = val[0].Guid.PrefabName(); } } return result; } private static bool BusyWith(Entity stash, PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) PrefabGUID guid; if (stash.Has()) { UnitSpawnerstation val = stash.Read(); Entity entity = default(Entity); if (val.IsWorking && Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(val.CurrentRecipeGuid, ref entity) && entity.Has()) { Enumerator enumerator = entity.ReadBuffer().GetEnumerator(); while (enumerator.MoveNext()) { RecipeRequirementBuffer current = enumerator.Current; guid = current.Guid; if (((PrefabGUID)(ref guid)).Equals(item)) { return true; } } } } if (stash.Has()) { Refinementstation val2 = stash.Read(); Entity entity2 = default(Entity); if (val2.IsWorking && Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(val2.CurrentRecipeGuid, ref entity2) && entity2.Has()) { Enumerator enumerator = entity2.ReadBuffer().GetEnumerator(); while (enumerator.MoveNext()) { RecipeRequirementBuffer current2 = enumerator.Current; guid = current2.Guid; if (((PrefabGUID)(ref guid)).Equals(item)) { return true; } } } } return false; } private static void Retrieve(Entity character, Entity workstation, User user, Entity bag, Entity stationInv, string recipeName, int reserve, bool silent, ref bool fetchedAll, ref bool fetchedAny, PrefabGUID item, int perCraft, int wantMultiple, double floor, string verb, bool excludeTreasuryRoom = false) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) reserve = Core.PlayerSettings.GetPullReserve(user.PlatformId, item); ServerGameManager serverGameManager = Core.ServerGameManager; int num = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(bag, item); if (stationInv != Entity.Null) { num += ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(stationInv, item); } int num2 = wantMultiple * (int)Math.Round((double)perCraft * floor, MidpointRounding.ToPositiveInfinity); if (num >= num2) { return; } if (!fetchedAny) { fetchedAny = true; if (!silent) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, $"Fetching materials for {verb} {recipeName}..."); } } int num3 = num2 - num; int slot = 0; bool full = false; HashSet hashSet = new HashSet(); for (int i = 0; i < 3; i++) { if (num3 <= 0) { break; } if (full) { break; } foreach (Entity item2 in Core.Stash.IslandChests(character)) { Entity current = item2; if (full || num3 <= 0) { break; } if (current.Has() || ((Entity)(ref current)).Equals(workstation) || StashRouting.SourcePass(current) != i || BusyWith(current, item) || !StashRouting.TryGetExternalInventory(current, out var inventory) || !hashSet.Add(inventory)) { continue; } bool flag = false; if (excludeTreasuryRoom && current.Has()) { CastleRoomConnection val = current.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.RoomEntity)).GetEntityOnServer(); flag = entityOnServer != Entity.Null && Utilities.IsRoomOfType(entityOnServer, (CastleFloorTypes)14); } int num4 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, item); if (reserve > 0) { num4 -= reserve; } if (num4 <= 0) { continue; } int num5 = Mathf.Min(num4, num3); int num6 = 0; num6 = ((excludeTreasuryRoom && flag) ? num5 : Take(serverGameManager, inventory, bag, item, num5, ref slot, ref full)); if (num6 <= 0) { continue; } if (!silent) { if (excludeTreasuryRoom && flag) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, $"{num6}x {item.PrefabName()} used from {current.EntityName()} in the Treasury Room"); } else { Utilities.SendSystemMessageToClient(Core.EntityManager, user, $"{num6}x {item.PrefabName()} fetched from {current.EntityName()}"); } } num3 -= num6; } } if (num3 > 0) { fetchedAll = false; Utilities.SendSystemMessageToClient(Core.EntityManager, user, $"Couldn't find {num3}x {item.PrefabName()}"); } } } internal sealed class ProxLights { private readonly HeartBoundIndex index; private readonly Dictionary> proxTouched; private const float TickSeconds = 2.5f; private const float Range = 20f; public ProxLights(HeartBoundIndex index, Dictionary> proxTouched) { this.index = index; this.proxTouched = proxTouched; Core.StartCoroutine(Tick()); } private IEnumerator Tick() { WaitForSeconds wait = new WaitForSeconds(2.5f); while (true) { yield return wait; if (!Core.HasInitialized || !Core.PlayerSettings.IsSolarEnabled(0uL)) { continue; } foreach (int item in index.OccupiedTerritoryIds()) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(item); if (!(castleHeart == Entity.Null)) { try { ApplyProximity(item, castleHeart); } catch (Exception e) { Core.LogException(e, "Tick"); } } } } } private unsafe void ApplyProximity(int plot, Entity heart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) if (!Core.PlayerSettings.IsSolarEnabled(0uL) || !heart.Has()) { return; } UserOwner val = heart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer == Entity.Null || !entityOnServer.Has()) { return; } List list = new List(); CollectClanOnPlot(entityOnServer.Read(), plot, list); bool flag = list.Count > 0; if (!proxTouched.TryGetValue(plot, out var value)) { value = new HashSet(); proxTouched[plot] = value; } foreach (Entity item in index.OnTerritory(plot)) { if (!item.Has() || !item.Has()) { continue; } NameableInteractable val2 = item.Read(); string text = ((object)(*(FixedString64Bytes*)(&val2.Name))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrEmpty(text) || text.IndexOf("prox", StringComparison.OrdinalIgnoreCase) < 0) { if (value.Remove(item) && item.Has()) { Bonfire componentData = item.Read(); componentData.TimeToGetToFullStrength = 15f; item.Write(componentData); } continue; } bool flag2 = flag && AnyWithin(item, list, 20f); BurnContainer val3 = item.Read(); if (val3.Enabled != flag2) { val3.Enabled = flag2; item.Write(val3); if (value.Add(item) && item.Has()) { Bonfire componentData2 = item.Read(); componentData2.TimeToGetToFullStrength = 0.5f; item.Write(componentData2); } } } } private static void CollectClanOnPlot(User owner, int plot, List into) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) Entity entityOnServer = ((NetworkedEntity)(ref owner.ClanEntity)).GetEntityOnServer(); if (entityOnServer == Entity.Null) { if (owner.IsConnected) { Entity entityOnServer2 = ((NetworkedEntity)(ref owner.LocalCharacter)).GetEntityOnServer(); if (entityOnServer2 != Entity.Null && Core.TerritoryService.GetStandingTerritoryId(entityOnServer2) == plot) { into.Add(entityOnServer2); } } return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasBuffer(entityOnServer)) { return; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasBuffer(entityOnServer)) { return; } entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(entityOnServer, false); entityManager = Core.EntityManager; DynamicBuffer buffer2 = ((EntityManager)(ref entityManager)).GetBuffer(entityOnServer, false); int num = ((buffer.Length < buffer2.Length) ? buffer.Length : buffer2.Length); for (int i = 0; i < num; i++) { if (buffer[i].IsConnected) { User val = buffer2[i].UserEntity.Read(); Entity entityOnServer3 = ((NetworkedEntity)(ref val.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer3 == Entity.Null) && Core.TerritoryService.GetStandingTerritoryId(entityOnServer3) == plot) { into.Add(entityOnServer3); } } } } private static bool AnyWithin(Entity brazier, List people, float range) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!brazier.Has()) { return false; } Translation val = brazier.Read(); float2 xz = ((float3)(ref val.Value)).xz; for (int i = 0; i < people.Count; i++) { Entity val2 = people[i]; if (val2 == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val2) && val2.Has()) { Vector2 val3 = float2.op_Implicit(xz); val = val2.Read(); if (Vector2.Distance(val3, float2.op_Implicit(((float3)(ref val.Value)).xz)) <= range) { return true; } } } return false; } } internal class PullService { public static void PullItem(Entity character, PrefabGUID item, int quantity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) PlayerWithdraw.Pull(character, item, quantity); } internal static int CountAlliedStores(Entity character, PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return PlayerWithdraw.CountStores(character, item); } internal static int CountAlliedTakeable(Entity character, PrefabGUID item, ulong leftoverOwnerId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return PlayerWithdraw.CountTakeable(character, item, leftoverOwnerId); } public static void HandleRecipePull(Entity character, Entity workstation, PrefabGUID recipe) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) PlayerWithdraw.Recipe(character, workstation, recipe); } public static void HandleRepairPull(Entity character, PrefabGUID recipe, float repairNeeded, PrefabGUID repairing) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) PlayerWithdraw.Repair(character, recipe, repairNeeded, repairing); } public static void HandleForgePull(Entity character, Entity workstation, Entity item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) PlayerWithdraw.Forge(character, workstation, item); } public static void HandleForgeUpgradePull(Entity character, Entity workstation, Entity item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) PlayerWithdraw.ForgeUpgrade(character, workstation, item); } } internal sealed class RefinementStationsService { private readonly HeartBoundIndex index; private readonly Regex receiveToken; private readonly Regex sendToken; private static ComponentType[] QueryTypes => (ComponentType[])(object)new ComponentType[7] { ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()) }; public RefinementStationsService() { receiveToken = new Regex("r(\\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); sendToken = new Regex("s(\\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); index = HeartBoundIndex.Scan(includeDisabled: true, QueryTypes); } internal void AddRefinementStation(Entity station) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) index.Track(station); } internal void RemoveRefinementStation(Entity station) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) index.Untrack(station); } public IEnumerable<(int group, Entity station)> ReceiveBenches(int territoryId) { return NamedGroups(receiveToken, territoryId); } public IEnumerable<(int group, Entity station)> SendBenches(int territoryId) { return NamedGroups(sendToken, territoryId); } public IEnumerable BenchesOnPlot(int territoryId) { return index.OnTerritory(territoryId); } private unsafe IEnumerable<(int group, Entity station)> NamedGroups(Regex token, int territoryId) { foreach (Entity station in index.OnTerritory(territoryId)) { if (!station.Has()) { continue; } NameableInteractable val = station.Read(); string text = ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrEmpty(text)) { continue; } foreach (Match item in token.Matches(text)) { if (int.TryParse(item.Groups[1].Value, out var result)) { yield return (group: result, station: station); } } } } } internal class RegionService { private readonly record struct Hull(WorldRegionType Kind, Aabb Box, float2[] Ring) { [CompilerGenerated] public void Deconstruct(out WorldRegionType Kind, out Aabb Box, out float2[] Ring) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected I4, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Kind = (WorldRegionType)(int)this.Kind; Box = this.Box; Ring = this.Ring; } } private readonly List hulls = new List(); public RegionService() { Rescan(); } public void Rescan() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) hulls.Clear(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadWrite(Il2CppType.Of())); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val4.Length; i++) { WorldRegionPolygon val5 = val4[i].Read(); entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(val4[i], false); float2[] array = (float2[])(object)new float2[buffer.Length]; for (int j = 0; j < buffer.Length; j++) { array[j] = buffer[j].VertexPos; } hulls.Add(new Hull(val5.WorldRegion, val5.PolygonBounds, array)); } } finally { val4.Dispose(); ((EntityQuery)(ref val3)).Dispose(); } } public WorldRegionType GetRegion(Entity entity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return GetRegion(entity.Read().Value); } public WorldRegionType GetRegion(float3 pos) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < hulls.Count; i++) { Aabb box = hulls[i].Box; if (((Aabb)(ref box)).Contains(pos) && OddCrossings(hulls[i].Ring, ((float3)(ref pos)).xz)) { return hulls[i].Kind; } } return (WorldRegionType)0; } private static bool OddCrossings(float2[] ring, float2 point) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = ring.Length; if (num2 == 0) { return false; } int num3 = 0; int num4 = num2 - 1; while (num3 < num2) { float2 val = ring[num3]; float2 val2 = ring[num4]; if (val.y > point.y != val2.y > point.y && point.x < val.x + (point.y - val.y) / (val2.y - val.y) * (val2.x - val.x)) { num++; } num4 = num3++; } return (num & 1) == 1; } } internal static class RepeatHunts { private struct Recipe { public int Plot; public NetworkId Throne; public NetworkId S1; public NetworkId S2; public NetworkId S3; public int MissionDataId; public PrefabGUID MissionPrefab; public MapZoneId Zone; public string DestName; public float SuccessPct; } private struct PendingReturn { public Recipe Hunt; public List Servants; public Entity Heart; } private static float lastSuccess = -1f; private static bool capThisTick; private static readonly List<(Recipe Hunt, Entity User)> pendingStarts = new List<(Recipe, Entity)>(); internal const string ClientJsonPath = "C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\repeathunt-client.json"; private static readonly Dictionary byPlot = new Dictionary(); private static readonly List pending = new List(); private static readonly Dictionary> pendingList = new Dictionary>(); private static readonly TimeSpan ListTtl = TimeSpan.FromMinutes(2.0); private static readonly Dictionary pendingListAt = new Dictionary(); private static int capSuccessFrames; private static Entity autoThrone; private static Entity autoCharacter; private static Entity autoUser; private static int autoFrames; private static bool skipSendChat; private static string lastFail = ""; private static List savedMissionSettings; private static Entity autoInteractChar; private static Entity autoInteractOldTarget; private static NetworkId autoInteractOldNid; private static bool autoInteractSaved; public static bool ShouldCapSuccess { get { if (!capThisTick) { return capSuccessFrames > 0; } return true; } } public static void NoteSuccess(float chance) { if (!(chance < 0f) && (lastSuccess < 0f || chance < lastSuccess)) { lastSuccess = chance; } } public static bool IsOn(int plot) { return Core.PlayerSettings.IsRepeatHuntPlotOn(plot); } public static bool IsAutoSend(Entity throne, Entity character) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (autoFrames <= 0 || throne == Entity.Null || character == Entity.Null) { return false; } if (throne == autoThrone) { if (!(character == autoCharacter)) { return character == autoUser; } return true; } return false; } public static void TickAutoSend() { if (autoFrames > 0) { autoFrames--; } if (autoFrames <= 0) { RestoreInteractor(); } } public static void TickCapFrames() { if (capSuccessFrames > 0) { capSuccessFrames--; } } public static void CaptureActiveMissions(int plotFilter = -1) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { return; } EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5)) { continue; } int territoryId = Core.TerritoryService.GetTerritoryId(val5); if (territoryId < 0 || (plotFilter >= 0 && territoryId != plotFilter)) { continue; } DynamicBuffer val6; try { val6 = val5.ReadBuffer(); } catch { continue; } for (int j = 0; j < val6.Length; j++) { ActiveServantMission mission = val6[j]; Recipe value = RecipeFromMission(territoryId, val5, mission); if (Core.TryGetEntityFromNetworkId(value.Throne, out var _)) { byPlot[territoryId] = value; DestDebugLog.Note("throne", territoryId, 0uL, "capture in-flight hunt"); } } } } catch (Exception e) { Core.LogException(e, "CaptureActiveMissions"); } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } } public static void Remember(Entity eventEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) if (eventEntity == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(eventEntity) || !eventEntity.Has()) { return; } SendOnMissionEvent val = eventEntity.Read(); if (!Core.TryGetEntityFromNetworkId(val.Throne, out var entity) || entity == Entity.Null) { return; } int territoryId = Core.TerritoryService.GetTerritoryId(entity); if (territoryId >= 0) { Recipe recipe = new Recipe { Plot = territoryId, Throne = val.Throne, S1 = val.Servant1, S2 = val.Servant2, S3 = val.Servant3, MissionDataId = val.MissionDataID, Zone = val.MapZoneId, DestName = DestLabel(val.MapZoneId, default(PrefabGUID)), SuccessPct = -1f }; if (byPlot.TryGetValue(territoryId, out var value)) { MergeRecipe(ref recipe, value); } FillDest(ref recipe); byPlot[territoryId] = recipe; Entity item = Entity.Null; if (eventEntity.Has()) { item = eventEntity.Read().User; } pendingStarts.Add((recipe, item)); if (IsOn(territoryId)) { capThisTick = true; } DestDebugLog.Note("throne", territoryId, 0uL, "remember hunt " + recipe.DestName + " z=" + ZoneTag(recipe.Zone) + " slot=" + ClampSetting(recipe.MissionDataId) + " prefab=" + ((PrefabGUID)(ref recipe.MissionPrefab)).GuidHash); } } public static void AfterSends() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) try { for (int i = 0; i < pendingStarts.Count; i++) { Recipe recipe = pendingStarts[i].Hunt; Entity item = pendingStarts[i].User; if (lastSuccess >= 0f) { recipe.SuccessPct = lastSuccess; } if (byPlot.TryGetValue(recipe.Plot, out var value)) { MergeRecipe(ref recipe, value); } FillDest(ref recipe); byPlot[recipe.Plot] = recipe; if (!skipSendChat) { ChatSent(recipe, item); } DestDebugLog.Note("throne", recipe.Plot, 0uL, "sent " + recipe.DestName + " " + ((recipe.SuccessPct >= 0f) ? ((int)(recipe.SuccessPct * 100f + 0.5f) + "%") : "?") + " rh=" + (IsOn(recipe.Plot) ? "on" : "off") + (skipSendChat ? " auto" : "")); } } finally { pendingStarts.Clear(); lastSuccess = -1f; capThisTick = false; skipSendChat = false; } } private static void ChatSent(Recipe hunt, Entity userEnt) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) List list = new List(3); AddServantName(list, hunt.S1); AddServantName(list, hunt.S2); AddServantName(list, hunt.S3); bool flag = IsOn(hunt.Plot); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Hunt sent"); if (hunt.Plot >= 0) { stringBuilder.Append(" (").Append(Core.TerritoryService.FormatPlotLabel(hunt.Plot)).Append(')'); } if (!string.IsNullOrWhiteSpace(hunt.DestName)) { stringBuilder.Append(" — ").Append(hunt.DestName); } if (hunt.SuccessPct >= 0f) { stringBuilder.Append(" (").Append((int)(hunt.SuccessPct * 100f + 0.5f)).Append("%)"); } stringBuilder.Append(": "); if (list.Count > 0) { stringBuilder.Append(string.Join(", ", list)); } else { stringBuilder.Append("servants"); } stringBuilder.Append(". Repeat ").Append(flag ? "ON" : "OFF"); if (flag) { stringBuilder.Append(" (max ").Append(Core.PlayerSettings.GetRepeatHuntMaxSuccess()).Append("%)"); } string text = Trim(stringBuilder.ToString()); TellClan((hunt.Plot >= 0) ? Core.TerritoryService.GetCastleHeart(hunt.Plot) : Entity.Null, text); } private static void AddServantName(List names, NetworkId nid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (TryServant(nid, out var servant)) { names.Add(ServantName(servant)); } } public static void PublishClientState() { try { bool flag = Core.PlayerSettings.IsRepeatHuntEnabled(); int repeatHuntMaxSuccess = Core.PlayerSettings.GetRepeatHuntMaxSuccess(); string text = ""; if (Core.PlayerSettings.TryWorldOffPlots(out var off) && off != null) { for (int i = 0; i < off.Count; i++) { if (i > 0) { text += ","; } text = text + "\"" + off[i] + "\""; } } string contents = "{\"on\":" + (flag ? "true" : "false") + ",\"max\":" + repeatHuntMaxSuccess.ToString(CultureInfo.InvariantCulture) + ",\"off\":[" + text + "]}"; string directoryName = Path.GetDirectoryName("C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\repeathunt-client.json"); if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } string text2 = "C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\repeathunt-client.json.tmp"; File.WriteAllText(text2, contents, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); if (File.Exists("C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\repeathunt-client.json")) { File.Replace(text2, "C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\repeathunt-client.json", null); } else { File.Move(text2, "C:\\VRisingServer\\BepInEx\\config\\Satisvampory\\debug\\repeathunt-client.json"); } } catch (Exception ex) { Core.Log.LogDebug((object)("RepeatHunt client json: " + ex.Message)); } } public static void ForgetAbort(Entity eventEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (!(eventEntity == Entity.Null) && eventEntity.Has() && Core.TryGetEntityFromNetworkId(eventEntity.Read().Throne, out var entity)) { int territoryId = Core.TerritoryService.GetTerritoryId(entity); if (territoryId >= 0) { byPlot.Remove(territoryId); } } } public static void SnapshotFinishing(NativeList finished) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) pending.Clear(); if (!finished.IsCreated) { return; } for (int i = 0; i < finished.Length; i++) { MissionIdentifier val = finished[i]; Entity missionOwner = val.MissionOwner; if (missionOwner == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(missionOwner)) { continue; } DynamicBuffer val2; try { val2 = missionOwner.ReadBuffer(); } catch { continue; } if (val.MissionIndex < 0 || val.MissionIndex >= val2.Length) { continue; } ActiveServantMission val3 = val2[val.MissionIndex]; int territoryId = Core.TerritoryService.GetTerritoryId(missionOwner); if (territoryId < 0) { territoryId = Core.TerritoryService.GetTerritoryId(((NetworkedEntity)(ref val3.Servant1)).GetEntityOnServer()); } Recipe hunt = RecipeFromMission(territoryId, missionOwner, val3); if (byPlot.TryGetValue(territoryId, out var value)) { if (((NetworkId)(ref hunt.Throne)).Equals(default(NetworkId))) { hunt.Throne = value.Throne; } if (!IsSettingIndex(hunt.MissionDataId) && IsSettingIndex(value.MissionDataId)) { hunt.MissionDataId = value.MissionDataId; } } FillDest(ref hunt); List list = new List(3); AddServant(list, val3.Servant1); AddServant(list, val3.Servant2); AddServant(list, val3.Servant3); pending.Add(new PendingReturn { Hunt = hunt, Servants = list, Heart = missionOwner }); } } public static void AfterReturn() { if (pending.Count != 0) { for (int i = 0; i < pending.Count; i++) { HandleReturn(pending[i]); } pending.Clear(); } } private static void HandleReturn(PendingReturn row) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); Dictionary dictionary = new Dictionary(); for (int i = 0; i < row.Servants.Count; i++) { Entity val = row.Servants[i]; string text = ServantName(val); if (!(val == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val) && !IsDead(val)) { AddLoot(val, dictionary); if (IsInjured(val)) { list3.Add(text + " (injured)"); } else if (val.Has()) { list.Add(val.Read()); list2.Add(text); } continue; } } list3.Add(text); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Hunt returned"); if (row.Hunt.Plot >= 0) { stringBuilder.Append(" (").Append(Core.TerritoryService.FormatPlotLabel(row.Hunt.Plot)).Append(')'); } if (!string.IsNullOrWhiteSpace(row.Hunt.DestName)) { stringBuilder.Append(" — ").Append(row.Hunt.DestName); } if (row.Hunt.SuccessPct >= 0f) { stringBuilder.Append(" (").Append((int)(row.Hunt.SuccessPct * 100f + 0.5f)).Append("%)"); } stringBuilder.Append(": "); if (list2.Count > 0) { stringBuilder.Append(string.Join(", ", list2)); } if (list3.Count > 0) { if (list2.Count > 0) { stringBuilder.Append(". "); } stringBuilder.Append("Died: ").Append(string.Join(", ", list3)); } if (dictionary.Count > 0) { stringBuilder.Append(" — "); bool flag = true; foreach (KeyValuePair item in dictionary) { if (!flag) { stringBuilder.Append(", "); } flag = false; stringBuilder.Append(item.Value).Append(' ').Append(StashRouting.ItemLabel(item.Key)); } } else if (list2.Count > 0 && list3.Count == 0) { stringBuilder.Append(" — no loot"); } int num; if (IsOn(row.Hunt.Plot) && list.Count > 0) { num = (Core.TryGetEntityFromNetworkId(row.Hunt.Throne, out var _) ? 1 : 0); if (num != 0) { stringBuilder.Append(". Repeat ON — sending again."); } } else { num = 0; } TellClan(row.Heart, Trim(stringBuilder.ToString())); DestDebugLog.Note("throne", row.Hunt.Plot, 0uL, "return " + stringBuilder); HuntLoginNote.RecordHaul(row.Hunt.Plot, dictionary); if (num != 0) { Recipe hunt = row.Hunt; hunt.S1 = (NetworkId)((list.Count > 0) ? list[0] : default(NetworkId)); hunt.S2 = (NetworkId)((list.Count > 1) ? list[1] : default(NetworkId)); hunt.S3 = (NetworkId)((list.Count > 2) ? list[2] : default(NetworkId)); Core.StartCoroutine(SendSoon(row.Heart, hunt)); } } private static IEnumerator SendSoon(Entity heart, Recipe hunt) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) List list = new List(3); AddServantName(list, hunt.S1); AddServantName(list, hunt.S2); AddServantName(list, hunt.S3); string who = ((list.Count > 0) ? string.Join(", ", list) : "servants"); FillDest(ref hunt); string dest = (string.IsNullOrWhiteSpace(hunt.DestName) ? "hunt" : hunt.DestName); lastFail = ""; for (int attempt = 0; attempt < 8; attempt++) { yield return (object)new WaitForSeconds((attempt == 0) ? 3f : 1f); if (!IsOn(hunt.Plot)) { yield break; } if (!ServantsReady(ref hunt)) { lastFail = "servants not ready"; DestDebugLog.Note("throne", hunt.Plot, 0uL, "repeat wait servants not ready try=" + (attempt + 1)); continue; } if (!TrySend(heart, hunt)) { DestDebugLog.Note("throne", hunt.Plot, 0uL, "repeat TrySend false try=" + (attempt + 1) + " " + lastFail); continue; } yield return (object)new WaitForSeconds(1f); if (AnyOnMission(hunt)) { int repeatHuntMaxSuccess = Core.PlayerSettings.GetRepeatHuntMaxSuccess(); TellClan(heart, Trim("Repeat: sent " + who + " to " + dest + " (" + repeatHuntMaxSuccess + "% repeat hunt).")); DestDebugLog.Note("throne", hunt.Plot, 0uL, "repeat accepted " + dest + " " + repeatHuntMaxSuccess + "%"); yield break; } lastFail = "vanilla did not accept"; DestDebugLog.Note("throne", hunt.Plot, 0uL, "repeat not accepted try=" + (attempt + 1) + " z=" + ZoneTag(hunt.Zone) + " slot=" + ClampSetting(hunt.MissionDataId)); } string text = (string.IsNullOrWhiteSpace(lastFail) ? "throne or servants not ready" : lastFail); TellClan(heart, Trim("Repeat: could not send " + who + " to " + dest + " — " + text + ".")); DestDebugLog.Note("throne", hunt.Plot, 0uL, "repeat gave up " + dest + " " + text); } private static bool TrySend(Entity heart, Recipe hunt, bool requireRepeatOn = true) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) try { lastFail = ""; if (requireRepeatOn && !IsOn(hunt.Plot)) { lastFail = "repeat off"; return false; } if (!(heart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(heart)) { if (TerritoryService.IsHeartRaided(heart)) { lastFail = "heart raided"; return false; } if (Core.TryGetEntityFromNetworkId(hunt.Throne, out var entity) && !(entity == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity)) { FillDest(ref hunt); if (!ZoneLooksSet(hunt.Zone)) { lastFail = "no hunt zone"; DestDebugLog.Note("throne", hunt.Plot, 0uL, "repeat send missing dest name=" + hunt.DestName + " z=" + ZoneTag(hunt.Zone) + " m=" + hunt.MissionDataId); return false; } hunt.MissionDataId = ClampSetting(hunt.MissionDataId); skipSendChat = true; if (!ForceHunt(heart, hunt)) { lastFail = "could not start hunt"; return false; } DestDebugLog.Note("throne", hunt.Plot, 0uL, "force hunt " + hunt.DestName + " z=" + ZoneTag(hunt.Zone) + " slot=" + hunt.MissionDataId + " prefab=" + ((PrefabGUID)(ref hunt.MissionPrefab)).GuidHash); return true; } } lastFail = "no throne"; return false; } } lastFail = "no heart"; return false; } catch (Exception e) { lastFail = "send error"; Core.LogException(e, "TrySend"); return false; } } private static bool ForceHunt(Entity heart, Recipe hunt) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) if (!(heart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(heart) && heart.Has()) { Entity servant2; NetworkedEntity servant = NetServant(hunt.S1, out servant2); Entity servant4; NetworkedEntity servant3 = NetServant(hunt.S2, out servant4); Entity servant6; NetworkedEntity servant5 = NetServant(hunt.S3, out servant6); int num = 0; if (servant2 != Entity.Null) { num++; } if (servant4 != Entity.Null) { num++; } if (servant6 != Entity.Null) { num++; } if (num == 0) { return false; } if (servant2 != Entity.Null && OnMission(servant2)) { return false; } if (servant4 != Entity.Null && OnMission(servant4)) { return false; } if (servant6 != Entity.Null && OnMission(servant6)) { return false; } PrefabGUID asset = hunt.MissionPrefab; if (((PrefabGUID)(ref asset)).GuidHash == 0) { TryZoneByName(hunt.DestName ?? "", out var _, out var _, out asset); } if (((PrefabGUID)(ref asset)).GuidHash == 0) { return false; } ActiveServantMission val = new ActiveServantMission { MissionID = asset, MissionStartTimeTicks = DateTime.UtcNow.Ticks, MissionLengthSeconds = SettingLength(hunt.MissionDataId), MissiontDataId = hunt.MissionDataId, Servant1 = servant, Servant2 = servant3, Servant3 = servant5, NumberOfServants = num }; heart.ReadBuffer().Add(val); MarkOnMission(servant2); MarkOnMission(servant4); MarkOnMission(servant6); TryApplyMissionBuff(heart, servant2); TryApplyMissionBuff(heart, servant4); TryApplyMissionBuff(heart, servant6); return true; } } return false; } private static NetworkedEntity NetServant(NetworkId nid, out Entity servant) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) servant = Entity.Null; if (!TryServant(nid, out servant)) { return NetworkedEntity.Empty; } Entity val = CoffinOf(servant); if (val != Entity.Null && val.Has()) { return val.Read().ConnectedServant; } return NetworkedEntity.ServerEntity(servant); } private static void MarkOnMission(Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!(servant == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(servant) && servant.Has()) { ServantData componentData = servant.Read(); componentData.IsOnMission = true; servant.Write(componentData); } } } private static float SettingLength(int slot) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) slot = ClampSetting(slot); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (!(val5 == Entity.Null) && val5.Has()) { DynamicBuffer val6; try { val6 = val5.ReadBuffer(); } catch { continue; } if (slot < val6.Length && val6[slot].MissionLength > 0f) { return val6[slot].MissionLength; } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } return 7200f; } private static void TryApplyMissionBuff(Entity heart, Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (servant == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(servant) && TryFromHeart(heart, out var userEnt, out var _) && !(userEnt == Entity.Null)) { PrefabGUID prefab = MissionBuffPrefab(); if (((PrefabGUID)(ref prefab)).GuidHash != 0) { FindBuff.TryApply(userEnt, servant, prefab, 0f, immortal: true); } } } private static PrefabGUID MissionBuffPrefab() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (!(val5 == Entity.Null) && val5.Has()) { PrefabGUID missionBuff = val5.Read().MissionBuff; if (((PrefabGUID)(ref missionBuff)).GuidHash != 0) { return missionBuff; } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } return default(PrefabGUID); } private static bool ServantsReady(ref Recipe hunt) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) List list = new List(3); TryReady(hunt.S1, list); TryReady(hunt.S2, list); TryReady(hunt.S3, list); if (list.Count == 0) { return false; } hunt.S1 = (NetworkId)((list.Count > 0) ? list[0] : default(NetworkId)); hunt.S2 = (NetworkId)((list.Count > 1) ? list[1] : default(NetworkId)); hunt.S3 = (NetworkId)((list.Count > 2) ? list[2] : default(NetworkId)); return true; } private static void TryReady(NetworkId nid, List ready) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (TryServant(nid, out var servant) && !IsDead(servant) && !IsInjured(servant) && !OnMission(servant)) { ready.Add(CoffinNid(nid)); } } private static bool TryServant(NetworkId nid, out Entity servant) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) servant = Entity.Null; if (!Core.TryGetEntityFromNetworkId(nid, out var entity) || entity == Entity.Null) { return false; } EntityManager entityManager; if (entity.Has()) { ServantCoffinstation val = entity.Read(); servant = ((NetworkedEntity)(ref val.ConnectedServant)).GetEntityOnServer(); if (servant != Entity.Null) { entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).Exists(servant); } return false; } servant = entity; entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).Exists(servant); } private static bool AnyOnMission(Recipe hunt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!OnMissionNid(hunt.S1) && !OnMissionNid(hunt.S2)) { return OnMissionNid(hunt.S3); } return true; } private static bool OnMissionNid(NetworkId nid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (TryServant(nid, out var servant)) { return OnMission(servant); } return false; } private static bool OnMission(Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) if (!(servant == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(servant)) { EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5)) { continue; } DynamicBuffer val6; try { val6 = val5.ReadBuffer(); } catch { continue; } for (int j = 0; j < val6.Length; j++) { ActiveServantMission val7 = val6[j]; if (((NetworkedEntity)(ref val7.Servant1)).GetEntityOnServer() == servant || ((NetworkedEntity)(ref val7.Servant2)).GetEntityOnServer() == servant || ((NetworkedEntity)(ref val7.Servant3)).GetEntityOnServer() == servant) { return true; } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } return false; } } return false; } public static string DebugSend(int plot, string who, string dest) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) if (plot < 0) { return "{\"error\":\"need plot\"}"; } Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); if (castleHeart == Entity.Null) { return "{\"error\":\"no heart on plot " + plot + "\"}"; } Entity val = ClanThroneServants.FindThrone(plot); if (val == Entity.Null || !val.Has()) { return "{\"error\":\"no throne on plot " + plot + "\"}"; } if (!TryPickIdle(plot, who, out var nids, out var names, out var error)) { return "{\"error\":\"" + EscJson(error) + "\"}"; } if (!TryResolveDest(plot, dest, out var zone, out var destName, out var missionId, out var error2)) { return "{\"error\":\"" + EscJson(error2) + "\"}"; } Recipe recipe = new Recipe { Plot = plot, Throne = val.Read(), S1 = (NetworkId)((nids.Count > 0) ? nids[0] : default(NetworkId)), S2 = (NetworkId)((nids.Count > 1) ? nids[1] : default(NetworkId)), S3 = (NetworkId)((nids.Count > 2) ? nids[2] : default(NetworkId)), MissionDataId = missionId, Zone = zone, DestName = destName, SuccessPct = -1f }; byPlot[plot] = recipe; if (!TrySend(castleHeart, recipe, requireRepeatOn: false)) { return "{\"error\":\"TrySend failed\",\"who\":\"" + EscJson(string.Join(", ", names)) + "\",\"dest\":\"" + EscJson(destName) + "\"}"; } DestDebugLog.Note("throne", plot, 0uL, "debug send " + string.Join(",", names) + " -> " + destName); return "{\"queued\":true,\"plot\":" + plot + ",\"who\":\"" + EscJson(string.Join(", ", names)) + "\",\"dest\":\"" + EscJson(destName) + "\",\"hint\":\"check servants; Repeat: sent chat if vanilla accepts\"}"; } public static string DebugSetTime(int plot, string who, int seconds) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (plot < 0) { return "{\"error\":\"need plot\"}"; } if (seconds < 1) { seconds = 1; } if (seconds > 86400) { seconds = 86400; } Entity castleHeart = Core.TerritoryService.GetCastleHeart(plot); if (castleHeart == Entity.Null || !castleHeart.Has()) { return "{\"error\":\"no missions on plot " + plot + "\"}"; } DynamicBuffer val; try { val = castleHeart.ReadBuffer(); } catch { return "{\"error\":\"no mission buffer\"}"; } long ticks = DateTime.UtcNow.Ticks; int num = 0; List list = new List(); for (int i = 0; i < val.Length; i++) { ActiveServantMission val2 = val[i]; if (MissionMatchesWho(val2, who, list)) { val2.MissionStartTimeTicks = ticks; val2.MissionLengthSeconds = seconds; val[i] = val2; num++; } } if (num == 0) { return "{\"error\":\"no matching active hunt\",\"who\":\"" + EscJson(who) + "\"}"; } DestDebugLog.Note("throne", plot, 0uL, "debug hunttime " + seconds + "s " + string.Join(",", list)); return "{\"ok\":true,\"plot\":" + plot + ",\"seconds\":" + seconds + ",\"missions\":" + num + ",\"who\":\"" + EscJson(string.Join(", ", list)) + "\"}"; } public unsafe static string DebugRevive(int plot, string who) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Invalid comparison between Unknown and I4 //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Invalid comparison between Unknown and I4 if (plot < 0) { return "{\"error\":\"need plot\"}"; } EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); List list = new List(); int num = 0; try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val5) && val5.Has() && Core.TerritoryService.GetTerritoryId(val5) == plot) { ServantCoffinstation val6 = val5.Read(); string text = ((object)(*(FixedString64Bytes*)(&val6.ServantName))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrWhiteSpace(text)) { text = "unnamed"; } if (NameHit(text, who) && ((int)val6.State == 8 || (int)val6.State == 9)) { val6.State = (ServantCoffinState)9; val6.ConvertionProgress = 600f; val6.Injury = default(PrefabGUID); val6.InjuryEndTimeTicks = 1L; val5.Write(val6); list.Add(text); num++; } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } if (num == 0) { return "{\"error\":\"no revivable coffin\",\"who\":\"" + EscJson(who) + "\"}"; } DestDebugLog.Note("throne", plot, 0uL, "debug revive " + string.Join(",", list)); return "{\"ok\":true,\"plot\":" + plot + ",\"reviving\":" + num + ",\"who\":\"" + EscJson(string.Join(", ", list)) + "\"}"; } private static bool NameHit(string name, string who) { if (string.IsNullOrWhiteSpace(who)) { return true; } string[] array = who.Replace(',', ' ').Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { if (name.IndexOf(array[i], StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } public static string DebugRhMax(int percent) { if (percent < 1) { percent = 1; } if (percent > 100) { percent = 100; } int num = Core.PlayerSettings.SetRepeatHuntMaxSuccess(percent); bool flag = ApplyMissionRoll(percent >= 100); DestDebugLog.Note("throne", -1, 0uL, "debug rhmax " + num + " roll=" + (flag ? "force" : "vanilla")); return "{\"ok\":true,\"max\":" + num + ",\"roll\":\"" + (flag ? "force100" : "vanilla") + "\"}"; } private static bool ApplyMissionRoll(bool force100) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)0)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); bool flag = false; try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null || !val5.Has()) { continue; } DynamicBuffer val6; try { val6 = val5.ReadBuffer(); } catch { continue; } if (val6.Length == 0) { continue; } if (force100) { if (savedMissionSettings == null) { savedMissionSettings = new List(val6.Length); for (int j = 0; j < val6.Length; j++) { savedMissionSettings.Add(val6[j]); } } for (int k = 0; k < val6.Length; k++) { ServantMissionSetting val7 = val6[k]; val7.SuccessRateBonus = 1f; val7.InjuryChance = 0f; val6[k] = val7; } flag = true; } else if (savedMissionSettings != null) { int num = Math.Min(val6.Length, savedMissionSettings.Count); for (int l = 0; l < num; l++) { val6[l] = savedMissionSettings[l]; } savedMissionSettings = null; flag = true; } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } return force100 && flag; } private static bool TryPickIdle(int plot, string who, out List nids, out List names, out string error) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) nids = new List(3); names = new List(3); error = ""; List<(string, NetworkId)> list = ClanThroneServants.DebugIdleServants(plot); if (list.Count == 0) { error = "no idle servants on plot " + plot; return false; } if (string.IsNullOrWhiteSpace(who)) { int num = Math.Min(3, list.Count); for (int i = 0; i < num; i++) { nids.Add(list[i].Item2); names.Add(list[i].Item1); } return true; } string[] array = who.Replace(',', ' ').Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); HashSet hashSet = new HashSet(); for (int j = 0; j < array.Length; j++) { if (nids.Count >= 3) { break; } string text = array[j]; if (int.TryParse(text, out var result) && result >= 1 && result <= list.Count) { if (hashSet.Add(result)) { nids.Add(list[result - 1].Item2); names.Add(list[result - 1].Item1); } continue; } for (int k = 0; k < list.Count; k++) { if (nids.Count >= 3) { break; } if (!hashSet.Contains(k + 1) && list[k].Item1.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0) { hashSet.Add(k + 1); nids.Add(list[k].Item2); names.Add(list[k].Item1); break; } } } if (nids.Count == 0) { error = "no match for '" + who + "'"; return false; } return true; } private static bool TryResolveDest(int plot, string dest, out MapZoneId zone, out string destName, out int missionId, out string error) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) zone = default(MapZoneId); destName = ""; missionId = 0; error = ""; if (!string.IsNullOrWhiteSpace(dest) && TryZoneByName(dest, out zone, out destName, out var _)) { if (byPlot.TryGetValue(plot, out var value) && IsSettingIndex(value.MissionDataId)) { missionId = value.MissionDataId; } return true; } if (byPlot.TryGetValue(plot, out var value2) && (ZoneLooksSet(value2.Zone) || !string.IsNullOrWhiteSpace(value2.DestName))) { zone = value2.Zone; destName = value2.DestName; missionId = ClampSetting(value2.MissionDataId); if (string.IsNullOrWhiteSpace(destName)) { destName = DestLabel(zone, value2.MissionPrefab); } return true; } error = "no dest (pass dest:\\\"Fishing Lake\\\" or send once from the map)"; return false; } private static bool TryZoneByName(string want, out MapZoneId zone, out string destName, out PrefabGUID asset) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) zone = default(MapZoneId); destName = ""; asset = default(PrefabGUID); string text = want.Trim(); if (text.Length < 2) { return false; } EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); int num = -1; try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (!(val5 == Entity.Null) && val5.Has()) { MapZoneData val6 = val5.Read(); string text2 = ZoneLabel(val6); if (!string.IsNullOrWhiteSpace(text2) && (text2.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0) && text2.Length >= num) { num = text2.Length; zone = new MapZoneId { ChunkCoordinate = val6.ChunkCoordinate, ZoneId = val6.ZoneIndex }; destName = text2; asset = val6.ServantMissionAsset; } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } return num >= 0; } private static bool MissionMatchesWho(ActiveServantMission mission, string who, List names) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) bool flag = false; flag |= MatchServant(mission.Servant1, who, names); flag |= MatchServant(mission.Servant2, who, names); flag |= MatchServant(mission.Servant3, who, names); string.IsNullOrWhiteSpace(who); return flag; } private static bool MatchServant(NetworkedEntity ne, string who, List names) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Entity entityOnServer = ((NetworkedEntity)(ref ne)).GetEntityOnServer(); if (entityOnServer == Entity.Null) { return false; } string text = ServantName(entityOnServer); if (string.IsNullOrWhiteSpace(who)) { names.Add(text); return true; } string[] array = who.Replace(',', ' ').Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { if (text.IndexOf(array[i], StringComparison.OrdinalIgnoreCase) >= 0) { names.Add(text); return true; } } return false; } private static string EscJson(string s) { if (string.IsNullOrEmpty(s)) { return ""; } return s.Replace("\\", "\\\\").Replace("\"", "\\\""); } private static Recipe RecipeFromMission(int plot, Entity heart, ActiveServantMission mission) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Entity val = ClanThroneServants.FindThrone(plot); NetworkId throne = (NetworkId)((val != Entity.Null && val.Has()) ? val.Read() : default(NetworkId)); TryZoneForMission(mission.MissionID, default(MapZoneId), out var zone, out var destName); Recipe hunt = new Recipe { Plot = plot, Throne = throne, S1 = CoffinNid(NidOf(mission.Servant1)), S2 = CoffinNid(NidOf(mission.Servant2)), S3 = CoffinNid(NidOf(mission.Servant3)), MissionDataId = mission.MissiontDataId, MissionPrefab = mission.MissionID, Zone = zone, DestName = destName, SuccessPct = -1f }; FillDest(ref hunt); return hunt; } private static string DestLabel(MapZoneId zone, PrefabGUID mission) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) TryZoneForMission(mission, zone, out var _, out var destName); return destName; } private static void MergeRecipe(ref Recipe recipe, Recipe old) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(recipe.DestName)) { recipe.DestName = old.DestName; } if (!IsSettingIndex(recipe.MissionDataId) && IsSettingIndex(old.MissionDataId)) { recipe.MissionDataId = old.MissionDataId; } if (((PrefabGUID)(ref recipe.MissionPrefab)).GuidHash == 0) { recipe.MissionPrefab = old.MissionPrefab; } if (!ZoneLooksSet(recipe.Zone) && ZoneLooksSet(old.Zone)) { recipe.Zone = old.Zone; } if (((NetworkId)(ref recipe.Throne)).Equals(default(NetworkId))) { recipe.Throne = old.Throne; } } private static bool FillDest(ref Recipe hunt) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (((PrefabGUID)(ref hunt.MissionPrefab)).GuidHash != 0 && TryZoneForMission(hunt.MissionPrefab, hunt.Zone, out var zone, out var destName) && ZoneLooksSet(zone)) { hunt.Zone = zone; if (!string.IsNullOrWhiteSpace(destName)) { hunt.DestName = destName; } hunt.MissionDataId = ClampSetting(hunt.MissionDataId); return true; } if (!string.IsNullOrWhiteSpace(hunt.DestName) && TryZoneByName(hunt.DestName, out zone, out destName, out var asset)) { hunt.Zone = zone; hunt.DestName = destName; if (((PrefabGUID)(ref hunt.MissionPrefab)).GuidHash == 0) { hunt.MissionPrefab = asset; } hunt.MissionDataId = ClampSetting(hunt.MissionDataId); return true; } if (ZoneLooksSet(hunt.Zone)) { string text = DestLabel(hunt.Zone, hunt.MissionPrefab); if (!string.IsNullOrWhiteSpace(text)) { hunt.DestName = text; } hunt.MissionDataId = ClampSetting(hunt.MissionDataId); return true; } return false; } private static bool IsSettingIndex(int id) { if (id >= 0) { return id <= 4; } return false; } private static int ClampSetting(int id) { if (!IsSettingIndex(id)) { return 0; } return id; } private static bool ZoneLooksSet(MapZoneId zone) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (zone.ZoneId == 0) { return !((TerrainChunk)(ref zone.ChunkCoordinate)).Equals(default(int2)); } return true; } private unsafe static string ZoneTag(MapZoneId zone) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) TerrainChunk chunkCoordinate = zone.ChunkCoordinate; return ((object)(*(TerrainChunk*)(&chunkCoordinate))/*cast due to .constrained prefix*/).ToString() + ":" + zone.ZoneId; } internal static string DestForMission(PrefabGUID mission) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (((PrefabGUID)(ref mission)).GuidHash == 0) { return ""; } if (TryZoneForMission(mission, default(MapZoneId), out var _, out var destName) && !string.IsNullOrWhiteSpace(destName)) { return destName; } return PrettyMission(mission); } private static bool TryZoneForMission(PrefabGUID mission, MapZoneId want, out MapZoneId zone, out string destName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) zone = default(MapZoneId); destName = ""; EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (!(val5 == Entity.Null) && val5.Has()) { MapZoneData val6 = val5.Read(); bool flag = ((PrefabGUID)(ref mission)).GuidHash != 0 && ((PrefabGUID)(ref val6.ServantMissionAsset)).GuidHash == ((PrefabGUID)(ref mission)).GuidHash; bool flag2 = (want.ZoneId != 0 || !((TerrainChunk)(ref want.ChunkCoordinate)).Equals(default(int2))) && val6.ZoneIndex == want.ZoneId && ((TerrainChunk)(ref val6.ChunkCoordinate)).Equals(want.ChunkCoordinate); if (flag || flag2) { zone = new MapZoneId { ChunkCoordinate = val6.ChunkCoordinate, ZoneId = val6.ZoneIndex }; destName = ZoneLabel(val6); return destName.Length > 0 || flag; } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } if (((PrefabGUID)(ref mission)).GuidHash != 0) { destName = PrettyMission(mission); return destName.Length > 0; } return false; } private static string ZoneLabel(MapZoneData data) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) try { string localization = Core.Localization.GetLocalization(data.Name); if (!string.IsNullOrWhiteSpace(localization) && localization.IndexOf("not found", StringComparison.OrdinalIgnoreCase) < 0) { return localization; } } catch { } if (((PrefabGUID)(ref data.ServantMissionAsset)).GuidHash != 0) { return PrettyMission(data.ServantMissionAsset); } return ""; } private static string PrettyMission(PrefabGUID guid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) string prefabName = Core.Localization.GetPrefabName(guid); if (!string.IsNullOrWhiteSpace(prefabName) && prefabName.IndexOf("not found", StringComparison.OrdinalIgnoreCase) < 0) { return prefabName; } string text = guid.LookupName(); if (string.IsNullOrWhiteSpace(text)) { return ""; } int num = text.IndexOf(' '); if (num > 0) { text = text.Substring(0, num); } if (text.StartsWith("ServantMission_", StringComparison.OrdinalIgnoreCase)) { text = text.Substring("ServantMission_".Length); } return text.Replace('_', ' '); } private static NetworkId NidOf(NetworkedEntity ne) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Entity entityOnServer = ((NetworkedEntity)(ref ne)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has()) { return entityOnServer.Read(); } } return default(NetworkId); } private static NetworkId CoffinNid(NetworkId nid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!Core.TryGetEntityFromNetworkId(nid, out var entity) || entity == Entity.Null) { return nid; } if (entity.Has() && entity.Has()) { return entity.Read(); } Entity val = CoffinOf(entity); if (val != Entity.Null && val.Has()) { return val.Read(); } return nid; } private unsafe static void ArmInteractor(Entity character, Entity throne) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) RestoreInteractor(); if (character == Entity.Null || throne == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(character)) { return; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(throne) && character.Has() && throne.Has()) { ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(character, val.TypeIndex); if (componentDataRawRW != null) { IntPtr pointer = new IntPtr(componentDataRawRW); autoInteractChar = character; autoInteractOldNid = Marshal.PtrToStructure(IntPtr.Add(pointer, 8)); autoInteractOldTarget = Marshal.PtrToStructure(IntPtr.Add(pointer, 20)); autoInteractSaved = true; Marshal.StructureToPtr(throne.Read(), IntPtr.Add(pointer, 8), fDeleteOld: false); Marshal.StructureToPtr(throne, IntPtr.Add(pointer, 20), fDeleteOld: false); } } } private unsafe static void RestoreInteractor() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (!autoInteractSaved) { return; } autoInteractSaved = false; Entity val = autoInteractChar; autoInteractChar = Entity.Null; if (val == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val) && val.Has()) { ComponentType val2 = default(ComponentType); ((ComponentType)(ref val2))..ctor(Il2CppType.Of(), (AccessMode)0); entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(val, val2.TypeIndex); if (componentDataRawRW != null) { IntPtr pointer = new IntPtr(componentDataRawRW); Marshal.StructureToPtr(autoInteractOldNid, IntPtr.Add(pointer, 8), fDeleteOld: false); Marshal.StructureToPtr(autoInteractOldTarget, IntPtr.Add(pointer, 20), fDeleteOld: false); } } } private static void AddServant(List list, NetworkedEntity ne) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Entity entityOnServer = ((NetworkedEntity)(ref ne)).GetEntityOnServer(); if (entityOnServer != Entity.Null) { list.Add(entityOnServer); } } private static bool IsDead(Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 Entity val = CoffinOf(servant); if (val == Entity.Null) { return true; } ServantCoffinState state = val.Read().State; if ((int)state != 8) { return (int)state == 0; } return true; } private static bool IsInjured(Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Entity val = CoffinOf(servant); if (val == Entity.Null || !val.Has()) { return false; } ServantCoffinstation val2 = val.Read(); return ((PrefabGUID)(ref val2.Injury)).GuidHash != 0; } private static Entity CoffinOf(Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) if (!(servant == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(servant)) { EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5.Has()) { ServantCoffinstation val6 = val5.Read(); if (((NetworkedEntity)(ref val6.ConnectedServant)).GetEntityOnServer() == servant) { return val5; } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } return Entity.Null; } } return Entity.Null; } private unsafe static string ServantName(Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Entity val = CoffinOf(servant); if (val != Entity.Null && val.Has()) { ServantCoffinstation val2 = val.Read(); string text = ((object)(*(FixedString64Bytes*)(&val2.ServantName))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrWhiteSpace(text)) { return text; } } return "servant"; } private static void AddLoot(Entity servant, Dictionary loot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (!InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, servant, ref val, 0) || val == Entity.Null) { return; } ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val2 = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val, ref val2)) { return; } for (int i = 0; i < val2.Length; i++) { InventoryBuffer val3 = val2[i]; if (((PrefabGUID)(ref val3.ItemType)).GuidHash != 0 && val2[i].Amount > 0) { loot.TryGetValue(val2[i].ItemType, out var value); loot[val2[i].ItemType] = value + val2[i].Amount; } } } private static bool TryFromHeart(Entity heart, out Entity userEnt, out Entity character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) userEnt = Entity.Null; character = Entity.Null; if (heart == Entity.Null || !heart.Has()) { return false; } UserOwner val = heart.Read(); userEnt = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (!(userEnt == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEnt) && userEnt.Has()) { User val2 = userEnt.Read(); character = ((NetworkedEntity)(ref val2.LocalCharacter)).GetEntityOnServer(); if (character != Entity.Null) { entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).Exists(character); } return false; } } return false; } private static bool TryFromSend(Entity heart, Entity throne, out Entity userEnt, out Entity character) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) userEnt = Entity.Null; character = Entity.Null; int plot = ((throne != Entity.Null) ? Core.TerritoryService.GetTerritoryId(throne) : Core.TerritoryService.GetTerritoryId(heart)); int best = 0; Entity pickUser = Entity.Null; Entity pickChar = Entity.Null; Core.TerritoryService.EachUser(delegate(Entity uent, User user) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (user.IsConnected) { Entity entityOnServer = ((NetworkedEntity)(ref user.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && (Core.TerritoryService.IsSameClanAsHeartOwner(user, heart) || Core.TerritoryService.IsSameClanAsHeart(entityOnServer, heart))) { int num = 1; int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(entityOnServer); if (plot >= 0 && standingTerritoryId == plot) { num = 2; } if (InteractorIs(entityOnServer, throne)) { num = 3; } if (num > best) { best = num; pickUser = uent; pickChar = entityOnServer; } } } } }); if (best > 0) { userEnt = pickUser; character = pickChar; return true; } return TryFromHeart(heart, out userEnt, out character); } private unsafe static bool InteractorIs(Entity character, Entity throne) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (!(character == Entity.Null) && !(throne == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && character.Has()) { ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); entityManager = Core.EntityManager; void* componentDataRawRW = ((EntityManager)(ref entityManager)).GetComponentDataRawRW(character, val.TypeIndex); if (componentDataRawRW == null) { return false; } return Marshal.PtrToStructure(IntPtr.Add(new IntPtr(componentDataRawRW), 20)) == throne; } } return false; } private unsafe static string SenderName(Entity userEnt) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!(userEnt == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEnt) && userEnt.Has()) { User val = userEnt.Read(); string text = ((object)(*(FixedString64Bytes*)(&val.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrWhiteSpace(text)) { return text; } return "?"; } } return "?"; } private static void TellOwner(Entity heart, string text) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) TellClan(heart, text); } private static void TellClan(Entity heart, string text) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(text) || heart == Entity.Null) { return; } HashSet sent = new HashSet(); if (TryFromHeart(heart, out var userEnt, out var _) && userEnt.Has()) { Send(userEnt.Read()); } Core.TerritoryService.EachUser(delegate(Entity _, User user) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Core.TerritoryService.IsSameClanAsHeartOwner(user, heart)) { Send(user); } }); void Send(User user) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (user.IsConnected && sent.Add(user.PlatformId)) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, text); } } } private static string Trim(string s) { if (string.IsNullOrEmpty(s)) { return s; } if (s.Length > 509) { return s.Substring(0, 509); } return s; } public static string ChatRh(Entity character, User user, string arg) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) if (!Core.PlayerSettings.IsRepeatHuntEnabled()) { return "Repeat hunts are OFF for the server. An admin must .sg rh first."; } List list = ListPlots(character, user); if (list.Count == 0) { return "Stand on a clan castle (or have ClanShare on) to see plots."; } ulong platformId = user.PlatformId; if (string.IsNullOrWhiteSpace(arg) || arg.Equals("list", StringComparison.OrdinalIgnoreCase)) { return FormatList(character, platformId, list); } if (arg.Equals("all", StringComparison.OrdinalIgnoreCase)) { for (int i = 0; i < list.Count; i++) { Core.PlayerSettings.SetRepeatHuntPlot(list[i], on: true); } return "Repeat hunts ON for all listed castles.\n" + FormatList(character, platformId, list); } if (arg.Equals("off", StringComparison.OrdinalIgnoreCase) || arg.Equals("on", StringComparison.OrdinalIgnoreCase)) { int num = ((character != Entity.Null) ? Core.TerritoryService.GetStandingTerritoryId(character) : (-1)); if (num < 0) { return "Stand on a castle to turn it " + arg + "."; } bool flag = arg.Equals("on", StringComparison.OrdinalIgnoreCase); Core.PlayerSettings.SetRepeatHuntPlot(num, flag); return Core.TerritoryService.FormatPlotLabel(num) + " repeat hunts " + (flag ? "ON" : "OFF") + ".\n" + FormatList(character, platformId, list); } if (int.TryParse(arg, out var result)) { List list2 = null; if (pendingList.TryGetValue(platformId, out var value) && pendingListAt.TryGetValue(platformId, out var value2) && DateTime.UtcNow <= value2 && value != null && result >= 1 && result <= value.Count) { list2 = value; } else if (result >= 1 && result <= list.Count) { list2 = list; } if (list2 == null) { return "Use .s rh then .s rh 2, or .s rh off / .s rh all."; } int num2 = list2[result - 1]; bool flag2 = !Core.PlayerSettings.IsRepeatHuntPlotOn(num2); Core.PlayerSettings.SetRepeatHuntPlot(num2, flag2); return Core.TerritoryService.FormatPlotLabel(num2) + " repeat hunts " + (flag2 ? "ON" : "OFF") + ".\n" + FormatList(character, platformId, list); } return "Use .s rh | .s rh all | .s rh off | .s rh 2"; } private static List ListPlots(Entity character, User user) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) IReadOnlyList logisticsTerritoryIdsForCharacter = Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(character); if (logisticsTerritoryIdsForCharacter != null && logisticsTerritoryIdsForCharacter.Count > 0) { return new List(logisticsTerritoryIdsForCharacter); } int num = ((character != Entity.Null) ? Core.TerritoryService.GetStandingTerritoryId(character) : (-1)); if (num >= 0) { return new List { num }; } return new List(); } private static string FormatList(Entity character, ulong steam, List ids) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) pendingList[steam] = new List(ids); pendingListAt[steam] = DateTime.UtcNow + ListTtl; int num = ((character != Entity.Null) ? Core.TerritoryService.GetStandingTerritoryId(character) : (-1)); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Repeat hunts (server ON, max ").Append(Core.PlayerSettings.GetRepeatHuntMaxSuccess()).Append("% )\n"); for (int i = 0; i < ids.Count; i++) { int num2 = ids[i]; bool flag = Core.PlayerSettings.IsRepeatHuntPlotOn(num2); stringBuilder.Append(i + 1).Append(") ").Append(Core.TerritoryService.FormatPlotLabel(num2)); if (num2 == num) { stringBuilder.Append(" (here)"); } stringBuilder.Append(flag ? " ON" : " OFF").Append('\n'); } stringBuilder.Append(".s rh 2 toggle .s rh all enable all .s rh off this castle"); string text = stringBuilder.ToString(); if (text.Length > 509) { return text.Substring(0, 509); } return text; } } internal sealed class SalvageService { private readonly HeartBoundIndex index; public SalvageService() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) index = HeartBoundIndex.Scan(true, ComponentType.ReadOnly(Il2CppType.Of())); } internal void Refresh() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) index.Rebuild(true, ComponentType.ReadOnly(Il2CppType.Of())); } internal void AddSalvageStation(Entity station) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) index.Track(station); } internal void RemoveSalvageStation(Entity station) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) index.Untrack(station); } public IEnumerable GetAllSalvageStations(int territoryId) { return index.OnTerritory(territoryId); } } internal struct ScoopResult { public int PilesTaken; public int ItemsTaken; public int PilesSkippedFull; public int PilesSkippedCap; public int PilesSkippedExclude; public int PilesSkippedClaimed; public bool Busy; public string Summary; } internal static class ScoopReport { internal const string ClientToken = "[GroundScoop]"; private const int MaxNamedTypes = 3; private static readonly Dictionary LastByPlayer = new Dictionary(); public static string ForClientFlash(string summary) { if (string.IsNullOrEmpty(summary)) { return null; } return "[GroundScoop] " + summary; } public static string Format(List<(string name, int amount)> items) { if (items == null || items.Count == 0) { return null; } items.Sort(delegate((string name, int amount) a, (string name, int amount) b) { int num3 = b.amount.CompareTo(a.amount); return (num3 == 0) ? string.Compare(a.name, b.name, StringComparison.OrdinalIgnoreCase) : num3; }); int num = ((items.Count < 3) ? items.Count : 3); string[] array = new string[num]; for (int num2 = 0; num2 < num; num2++) { array[num2] = $"{items[num2].name} x{items[num2].amount}"; } string text = "Scoop: " + string.Join(", ", array); if (items.Count > 3) { text += $" +{items.Count - 3} more"; } return text; } public static void Remember(ulong platformId, string summary) { if (!string.IsNullOrEmpty(summary)) { LastByPlayer[platformId] = summary; } } public static bool TryGetLast(ulong platformId, out string summary) { if (LastByPlayer.TryGetValue(platformId, out summary)) { return !string.IsNullOrEmpty(summary); } return false; } public static void TellClient(User user, string message) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(message)) { FixedString512Bytes val = FixedString512Bytes.op_Implicit(message); ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, user, ref val); } } } internal static class ScoopService { private sealed class AutoPlayerCtx { public Entity Character; public User User; public Entity Inventory; public float3 Origin; public float RadiusSq; public ulong PlatformId; public CapMode Mode; public AutoFilter Filter; public Dictionary Snapshot; public Dictionary TakenThisPass; public HashSet Assigned; } private struct AutoCandidate { public int PlayerIndex; public float DistSq; public PrefabGUID Item; public int PileAmount; } public const float DefaultRadius = 10f; public const float AutoIntervalSeconds = 0.75f; private static readonly object Gate = new object(); private static readonly HashSet InProgress = new HashSet(); private static readonly HashSet InFlight = new HashSet(); private static readonly Dictionary FullyGranted = new Dictionary(); private static int DrainSerial; public static ScoopResult ScoopNow(Entity character, User user, bool auto = false) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) lock (Gate) { if (!InProgress.Add(user.PlatformId)) { return new ScoopResult { Busy = true }; } try { PruneGranted(); return Drain(character, user, auto); } finally { InProgress.Remove(user.PlatformId); } } } public static IEnumerator AutoScoopLoop() { WaitForSeconds wait = new WaitForSeconds(0.75f); while (true) { yield return wait; if (Core.HasInitialized) { TickAuto(); } } } private static void TickAuto() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) try { EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray users = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { lock (Gate) { PruneGranted(); DropTracker.Discover(); List list = CollectAutoPlayers(users); if (list.Count == 0) { return; } AssignClosestWinners(list); foreach (AutoPlayerCtx item in list) { if (item.Assigned.Count != 0 && !InProgress.Contains(item.PlatformId)) { InProgress.Add(item.PlatformId); try { Drain(item.Character, item.User, auto: true, item.Assigned); } finally { InProgress.Remove(item.PlatformId); } } } } } finally { users.Dispose(); ((EntityQuery)(ref val3)).Dispose(); } } catch (Exception e) { Core.LogException(e, "TickAuto"); } } private static List CollectAutoPlayers(NativeArray users) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Enumerator enumerator = users.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(current) || !current.Has()) { continue; } User val = current.Read(); if (!val.IsConnected || !Core.PlayerSettings.IsAutoEnabled(val.PlatformId) || InProgress.Contains(val.PlatformId)) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has() && InventoryCountService.TryGetPlayerInventory(entityOnServer, out var inventory)) { float radius = Core.PlayerSettings.GetRadius(val.PlatformId); list.Add(new AutoPlayerCtx { Character = entityOnServer, User = val, Inventory = inventory, Origin = entityOnServer.Read().Value, RadiusSq = radius * radius, PlatformId = val.PlatformId, Mode = Core.PlayerSettings.GetCapMode(val.PlatformId), Filter = Core.PlayerSettings.GetAutoFilter(val.PlatformId), Snapshot = new Dictionary(), TakenThisPass = new Dictionary(), Assigned = new HashSet() }); } } } return list; } private static void AssignClosestWinners(List players) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Expected O, but got Unknown //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)0)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); val = ((EntityQueryBuilder)(ref val)).AddNone(new ComponentType(Il2CppType.Of(), (AccessMode)1)); val = ((EntityQueryBuilder)(ref val)).AddNone(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddNone(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Dictionary> dictionary = new Dictionary>(); Enumerator enumerator = val4.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!TryGetAutoPickup(current, out var item, out var pileAmount, out var pos)) { continue; } List list = null; for (int i = 0; i < players.Count; i++) { if (IsAutoEligible(players[i], current, item, pileAmount, pos, out var distSq)) { if (list == null) { list = new List(); } list.Add(new AutoCandidate { PlayerIndex = i, DistSq = distSq, Item = item, PileAmount = pileAmount }); } } if (list != null) { dictionary[current] = list; } } bool flag = default(bool); foreach (KeyValuePair> item3 in dictionary) { Entity key = item3.Key; List value = item3.Value; value.Sort(delegate(AutoCandidate a, AutoCandidate b) { int num3 = a.DistSq.CompareTo(b.DistSq); return (num3 != 0) ? num3 : players[a.PlayerIndex].PlatformId.CompareTo(players[b.PlayerIndex].PlatformId); }); foreach (AutoCandidate item4 in value) { AutoPlayerCtx autoPlayerCtx = players[item4.PlayerIndex]; int num = RemainingBudget(autoPlayerCtx.PlatformId, autoPlayerCtx.Character, autoPlayerCtx.User, item4.Item, autoPlayerCtx.Mode, autoPlayerCtx.Snapshot, autoPlayerCtx.TakenThisPass); if (num <= 0 || !InventoryCanAcceptAtLeastOne(autoPlayerCtx.Inventory, item4.Item)) { continue; } autoPlayerCtx.Assigned.Add(key); int num2 = ((item4.PileAmount < num) ? item4.PileAmount : num); Dictionary takenThisPass = autoPlayerCtx.TakenThisPass; PrefabGUID item2 = item4.Item; takenThisPass.TryGetValue(((PrefabGUID)(ref item2)).GuidHash, out var value2); Dictionary takenThisPass2 = autoPlayerCtx.TakenThisPass; item2 = item4.Item; takenThisPass2[((PrefabGUID)(ref item2)).GuidHash] = value2 + num2; if (value.Count > 1) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(53, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Scoop auto assign "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(autoPlayerCtx.User.CharacterName); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(autoPlayerCtx.PlatformId); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("): entity="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(Ent(key)); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" distSq="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(item4.DistSq, "0.##"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" beat "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(value.Count - 1); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" other(s)"); } log.LogInfo(val5); } break; } } } finally { val4.Dispose(); ((EntityQuery)(ref val3)).Dispose(); } } private static bool TryGetAutoPickup(Entity drop, out PrefabGUID item, out int pileAmount, out float3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) item = default(PrefabGUID); pileAmount = 0; pos = default(float3); if (!(drop == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(drop)) { if (IsAlreadyClaimed(drop)) { return false; } if (!IsEligibleWorldDrop(drop)) { return false; } if (!drop.Has() || !drop.Has()) { return false; } if (DropTracker.IsPlayerDropped(drop)) { return false; } pos = drop.Read().Value; ItemPickup val = drop.Read(); item = val.ItemId; pileAmount = val.ItemAmount; if (((PrefabGUID)(ref item)).GuidHash == 0 || pileAmount <= 0) { return false; } if (IsForbiddenItem(item, drop)) { return false; } return true; } } return false; } private static bool IsAutoEligible(AutoPlayerCtx player, Entity drop, PrefabGUID item, int pileAmount, float3 pos, out float distSq) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) distSq = math.lengthsq(pos - player.Origin); if (distSq > player.RadiusSq) { return false; } if (player.Filter == AutoFilter.Around && !DropTracker.IsFreshFor(drop, player.PlatformId)) { return false; } if (Core.PlayerSettings.IsExcluded(player.PlatformId, item)) { return false; } if (RemainingBudget(player.PlatformId, player.Character, player.User, item, player.Mode, player.Snapshot, player.TakenThisPass) <= 0) { return false; } if (!InventoryCanAcceptAtLeastOne(player.Inventory, item)) { return false; } return pileAmount > 0; } private static bool InventoryCanAcceptAtLeastOne(Entity inventory, PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!(inventory == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inventory)) { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(inventory, ref val)) { return false; } int maxStack = GetMaxStack(item); bool result = false; Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { InventoryBuffer current = enumerator.Current; PrefabGUID itemType = current.ItemType; if (((PrefabGUID)(ref itemType)).GuidHash == 0) { result = true; continue; } itemType = current.ItemType; if (((PrefabGUID)(ref itemType)).Equals(item)) { int num = ((current.MaxAmountOverride > 0) ? current.MaxAmountOverride : maxStack); if (num <= 0) { return true; } if (current.Amount < num) { return true; } } } return result; } } return false; } private static int GetMaxStack(PrefabGUID item) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (Core.PrefabCollectionSystem != null) { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity entity = default(Entity); if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(item, ref entity) && entity.Has()) { return entity.Read().MaxAmount; } } return 0; } private static ScoopResult Drain(Entity character, User user, bool auto, HashSet assignedPickups = null) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) ScoopResult result = default(ScoopResult); if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character)) { if (!character.Has()) { return result; } if (!InventoryCountService.TryGetPlayerInventory(character, out var inventory)) { return result; } DropTracker.Discover(); ulong platformId = user.PlatformId; float radius = Core.PlayerSettings.GetRadius(platformId); CapMode capMode = Core.PlayerSettings.GetCapMode(platformId); AutoFilter autoFilter = Core.PlayerSettings.GetAutoFilter(platformId); float3 value = character.Read().Value; float num = radius * radius; Dictionary snapshot = new Dictionary(); Dictionary dictionary = new Dictionary(); Dictionary dictionary2 = new Dictionary(); HashSet hashSet = new HashSet(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)0)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); val = ((EntityQueryBuilder)(ref val)).AddNone(new ComponentType(Il2CppType.Of(), (AccessMode)1)); val = ((EntityQueryBuilder)(ref val)).AddNone(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddNone(new ComponentType(Il2CppType.Of(), (AccessMode)1)); entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val4.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (current == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(current) || !hashSet.Add(current) || (assignedPickups != null && !assignedPickups.Contains(current))) { continue; } if (IsAlreadyClaimed(current)) { result.PilesSkippedClaimed++; LogSkipClaimed(user, current); } else { if (!IsEligibleWorldDrop(current) || !current.Has() || !current.Has() || (auto && (DropTracker.IsPlayerDropped(current) || (autoFilter == AutoFilter.Around && !DropTracker.IsFreshFor(current, platformId)))) || math.lengthsq(current.Read().Value - value) > num) { continue; } ItemPickup val5 = current.Read(); PrefabGUID itemId = val5.ItemId; int itemAmount = val5.ItemAmount; if (((PrefabGUID)(ref itemId)).GuidHash == 0 || itemAmount <= 0 || IsForbiddenItem(itemId, current)) { continue; } if (Core.PlayerSettings.IsExcluded(platformId, itemId)) { result.PilesSkippedExclude++; continue; } int num2 = RemainingBudget(platformId, character, user, itemId, capMode, snapshot, dictionary); if (num2 <= 0) { result.PilesSkippedCap++; continue; } int num3 = ((itemAmount < num2) ? itemAmount : num2); if (num3 <= 0) { continue; } int num4 = TryAddThenReduce(inventory, current, itemId, itemAmount, num3, user); if (num4 <= 0) { result.PilesSkippedFull++; continue; } if (!dictionary.TryGetValue(((PrefabGUID)(ref itemId)).GuidHash, out var value2)) { value2 = 0; } dictionary[((PrefabGUID)(ref itemId)).GuidHash] = value2 + num4; if (!dictionary2.ContainsKey(((PrefabGUID)(ref itemId)).GuidHash)) { dictionary2[((PrefabGUID)(ref itemId)).GuidHash] = itemId.PrefabName(); } result.ItemsTaken += num4; result.PilesTaken++; } } } finally { val4.Dispose(); ((EntityQuery)(ref val3)).Dispose(); } if (result.ItemsTaken > 0) { List<(string, int)> list = new List<(string, int)>(); foreach (KeyValuePair item in dictionary) { dictionary2.TryGetValue(item.Key, out var value3); if (string.IsNullOrEmpty(value3)) { value3 = ECSExtensions.PrefabName(new PrefabGUID(item.Key)); } list.Add((value3, item.Value)); } result.Summary = ScoopReport.Format(list); ScoopReport.Remember(platformId, result.Summary); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(51, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Scoop "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(platformId); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("): +"); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(result.ItemsTaken); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" from "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(result.PilesTaken); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" pile(s) r="); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(radius, "0.#"); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" mode="); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(capMode); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" skippedClaimed="); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(result.PilesSkippedClaimed); } log.LogInfo(val6); if (auto && Core.PlayerSettings.GetNotifyMode(platformId) == NotifyMode.On) { ScoopReport.TellClient(user, ScoopReport.ForClientFlash(result.Summary)); } } return result; } } return result; } private static int RemainingBudget(ulong platformId, Entity character, User user, PrefabGUID item, CapMode mode, Dictionary snapshot, Dictionary takenThisPass) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) int cap = Core.PlayerSettings.GetCap(platformId, item); if (cap == 0) { return 0; } if (cap < 0) { return int.MaxValue; } if (!snapshot.TryGetValue(((PrefabGUID)(ref item)).GuidHash, out var value)) { value = InventoryCountService.CountForCap(character, user, item, mode); if (value < 0) { value = 0; } snapshot[((PrefabGUID)(ref item)).GuidHash] = value; } takenThisPass.TryGetValue(((PrefabGUID)(ref item)).GuidHash, out var value2); int num = value + value2; int num2 = cap - num; if (num2 <= 0) { return 0; } return num2; } private static int TryAddThenReduce(Entity inventory, Entity drop, PrefabGUID item, int pileAmount, int want, User user) { //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Expected O, but got Unknown //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) if (want <= 0 || pileAmount <= 0) { return 0; } if (!(drop == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(drop) && drop.Has()) { if (IsAlreadyClaimed(drop) || !InFlight.Add(drop)) { LogSkipClaimed(user, drop, item, pileAmount); return 0; } int num = 0; bool flag = false; bool flag2 = default(bool); try { ItemPickup val = drop.Read(); if (!((PrefabGUID)(ref val.ItemId)).Equals(item)) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(60, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Scoop abort claim: drop item changed before add of "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(item.PrefabName()); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" entity="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Ent(drop)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogWarning(val2); return 0; } num = val.ItemAmount; if (num <= 0) { MarkFullyGranted(drop); LogSkipClaimed(user, drop, item); return 0; } val.ItemAmount = 0; drop.Write(val); flag = true; MarkFullyGranted(drop); ServerGameManager serverGameManager = Core.ServerGameManager; int num2 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, item); if (num2 < 0) { num2 = 0; } AddItemSettings val3 = new AddItemSettings { EntityManager = Core.EntityManager }; serverGameManager = Core.ServerGameManager; val3.ItemDataMap = ((ServerGameManager)(ref serverGameManager)).ItemLookupMap; val3.DropRemainder = false; val3.EquipIfPossible = false; val3.OnlyFillEmptySlots = false; int num3 = ((want < num) ? want : num); InventoryUtilitiesServer.TryAddItem(val3, inventory, item, num3); serverGameManager = Core.ServerGameManager; int num4 = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, item); if (num4 < 0) { num4 = num2; } int num5 = num4 - num2; if (num5 <= 0) { RestoreAmount(drop, item, num); UnmarkFullyGranted(drop); return 0; } if (num5 > num) { num5 = num; } if (num5 > num3) { num5 = num3; } int num6 = num - num5; string text = item.PrefabName() ?? item.LookupName(); bool flag3 = false; if (num6 <= 0) { flag3 = TryDestroyPickup(drop, user, text, item, num5); LogGrant(user, item, text, drop, num5, 0, flag3); return num5; } if (!RestoreAmount(drop, item, num6)) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(93, 7, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Scoop "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): granted "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num5); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("x "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((PrefabGUID)(ref item)).GuidHash); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") entity="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Ent(drop)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" leftover="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num6); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" destroyed=no; leftover write failed, keeping claim"); } log2.LogWarning(val2); return num5; } UnmarkFullyGranted(drop); LogGrant(user, item, text, drop, num5, num6, destroyed: false); return num5; } catch (Exception ex) { if (flag && num > 0 && !FullyGranted.ContainsKey(drop)) { RestoreAmount(drop, item, num); } ManualLogSource log3 = Core.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(32, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Scoop claim/add failed entity="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Ent(drop)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log3.LogWarning(val2); return 0; } finally { InFlight.Remove(drop); } } } return 0; } private static bool TryDestroyPickup(Entity drop, User user, string itemName, PrefabGUID item, int added) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!(drop == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(drop)) { try { DestroyUtility.Destroy(Core.EntityManager, drop, (DestroyDebugReason)13, (string)null, 0); DropTracker.Forget(drop); return true; } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(90, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Scoop "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("): granted "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(added); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(itemName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((PrefabGUID)(ref item)).GuidHash); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") entity="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Ent(drop)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" leftover=0 destroyed=no ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); amount already 0 so no clone."); } log.LogWarning(val); return false; } } } return true; } private static bool RestoreAmount(Entity drop, PrefabGUID item, int amount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!(drop == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(drop) && drop.Has()) { ItemPickup componentData = drop.Read(); if (!((PrefabGUID)(ref componentData.ItemId)).Equals(item)) { return false; } componentData.ItemAmount = amount; drop.Write(componentData); return true; } } return false; } private static bool IsAlreadyClaimed(Entity drop) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!InFlight.Contains(drop)) { return FullyGranted.ContainsKey(drop); } return true; } private static void MarkFullyGranted(Entity drop) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) DrainSerial++; FullyGranted[drop] = DrainSerial; } private static void UnmarkFullyGranted(Entity drop) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) FullyGranted.Remove(drop); } private static void PruneGranted() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (FullyGranted.Count == 0) { return; } List list = null; foreach (KeyValuePair item in FullyGranted) { if (!(item.Key == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(item.Key)) { continue; } } if (list == null) { list = new List(); } list.Add(item.Key); } if (list == null) { return; } foreach (Entity item2 in list) { FullyGranted.Remove(item2); } } private static string Ent(Entity e) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) return $"{e.Index}:{e.Version}"; } private static void LogSkipClaimed(User user, Entity drop, PrefabGUID item = default(PrefabGUID), int amount = 0) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) string text = "?"; int num = 0; if (((PrefabGUID)(ref item)).GuidHash != 0) { text = item.PrefabName() ?? item.LookupName(); num = ((PrefabGUID)(ref item)).GuidHash; } else if (drop != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(drop) && drop.Has()) { ItemPickup val = drop.Read(); text = val.ItemId.PrefabName() ?? val.ItemId.LookupName(); num = ((PrefabGUID)(ref val.ItemId)).GuidHash; amount = val.ItemAmount; } } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(64, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Scoop "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): skippedBecauseAlreadyClaimed item="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") entity="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(Ent(drop)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" amount="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(amount); } log.LogInfo(val2); } private static void LogGrant(User user, PrefabGUID item, string itemName, Entity drop, int granted, int leftover, bool destroyed) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Scoop "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(user.PlatformId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("): granted "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(granted); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(itemName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((PrefabGUID)(ref item)).GuidHash); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") entity="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Ent(drop)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" leftover="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(leftover); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" destroyed="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(destroyed ? "yes" : "no"); } log.LogInfo(val); } private static bool IsEligibleWorldDrop(Entity drop) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (drop.Has()) { return false; } if (drop.Has()) { return false; } if (drop.Has()) { return false; } if (drop.Has()) { return false; } if (drop.Has()) { return false; } if (drop.Has()) { return false; } if (drop.Has()) { return false; } if (drop.Has() && drop.Has()) { return false; } return drop.Has(); } private static bool IsForbiddenItem(PrefabGUID item, Entity drop) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 if (drop.Has()) { return true; } if (Core.PrefabCollectionSystem != null) { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity entity = default(Entity); if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(item, ref entity)) { if (entity.Has()) { return true; } if (entity.Has() && (int)entity.Read().ItemType == 7) { return false; } } } string text = item.LookupName() ?? string.Empty; if (text.IndexOf("SoulShard", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (text.IndexOf("Item_Building_Relic", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (text.IndexOf("Relic_", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } return false; } } internal static class ServantLoot { public static int Deposit(Entity servant) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Invalid comparison between Unknown and I8 //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_060e: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_073f: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Unknown result type (might be due to invalid IL or missing references) //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_074d: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_0642: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_0695: Unknown result type (might be due to invalid IL or missing references) //IL_069a: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_06ea: Unknown result type (might be due to invalid IL or missing references) //IL_06ee: Unknown result type (might be due to invalid IL or missing references) //IL_06ef: Unknown result type (might be due to invalid IL or missing references) //IL_071f: Unknown result type (might be due to invalid IL or missing references) //IL_0724: Unknown result type (might be due to invalid IL or missing references) try { if (!(servant == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(servant)) { if (servant.Has() || servant.Has()) { return 0; } Entity val = default(Entity); if (InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, servant, ref val, 0) && !(val == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val)) { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val2 = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val, ref val2)) { return 0; } int home = Core.TerritoryService.GetTerritoryId(servant); if (home < 0) { home = Core.TerritoryService.GetStandingTerritoryId(servant); } PrefabGUID item; if (home < 0) { item = default(PrefabGUID); DestDebugLog.Miss("servant", -1, item, 0, 0, "no-plot"); return 0; } IReadOnlyList servantStashPlotIds = Core.TerritoryService.GetServantStashPlotIds(home); if (servantStashPlotIds == null || servantStashPlotIds.Count == 0) { int plot = home; item = default(PrefabGUID); DestDebugLog.Miss("servant", plot, item, 0, 0, "no-dest-plots"); return 0; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(home, out var platformId); List<(Entity, Entity)> list = new List<(Entity, Entity)>(100); DynamicBuffer val3 = default(DynamicBuffer); foreach (int item2 in servantStashPlotIds) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(item2); if (castleHeart == Entity.Null || TerritoryService.IsHeartRaided(castleHeart)) { continue; } foreach (Entity item3 in Core.Stash.ChestsOnPlot(item2)) { if (item3.Has()) { continue; } string name = StashRouting.RawName(item3); if (StashRouting.IsNoShareName(name) || StashRouting.IsSpecialName(name)) { continue; } serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(item3, ref val3)) { continue; } Enumerator enumerator3 = val3.GetEnumerator(); while (enumerator3.MoveNext()) { Entity entity = enumerator3.Current.Entity; if (entity.Has()) { item = entity.Read(); if (((PrefabGUID)(ref item)).Equals(StashService.ChestBagGuid)) { list.Add((item3, entity)); } } } } } if (list.Count == 0) { int plot2 = home; item = default(PrefabGUID); DestDebugLog.Miss("servant", plot2, item, 0, 0, "no-dest"); return 0; } Entity[] array = (from s in servantStashPlotIds.Where((int id) => !TerritoryService.IsHeartRaided(Core.TerritoryService.GetCastleHeart(id))).SelectMany(Core.Stash.OverflowChests) orderby StashRouting.IsSpecialName(StashRouting.RawName(s)) ? 1 : 0, (Core.TerritoryService.GetTerritoryId(s) != home) ? 1 : 0 select s).ToArray(); AddItemSettings addItemSettings = Utilities.GetAddItemSettings(); int num = 0; Entity entity2 = default(Entity); DynamicBuffer val10 = default(DynamicBuffer); for (int num2 = 0; num2 < val2.Length; num2++) { InventoryBuffer val4 = val2[num2]; PrefabGUID itemType = val4.ItemType; if (((PrefabGUID)(ref itemType)).GuidHash == 0) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val4.ItemEntity)).GetEntityOnServer(); bool num3 = !((Entity)(ref entityOnServer)).Equals(Entity.Null); List<(Entity, Entity)> list2 = StashRouting.OrderDepositDests(list, itemType, platformId, home); if (num3) { bool flag = false; foreach (var item4 in list2) { DynamicBuffer val5 = item4.Item2.ReadBuffer(); for (int num4 = 0; num4 < val5.Length; num4++) { InventoryBuffer val6 = val5[num4]; if (((PrefabGUID)(ref val6.ItemType)).Equals(PrefabGUID.Empty)) { val5[num4] = val4; Entity entityOnServer2 = ((NetworkedEntity)(ref val4.ItemEntity)).GetEntityOnServer(); if (entityOnServer2.Has()) { InventoryItem componentData = entityOnServer2.Read(); (componentData.ContainerEntity, _) = item4; entityOnServer2.Write(componentData); } InventoryUtilitiesServer.ClearSlot(Core.EntityManager, val, num2); StashRouting.DepositRank depositRank = StashRouting.RankDeposit(item4.Item1, itemType, platformId, hasItem: true, home); DestDebugLog.Move("servant", home, itemType, 1, servant, item4.Item1, depositRank.Label + "/c" + depositRank.Class, 0, "stays"); num++; flag = true; break; } } if (flag) { break; } } continue; } foreach (var item5 in list2) { AddItemResponse val7 = InventoryUtilitiesServer.TryAddItem(addItemSettings, item5.Item2, val4); if (((AddItemResponse)(ref val7)).Success) { int num5 = val4.Amount - val7.RemainingAmount; if (num5 > 0) { StashRouting.DepositRank depositRank2 = StashRouting.RankDeposit(item5.Item1, itemType, platformId, hasItem: true, home); DestDebugLog.Move("servant", home, itemType, num5, servant, item5.Item1, depositRank2.Label + "/c" + depositRank2.Class, 0, "stays"); num += num5; } val4.Amount = val7.RemainingAmount; if (!((AddItemResponse)(ref val7)).ItemsRemaining) { InventoryUtilitiesServer.ClearSlot(Core.EntityManager, val, num2); break; } } } if (val4.Amount <= 0) { continue; } ItemData val8 = default(ItemData); if (array.Length != 0) { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(itemType, ref entity2)) { val8 = entity2.Read(); } } bool flag2 = (long)val8.ItemCategory == 1073741824; Entity[] array2 = array; foreach (Entity val9 in array2) { serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val9, ref val10)) { continue; } Entity val11 = Entity.Null; Enumerator enumerator5 = val10.GetEnumerator(); while (enumerator5.MoveNext()) { InventoryInstanceElement current5 = enumerator5.Current; if ((!(current5.RestrictedType != PrefabGUID.Empty) || !(current5.RestrictedType != val8.ItemTypeGUID)) && (current5.RestrictedCategory == 0L || (int)(current5.RestrictedCategory & val8.ItemCategory) != 0) && (!flag2 || current5.RestrictedCategory != 0L)) { NetworkedEntity externalInventoryEntity = current5.ExternalInventoryEntity; val11 = ((NetworkedEntity)(ref externalInventoryEntity)).GetEntityOnServer(); } } if (val11 == Entity.Null) { continue; } AddItemResponse val12 = InventoryUtilitiesServer.TryAddItem(addItemSettings, val11, val4); if (((AddItemResponse)(ref val12)).Success) { int num7 = val4.Amount - val12.RemainingAmount; if (num7 > 0) { DestDebugLog.Move("servant", home, itemType, num7, servant, val9, "overflow", 0, "stays"); num += num7; } val4.Amount = val12.RemainingAmount; if (!((AddItemResponse)(ref val12)).ItemsRemaining) { InventoryUtilitiesServer.ClearSlot(Core.EntityManager, val, num2); break; } } } if (val4.Amount > 0) { val2[num2] = val4; } } DestDebugLog.Note("servant", home, platformId, "stash plots=" + servantStashPlotIds.Count + " dests=" + list.Count + " moved=" + num); return num; } } return 0; } } return 0; } catch (Exception e) { Core.LogException(e, "StashServantLoot"); return 0; } } public unsafe static string List(int plotFilter) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"plot\":").Append(plotFilter).Append(",\"servants\":["); bool flag = true; EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); DynamicBuffer val8 = default(DynamicBuffer); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val5) || !val5.Has()) { continue; } int territoryId = Core.TerritoryService.GetTerritoryId(val5); if (plotFilter >= 0 && territoryId != plotFilter) { continue; } ServantCoffinstation val6 = val5.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val6.ConnectedServant)).GetEntityOnServer(); string s = ((object)(*(FixedString64Bytes*)(&val6.ServantName))/*cast due to .constrained prefix*/).ToString(); int num = 0; int num2 = 0; Entity val7 = Entity.Null; if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, entityOnServer, ref val7, 0) && val7 != Entity.Null) { ServerGameManager serverGameManager = Core.ServerGameManager; if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val7, ref val8)) { HashSet hashSet = new HashSet(); for (int j = 0; j < val8.Length; j++) { InventoryBuffer val9 = val8[j]; if (((PrefabGUID)(ref val9.ItemType)).GuidHash != 0 && val8[j].Amount > 0) { num += val8[j].Amount; val9 = val8[j]; if (hashSet.Add(((PrefabGUID)(ref val9.ItemType)).GuidHash)) { num2++; } } } } } } if (!flag) { stringBuilder.Append(','); } flag = false; int num3; if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has()) { num3 = (entityOnServer.Read().IsOnMission ? 1 : 0); goto IL_0232; } } num3 = 0; goto IL_0232; IL_0302: object stringBuilder2; object value; ((StringBuilder)stringBuilder2).Append((string?)value).Append('}'); continue; IL_0232: bool flag2 = (byte)num3 != 0; stringBuilder2 = stringBuilder.Append("{\"plot\":").Append(territoryId).Append(",\"name\":\"") .Append(DebugPeekServiceEsc(s)) .Append('"') .Append(",\"state\":\"") .Append(((object)(*(ServantCoffinState*)(&val6.State))/*cast due to .constrained prefix*/).ToString()) .Append('"') .Append(",\"stacks\":") .Append(num) .Append(",\"kinds\":") .Append(num2) .Append(",\"onMission\":") .Append(flag2 ? "true" : "false") .Append(",\"hasServant\":"); if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { value = "true"; goto IL_0302; } } value = "false"; goto IL_0302; } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } stringBuilder.Append("]}"); return stringBuilder.ToString(); } private static string DebugPeekServiceEsc(string s) { if (string.IsNullOrEmpty(s)) { return ""; } return s.Replace("\\", "\\\\").Replace("\"", "\\\""); } public static string StashAll(int plotFilter) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) HashSet seen = new HashSet(); int servants = 0; int num = 0; int moved = 0; int skipped = 0; EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = default(NativeArray); try { val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; num++; Consider(val5); if (!(val5 == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val5) && val5.Has()) { ServantCoffinstation val6 = val5.Read(); Consider(((NetworkedEntity)(ref val6.ConnectedServant)).GetEntityOnServer()); } } } } finally { if (val4.IsCreated) { val4.Dispose(); } ((EntityQuery)(ref val3)).Dispose(); } val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val7 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); entityManager = Core.EntityManager; EntityQuery val8 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val7); ((EntityQueryBuilder)(ref val7)).Dispose(); NativeArray val9 = default(NativeArray); try { val9 = ((EntityQuery)(ref val8)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int j = 0; j < val9.Length; j++) { Consider(val9[j]); } } finally { if (val9.IsCreated) { val9.Dispose(); } ((EntityQuery)(ref val8)).Dispose(); } return "{\"plot\":" + plotFilter + ",\"coffins\":" + num + ",\"stashed\":" + servants + ",\"moved\":" + moved + ",\"skipped\":" + skipped + "}"; void Consider(Entity e) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!(e == Entity.Null)) { EntityManager entityManager2 = Core.EntityManager; if (((EntityManager)(ref entityManager2)).Exists(e) && seen.Add(e.Index)) { if (plotFilter >= 0) { int num2 = Core.TerritoryService.GetTerritoryId(e); if (num2 < 0) { num2 = Core.TerritoryService.GetStandingTerritoryId(e); } if (num2 != plotFilter) { skipped++; return; } } moved += Deposit(e); servants++; } } } } } internal static class ServerHost { private static MonoBehaviour behaviour; public static World Find(string name) { Enumerator enumerator = World.s_AllWorlds.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == name) { return current; } } return null; } public static void Start(IEnumerator routine) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if ((Object)(object)behaviour == (Object)null) { GameObject val = new GameObject("Satisvampory"); behaviour = (MonoBehaviour)(object)val.AddComponent(); Object.DontDestroyOnLoad((Object)val); } behaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine)); } public static IEnumerator SettingsFlushLoop() { WaitForSeconds wait = new WaitForSeconds(2f); while (true) { yield return wait; Core.PlayerSettings.FlushSettings(); } } public static void Boot() { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown Core.PrefabCollectionSystem = Core.Server.GetExistingSystemManaged(); Core.ServerGameSettingsSystem = Core.Server.GetExistingSystemManaged(); Core.DebugEventsSystem = Core.Server.GetExistingSystemManaged(); Core.ServerScriptMapper = Core.Server.GetExistingSystemManaged(); Core.RefinementStations = new RefinementStationsService(); Core.RegionService = new RegionService(); Core.SalvageService = new SalvageService(); Core.TerritoryService = new TerritoryService(); Core.UnitSpawnerstationService = new UnitSpawnerstationService(); Core.BrazierService = new BrazierService(); Core.ConveyorService = new ConveyorService(); Core.WorkQueue = new WorkQueueService(); Core.MarkBooted(); Core.WorkQueue.EnqueueAll(); RepeatHunts.PublishClientState(); if (Core.PlayerSettings.IsRepeatHuntEnabled()) { RepeatHunts.CaptureActiveMissions(); } Start(ClanTreasuryLend.Loop()); Start(DebugPeekService.Loop()); DropTracker.SeedExisting(); Start(DropTracker.DiscoverLoop()); Start(ScoopService.AutoScoopLoop()); Start(HuntLoginNote.Loop()); Start(SettingsFlushLoop()); FoundItemConverter.LoadItemNames(); ItemGroupService.Initialize(); FixHiddenGlassBottleRecipe(); Core.Log.LogInfo((object)"Satisvampory initialized"); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(99, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Satisvampory "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.0.85"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": logistics + scoop. Chest labels s#/r#/overflow/salvage/spoils/trash/NS/'' unchanged."); } log.LogInfo(val); } public static void FixHiddenGlassBottleRecipe() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(461575192); PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity val2 = default(Entity); if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(val, ref val2)) { return; } EntityQueryBuilder val3 = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val3 = ((EntityQueryBuilder)(ref val3)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); val3 = ((EntityQueryBuilder)(ref val3)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); val3 = ((EntityQueryBuilder)(ref val3)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)0)); EntityQueryBuilder val4 = ((EntityQueryBuilder)(ref val3)).WithOptions((EntityQueryOptions)3); EntityManager entityManager = Core.EntityManager; EntityQuery val5 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val4); ((EntityQueryBuilder)(ref val4)).Dispose(); NativeArray val6 = ((EntityQuery)(ref val5)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { bool flag = default(bool); for (int i = 0; i < val6.Length; i++) { Entity val7 = val6[i]; PrefabGUID val8 = val7.Read(); if (((PrefabGUID)(ref val8)).GuidHash != -222851985) { continue; } entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(val7, false); for (int j = 0; j < buffer.Length; j++) { RefinementstationRecipesBuffer val9 = buffer[j]; if (((PrefabGUID)(ref val9.RecipeGuid)).GuidHash == 394757670) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val10 = new BepInExInfoLogInterpolatedStringHandler(29, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val10).AppendLiteral("Replacing recipe "); ((BepInExLogInterpolatedStringHandler)val10).AppendFormatted(val9.RecipeGuid.LookupName()); ((BepInExLogInterpolatedStringHandler)val10).AppendLiteral(" on "); ((BepInExLogInterpolatedStringHandler)val10).AppendFormatted(val7.EntityName()); ((BepInExLogInterpolatedStringHandler)val10).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val10).AppendFormatted(val7.Index); ((BepInExLogInterpolatedStringHandler)val10).AppendLiteral(":"); ((BepInExLogInterpolatedStringHandler)val10).AppendFormatted(val7.Version); ((BepInExLogInterpolatedStringHandler)val10).AppendLiteral(" with "); ((BepInExLogInterpolatedStringHandler)val10).AppendFormatted(val.LookupName()); } log.LogInfo(val10); val9.RecipeGuid = val; buffer[j] = val9; } } } } finally { val6.Dispose(); ((EntityQuery)(ref val5)).Dispose(); } } } internal static class SettingsExtras { private static PlayerSettingsService S => Core.PlayerSettings; internal static bool IsRrGlobalEnabled(ulong playerId) { if (S.Snapshot(playerId, create: false).RrGlobal) { if (S.TryRow(0uL, out var settings)) { return settings.RrGlobalAllow; } return true; } return false; } internal static bool ToggleRrGlobal(ulong playerId = 0uL) { if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } if (playerId == 0L) { settings.RrGlobalAllow = !settings.RrGlobalAllow; S.Put(playerId, settings); S.MarkDirty(); return settings.RrGlobalAllow; } settings.RrGlobal = !settings.RrGlobal; S.Put(playerId, settings); S.MarkDirty(); return settings.RrGlobal; } internal static bool IsRrGlobalServerAllowed() { if (S.TryRow(0uL, out var settings)) { return settings.RrGlobalAllow; } return true; } internal static int GetPullReserve(ulong playerId, PrefabGUID item = default(PrefabGUID)) { if (!S.IsDontPullLastEnabled(playerId)) { return 0; } if (!S.TryRow(playerId, out var settings)) { settings = S.Blank; } if (((PrefabGUID)(ref item)).GuidHash != 0 && settings.ItemReserves != null && settings.ItemReserves.TryGetValue(((PrefabGUID)(ref item)).GuidHash.ToString(), out var value)) { return value; } if (settings.PullReserve <= 0) { return 10; } return settings.PullReserve; } internal static int SetPullReserve(ulong playerId, int amount) { if (amount < 0) { amount = 0; } if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } settings.PullReserve = amount; settings.DontPullLast = amount > 0; S.Put(playerId, settings); S.MarkDirty(); return settings.PullReserve; } internal static int SetItemReserve(ulong playerId, PrefabGUID item, string itemName, int amount) { if (amount < 0) { amount = 0; } if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ItemReserves == null) { Dictionary dictionary = (reference.ItemReserves = new Dictionary()); } reference = ref settings; if (reference.ItemReserveNames == null) { Dictionary dictionary3 = (reference.ItemReserveNames = new Dictionary()); } string key = ((PrefabGUID)(ref item)).GuidHash.ToString(); settings.ItemReserves[key] = amount; settings.ItemReserveNames[key] = itemName; if (amount > 0) { settings.DontPullLast = true; } S.Put(playerId, settings); S.MarkDirty(); return amount; } internal static bool ClearItemReserve(ulong playerId, PrefabGUID item) { if (!S.TryRow(playerId, out var settings)) { return false; } if (settings.ItemReserves == null) { return false; } string key = ((PrefabGUID)(ref item)).GuidHash.ToString(); bool result = settings.ItemReserves.Remove(key); settings.ItemReserveNames?.Remove(key); S.Put(playerId, settings); S.MarkDirty(); return result; } internal static IEnumerable<(string name, int amount)> ListItemReserves(ulong playerId) { if (!S.TryRow(playerId, out var settings) || settings.ItemReserves == null) { yield break; } foreach (KeyValuePair itemReserf in settings.ItemReserves) { string item = itemReserf.Key; if (settings.ItemReserveNames != null && settings.ItemReserveNames.TryGetValue(itemReserf.Key, out var value) && !string.IsNullOrEmpty(value)) { item = value; } yield return (name: item, amount: itemReserf.Value); } } internal static int GetItemReserveOverrideCount(ulong playerId) { if (!S.Rows.TryGetValue(playerId, out var value) || value.ItemReserves == null) { return 0; } return value.ItemReserves.Count; } internal static bool TryGetItemCap(ulong playerId, PrefabGUID item, out int cap) { cap = 0; if (!S.TryRow(playerId, out var settings)) { return false; } if (settings.ItemCaps == null) { return false; } if (((PrefabGUID)(ref item)).GuidHash == 0) { return false; } return settings.ItemCaps.TryGetValue(((PrefabGUID)(ref item)).GuidHash.ToString(), out cap); } internal static int SetItemCap(ulong playerId, PrefabGUID item, string itemName, int amount) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (amount < 0) { ClearItemCap(playerId, item); return amount; } if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ItemCaps == null) { Dictionary dictionary = (reference.ItemCaps = new Dictionary()); } reference = ref settings; if (reference.ItemCapNames == null) { Dictionary dictionary3 = (reference.ItemCapNames = new Dictionary()); } string key = ((PrefabGUID)(ref item)).GuidHash.ToString(); settings.ItemCaps[key] = amount; settings.ItemCapNames[key] = itemName; S.Put(playerId, settings); S.MarkDirty(); return amount; } internal static bool ClearItemCap(ulong playerId, PrefabGUID item) { if (!S.TryRow(playerId, out var settings)) { return false; } if (settings.ItemCaps == null) { return false; } string key = ((PrefabGUID)(ref item)).GuidHash.ToString(); bool result = settings.ItemCaps.Remove(key); settings.ItemCapNames?.Remove(key); S.Put(playerId, settings); S.MarkDirty(); return result; } internal static IEnumerable<(string name, int amount)> ListItemCaps(ulong playerId) { if (!S.TryRow(playerId, out var settings) || settings.ItemCaps == null) { yield break; } foreach (KeyValuePair itemCap in settings.ItemCaps) { string item = itemCap.Key; if (settings.ItemCapNames != null && settings.ItemCapNames.TryGetValue(itemCap.Key, out var value) && !string.IsNullOrEmpty(value)) { item = value; } yield return (name: item, amount: itemCap.Value); } } internal static int GetItemCapOverrideCount(ulong playerId) { if (!S.Rows.TryGetValue(playerId, out var value) || value.ItemCaps == null) { return 0; } return value.ItemCaps.Count; } internal static bool IsConveyorLoopsAllowed() { if (S.TryRow(0uL, out var settings)) { return settings.ConveyorLoops; } return false; } internal static bool ToggleConveyorLoops() { if (!S.TryRow(0uL, out var settings)) { settings = new SettingsRow(); } settings.ConveyorLoops = !settings.ConveyorLoops; S.Put(0uL, settings); S.MarkDirty(); return settings.ConveyorLoops; } internal static bool IsGlobalSalvageEnabled() { if (S.TryRow(0uL, out var settings)) { return settings.Salvage; } return true; } internal static string PlotSalvageKey(int territoryId) { return territoryId.ToString(); } internal static bool GetPlotSalvageFlag(ulong heartOwnerId, int territoryId) { SettingsRow settings; bool value = default(bool); return S.TryRow(heartOwnerId, out settings) && settings.PlotSalvage != null && settings.PlotSalvage.TryGetValue(PlotSalvageKey(territoryId), out value) && value; } internal static bool TogglePlotSalvage(ulong heartOwnerId, int territoryId) { if (!S.Rows.TryGetValue(heartOwnerId, out var value)) { value = new SettingsRow(); } if (value.PlotSalvage == null) { Dictionary dictionary = (value.PlotSalvage = new Dictionary()); } string key = PlotSalvageKey(territoryId); bool value2; bool flag = !(value.PlotSalvage.TryGetValue(key, out value2) && value2); value.PlotSalvage[key] = flag; S.Rows[heartOwnerId] = value; S.MarkDirty(); return flag; } internal static string HeartFeedKey(int territoryId) { return territoryId.ToString(); } internal static bool IsHeartFeedEnabled(ulong heartOwnerId, int territoryId) { SettingsRow settings; bool value = default(bool); return !S.TryRow(heartOwnerId, out settings) || settings.HeartFeed == null || !settings.HeartFeed.TryGetValue(HeartFeedKey(territoryId), out value) || value; } internal static bool ToggleHeartFeed(ulong heartOwnerId, int territoryId) { if (!S.Rows.TryGetValue(heartOwnerId, out var value)) { value = new SettingsRow(); } if (value.HeartFeed == null) { Dictionary dictionary = (value.HeartFeed = new Dictionary()); } string key = HeartFeedKey(territoryId); bool value2; bool flag = !(!value.HeartFeed.TryGetValue(key, out value2) || value2); value.HeartFeed[key] = flag; S.Rows[heartOwnerId] = value; S.MarkDirty(); return flag; } internal static bool IsHeartFuelSeeded(string heartKey) { if (string.IsNullOrEmpty(heartKey)) { return false; } if (!S.TryRow(0uL, out var settings) || settings.HeartFuelSeeded == null) { return false; } return settings.HeartFuelSeeded.Contains(heartKey); } internal static void MarkHeartFuelSeeded(params string[] heartKeys) { if (!S.TryRow(0uL, out var settings)) { settings = new SettingsRow(); } if (settings.HeartFuelSeeded == null) { List list = (settings.HeartFuelSeeded = new List()); } bool flag = false; foreach (string text in heartKeys) { if (!string.IsNullOrEmpty(text) && !settings.HeartFuelSeeded.Contains(text)) { settings.HeartFuelSeeded.Add(text); flag = true; } } if (flag) { S.Put(0uL, settings); S.MarkDirty(); } } internal static bool IsHeartFuelOptOut(string heartKey) { if (string.IsNullOrEmpty(heartKey)) { return false; } if (!S.TryRow(0uL, out var settings) || settings.HeartFuelOptOut == null) { return false; } return settings.HeartFuelOptOut.Contains(heartKey); } internal static void SetHeartFuelOptOut(bool optedOut, params string[] heartKeys) { if (!S.TryRow(0uL, out var settings)) { settings = new SettingsRow(); } if (settings.HeartFuelOptOut == null) { List list = (settings.HeartFuelOptOut = new List()); } bool flag = false; foreach (string text in heartKeys) { if (string.IsNullOrEmpty(text)) { continue; } if (optedOut) { if (!settings.HeartFuelOptOut.Contains(text)) { settings.HeartFuelOptOut.Add(text); flag = true; } } else if (settings.HeartFuelOptOut.Remove(text)) { flag = true; } } if (flag) { S.Put(0uL, settings); S.MarkDirty(); } } internal static bool IsAutoEnabled(ulong platformId) { return S.GetOrCreate(platformId).AutoScoop; } internal static bool ToggleAuto(ulong platformId) { SettingsRow orCreate = S.GetOrCreate(platformId); orCreate.AutoScoop = !orCreate.AutoScoop; S.Put(platformId, orCreate); return orCreate.AutoScoop; } internal static bool TryParseAutoFilter(string value, out AutoFilter filter) { filter = AutoFilter.Around; if (string.IsNullOrWhiteSpace(value)) { return false; } if (string.Equals(value, "around", StringComparison.OrdinalIgnoreCase)) { filter = AutoFilter.Around; return true; } if (string.Equals(value, "all", StringComparison.OrdinalIgnoreCase)) { filter = AutoFilter.All; return true; } return false; } internal static AutoFilter GetAutoFilter(ulong platformId) { if (!TryParseAutoFilter(S.GetOrCreate(platformId).AutoFilter, out var filter)) { return AutoFilter.All; } return filter; } internal static AutoFilter SetAutoFilter(ulong platformId, AutoFilter filter) { SettingsRow orCreate = S.GetOrCreate(platformId); orCreate.AutoFilter = ((filter == AutoFilter.All) ? "all" : "around"); S.Put(platformId, orCreate); return filter; } internal static void SetAutoOnWithFilter(ulong platformId, AutoFilter filter) { SettingsRow orCreate = S.GetOrCreate(platformId); orCreate.AutoScoop = true; orCreate.AutoFilter = ((filter == AutoFilter.All) ? "all" : "around"); S.Put(platformId, orCreate); } internal static bool TryParseNotifyMode(string value, out NotifyMode mode) { mode = NotifyMode.Manual; if (string.IsNullOrWhiteSpace(value)) { return false; } if (string.Equals(value, "off", StringComparison.OrdinalIgnoreCase)) { mode = NotifyMode.Off; return true; } if (string.Equals(value, "manual", StringComparison.OrdinalIgnoreCase)) { mode = NotifyMode.Manual; return true; } if (string.Equals(value, "on", StringComparison.OrdinalIgnoreCase)) { mode = NotifyMode.On; return true; } return false; } internal static NotifyMode GetNotifyMode(ulong platformId) { if (!TryParseNotifyMode(S.GetOrCreate(platformId).NotifyMode, out var mode)) { return NotifyMode.Manual; } return mode; } internal static NotifyMode SetNotifyMode(ulong platformId, NotifyMode mode) { SettingsRow orCreate = S.GetOrCreate(platformId); orCreate.NotifyMode = mode switch { NotifyMode.Off => "off", NotifyMode.On => "on", _ => "manual", }; S.Put(platformId, orCreate); return mode; } internal static float GetRadius(ulong platformId) { float num = S.GetOrCreate(platformId).Radius; if (num < 1f) { num = 10f; } if (num > 50f) { num = 50f; } return num; } internal static float SetRadius(ulong platformId, float radius) { if (radius < 1f) { radius = 1f; } if (radius > 50f) { radius = 50f; } SettingsRow orCreate = S.GetOrCreate(platformId); orCreate.Radius = radius; S.Put(platformId, orCreate); return orCreate.Radius; } internal static CapMode GetCapMode(ulong platformId) { if (!string.Equals(S.GetOrCreate(platformId).ScoopMode, "guild", StringComparison.OrdinalIgnoreCase)) { return CapMode.Bags; } return CapMode.Guild; } internal static CapMode SetCapMode(ulong platformId, CapMode mode) { SettingsRow orCreate = S.GetOrCreate(platformId); orCreate.ScoopMode = ((mode == CapMode.Guild) ? "guild" : "bags"); S.Put(platformId, orCreate); return mode; } internal static bool IsExcluded(ulong platformId, PrefabGUID item) { return S.GetOrCreate(platformId).ScoopExcludes.Contains(((PrefabGUID)(ref item)).GuidHash.ToString()); } internal static bool ToggleExclude(ulong platformId, PrefabGUID item, string name) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) SettingsRow orCreate = S.GetOrCreate(platformId); string text = ((PrefabGUID)(ref item)).GuidHash.ToString(); if (orCreate.ScoopExcludes.Contains(text)) { orCreate.ScoopExcludes.Remove(text); orCreate.ScoopExcludeNames.Remove(text); S.Put(platformId, orCreate); return false; } orCreate.ScoopExcludes.Add(text); orCreate.ScoopExcludeNames[text] = name ?? item.PrefabName(); S.Put(platformId, orCreate); return true; } internal static IReadOnlyList<(PrefabGUID prefab, string name)> ListExcludes(ulong platformId) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) SettingsRow orCreate = S.GetOrCreate(platformId); List<(PrefabGUID, string)> list = new List<(PrefabGUID, string)>(); PrefabGUID val = default(PrefabGUID); foreach (string scoopExclude in orCreate.ScoopExcludes) { if (int.TryParse(scoopExclude, out var result)) { ((PrefabGUID)(ref val))..ctor(result); orCreate.ScoopExcludeNames.TryGetValue(scoopExclude, out var value); if (string.IsNullOrEmpty(value)) { value = val.PrefabName(); } list.Add((val, value)); } } return list; } internal static int GetCap(ulong platformId, PrefabGUID item) { if (S.GetOrCreate(platformId).ScoopCaps.TryGetValue(((PrefabGUID)(ref item)).GuidHash.ToString(), out var value)) { return value; } return -1; } internal static void SetScoopCap(ulong platformId, PrefabGUID item, int cap, string name) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) SettingsRow orCreate = S.GetOrCreate(platformId); string key = ((PrefabGUID)(ref item)).GuidHash.ToString(); if (cap < 0) { orCreate.ScoopCaps.Remove(key); orCreate.ScoopCapNames.Remove(key); } else { orCreate.ScoopCaps[key] = cap; orCreate.ScoopCapNames[key] = name ?? item.PrefabName(); } S.Put(platformId, orCreate); } internal static void ClearAllScoopCaps(ulong platformId) { SettingsRow orCreate = S.GetOrCreate(platformId); orCreate.ScoopCaps.Clear(); orCreate.ScoopCapNames.Clear(); S.Put(platformId, orCreate); } internal static IReadOnlyList<(PrefabGUID prefab, string name, int cap)> ListScoopCaps(ulong platformId) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) SettingsRow orCreate = S.GetOrCreate(platformId); List<(PrefabGUID, string, int)> list = new List<(PrefabGUID, string, int)>(); PrefabGUID val = default(PrefabGUID); foreach (KeyValuePair scoopCap in orCreate.ScoopCaps) { if (int.TryParse(scoopCap.Key, out var result)) { ((PrefabGUID)(ref val))..ctor(result); orCreate.ScoopCapNames.TryGetValue(scoopCap.Key, out var value); if (string.IsNullOrEmpty(value)) { value = val.PrefabName(); } list.Add((val, value, scoopCap.Value)); } } return list; } internal static bool IsClanShareEnabled(ulong playerId) { if (!S.TryRow(playerId, out var settings)) { return false; } return settings.ClanShare; } internal static bool ToggleClanShare(ulong playerId) { if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } settings.ClanShare = !settings.ClanShare; S.Put(playerId, settings); S.MarkDirty(); return settings.ClanShare; } internal static bool TryGetClanShareFlag(string clanKey, out bool enabled) { enabled = false; if (string.IsNullOrEmpty(clanKey)) { return false; } if (!S.TryRow(0uL, out var settings) || settings.ClanShareByClan == null) { return false; } return settings.ClanShareByClan.TryGetValue(clanKey, out enabled); } internal static void SetClanShareForClan(string clanKey, bool enabled) { if (!string.IsNullOrEmpty(clanKey)) { SettingsRow globalMutable = S.GetGlobalMutable(); globalMutable.ClanShareByClan[clanKey] = enabled; S.Put(0uL, globalMutable); S.MarkDirty(); if (Core.HasInitialized && Core.TerritoryService != null) { Core.TerritoryService.InvalidateClanPlotCache(); } } } internal static bool ToggleClanShareForClan(string clanKey, bool current) { bool flag = !current; SetClanShareForClan(clanKey, flag); return flag; } internal static string TerritoryExcludeKey(int territoryId) { return "t" + territoryId; } internal static bool IsTerritoryClanShareExcluded(int territoryId) { if (!S.TryRow(0uL, out var settings) || settings.ClanShareExcludedTerritories == null) { return false; } return settings.ClanShareExcludedTerritories.Contains(TerritoryExcludeKey(territoryId)); } internal static bool ToggleTerritoryClanShareExclude(int territoryId) { SettingsRow globalMutable = S.GetGlobalMutable(); string item = TerritoryExcludeKey(territoryId); bool num = globalMutable.ClanShareExcludedTerritories.Contains(item); if (num) { globalMutable.ClanShareExcludedTerritories.Remove(item); } else { globalMutable.ClanShareExcludedTerritories.Add(item); } S.Put(0uL, globalMutable); S.MarkDirty(); if (Core.HasInitialized && Core.TerritoryService != null) { Core.TerritoryService.InvalidateClanPlotCache(); } return !num; } internal static bool IsStarterKitSeeded(string key) { if (string.IsNullOrEmpty(key)) { return false; } if (!S.TryRow(0uL, out var settings) || settings.StarterKitSeeded == null) { return false; } return settings.StarterKitSeeded.Contains(key); } internal static void MarkStarterKitSeeded(params string[] keys) { if (keys == null || keys.Length == 0) { return; } SettingsRow globalMutable = S.GetGlobalMutable(); bool flag = false; foreach (string text in keys) { if (!string.IsNullOrEmpty(text) && !globalMutable.StarterKitSeeded.Contains(text)) { globalMutable.StarterKitSeeded.Add(text); flag = true; } } if (flag) { S.Put(0uL, globalMutable); S.MarkDirty(); } } internal static bool IsStarterKitChestSeeded(string key) { if (string.IsNullOrEmpty(key)) { return false; } if (!S.TryRow(0uL, out var settings) || settings.StarterKitChestSeeded == null) { return false; } return settings.StarterKitChestSeeded.Contains(key); } internal static void MarkStarterKitChestSeeded(params string[] keys) { if (keys == null || keys.Length == 0) { return; } SettingsRow globalMutable = S.GetGlobalMutable(); bool flag = false; foreach (string text in keys) { if (!string.IsNullOrEmpty(text) && !globalMutable.StarterKitChestSeeded.Contains(text)) { globalMutable.StarterKitChestSeeded.Add(text); flag = true; } } if (flag) { S.Put(0uL, globalMutable); S.MarkDirty(); } } internal static bool IsStarterKitChestOptOut(string key) { if (string.IsNullOrEmpty(key)) { return false; } if (!S.TryRow(0uL, out var settings) || settings.StarterKitChestOptOut == null) { return false; } return settings.StarterKitChestOptOut.Contains(key); } internal static void SetStarterKitChestOptOut(bool optedOut, params string[] keys) { if (keys == null || keys.Length == 0) { return; } SettingsRow globalMutable = S.GetGlobalMutable(); bool flag = false; foreach (string text in keys) { if (string.IsNullOrEmpty(text)) { continue; } if (optedOut) { if (!globalMutable.StarterKitChestOptOut.Contains(text)) { globalMutable.StarterKitChestOptOut.Add(text); flag = true; } } else if (globalMutable.StarterKitChestOptOut.Remove(text)) { flag = true; } } if (flag) { S.Put(0uL, globalMutable); S.MarkDirty(); } } internal static string NormalizeGroupKey(string name) { return ItemGroupService.NormalizeName(name); } internal static bool HasItemGroup(ulong playerId, string name) { if (!S.Rows.TryGetValue(playerId, out var value) || value.ItemGroups == null) { return false; } string value2 = NormalizeGroupKey(name); foreach (string key in value.ItemGroups.Keys) { if (NormalizeGroupKey(key).Equals(value2, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } internal static IEnumerable<(string name, int count)> ListCustomGroups(ulong playerId) { if (!S.Rows.TryGetValue(playerId, out var value) || value.ItemGroups == null) { yield break; } foreach (KeyValuePair> itemGroup in value.ItemGroups) { int item = ((itemGroup.Value != null) ? itemGroup.Value.Count : 0); yield return (name: itemGroup.Key, count: item); } } internal static IEnumerable<(string guid, string name)> ListItemGroupMembers(ulong playerId, string name) { if (!S.Rows.TryGetValue(playerId, out var value) || value.ItemGroups == null) { yield break; } string value2 = NormalizeGroupKey(name); string text = null; foreach (string key in value.ItemGroups.Keys) { if (NormalizeGroupKey(key).Equals(value2, StringComparison.OrdinalIgnoreCase)) { text = key; break; } } if (text == null) { yield break; } List list = value.ItemGroups[text]; if (list == null) { yield break; } Dictionary names = null; value.ItemGroupNames?.TryGetValue(text, out names); foreach (string item2 in list) { string item = item2; if (names != null && names.TryGetValue(item2, out var value3) && !string.IsNullOrEmpty(value3)) { item = value3; } yield return (guid: item2, name: item); } } internal static bool CreateItemGroup(ulong playerId, string name) { if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ItemGroups == null) { Dictionary> dictionary = (reference.ItemGroups = new Dictionary>()); } reference = ref settings; if (reference.ItemGroupNames == null) { Dictionary> dictionary3 = (reference.ItemGroupNames = new Dictionary>()); } string text = NormalizeGroupKey(name); if (HasItemGroup(playerId, text) || settings.ItemGroups.ContainsKey(text)) { return false; } settings.ItemGroups[text] = new List(); settings.ItemGroupNames[text] = new Dictionary(); S.Put(playerId, settings); S.MarkDirty(); return true; } internal static bool DeleteItemGroup(ulong playerId, string name) { if (!S.Rows.TryGetValue(playerId, out var value) || value.ItemGroups == null) { return false; } string value2 = NormalizeGroupKey(name); string text = null; foreach (string key in value.ItemGroups.Keys) { if (NormalizeGroupKey(key).Equals(value2, StringComparison.OrdinalIgnoreCase)) { text = key; break; } } if (text == null) { return false; } value.ItemGroups.Remove(text); value.ItemGroupNames?.Remove(text); S.Put(playerId, value); S.MarkDirty(); return true; } internal static bool AddItemToGroup(ulong playerId, string name, PrefabGUID item, string itemName) { if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ItemGroups == null) { Dictionary> dictionary = (reference.ItemGroups = new Dictionary>()); } reference = ref settings; if (reference.ItemGroupNames == null) { Dictionary> dictionary3 = (reference.ItemGroupNames = new Dictionary>()); } string text = NormalizeGroupKey(name); string key = text; foreach (string key2 in settings.ItemGroups.Keys) { if (NormalizeGroupKey(key2).Equals(text, StringComparison.OrdinalIgnoreCase)) { key = key2; break; } } if (!settings.ItemGroups.TryGetValue(key, out var value) || value == null) { value = new List(); settings.ItemGroups[key] = value; } if (!settings.ItemGroupNames.TryGetValue(key, out var value2) || value2 == null) { value2 = new Dictionary(); settings.ItemGroupNames[key] = value2; } string text2 = ((PrefabGUID)(ref item)).GuidHash.ToString(); if (!value.Contains(text2)) { value.Add(text2); } value2[text2] = itemName; S.Put(playerId, settings); S.MarkDirty(); return true; } internal static bool RemoveItemFromGroup(ulong playerId, string name, PrefabGUID item) { if (!S.Rows.TryGetValue(playerId, out var value) || value.ItemGroups == null) { return false; } string value2 = NormalizeGroupKey(name); string text = null; foreach (string key in value.ItemGroups.Keys) { if (NormalizeGroupKey(key).Equals(value2, StringComparison.OrdinalIgnoreCase)) { text = key; break; } } if (text == null) { return false; } string text2 = ((PrefabGUID)(ref item)).GuidHash.ToString(); bool result = value.ItemGroups[text]?.Remove(text2) ?? false; value.ItemGroupNames?.GetValueOrDefault(text)?.Remove(text2); S.Put(playerId, value); S.MarkDirty(); return result; } internal static int ApplyGroupAmounts(ulong playerId, IReadOnlyList<(PrefabGUID guid, string name)> items, bool isCap, int amount) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ItemReserves == null) { Dictionary dictionary = (reference.ItemReserves = new Dictionary()); } reference = ref settings; if (reference.ItemReserveNames == null) { Dictionary dictionary3 = (reference.ItemReserveNames = new Dictionary()); } reference = ref settings; if (reference.ItemCaps == null) { Dictionary dictionary = (reference.ItemCaps = new Dictionary()); } reference = ref settings; if (reference.ItemCapNames == null) { Dictionary dictionary3 = (reference.ItemCapNames = new Dictionary()); } int num = 0; foreach (var item in items) { var (val, value) = item; if (((PrefabGUID)(ref val)).GuidHash == 0) { continue; } string key = ((PrefabGUID)(ref val)).GuidHash.ToString(); if (isCap) { if (amount < 0) { settings.ItemCaps.Remove(key); settings.ItemCapNames.Remove(key); } else { settings.ItemCaps[key] = amount; settings.ItemCapNames[key] = value; } } else if (amount < 0) { settings.ItemReserves.Remove(key); settings.ItemReserveNames.Remove(key); } else { settings.ItemReserves[key] = amount; settings.ItemReserveNames[key] = value; if (amount > 0) { settings.DontPullLast = true; } } num++; } S.Put(playerId, settings); S.MarkDirty(); return num; } internal static bool IsDeletedGroup(ulong playerId, string name) { if (!S.Rows.TryGetValue(playerId, out var value) || value.DeletedGroups == null) { return false; } string value2 = NormalizeGroupKey(name); foreach (string deletedGroup in value.DeletedGroups) { if (NormalizeGroupKey(deletedGroup).Equals(value2, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } internal static bool HasGroupOverlay(ulong playerId, string name) { if (!S.Rows.TryGetValue(playerId, out var value) || value.OverlaidGroups == null) { return false; } string value2 = NormalizeGroupKey(name); foreach (string overlaidGroup in value.OverlaidGroups) { if (NormalizeGroupKey(overlaidGroup).Equals(value2, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } internal static bool ListContainsNormalized(List list, string key) { if (list == null) { return false; } foreach (string item in list) { if (NormalizeGroupKey(item).Equals(key, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } internal static void ListAddNormalized(List list, string key) { if (!ListContainsNormalized(list, key)) { list.Add(key); } } internal static bool ListRemoveNormalized(List list, string key) { if (list == null) { return false; } for (int num = list.Count - 1; num >= 0; num--) { if (NormalizeGroupKey(list[num]).Equals(key, StringComparison.OrdinalIgnoreCase)) { list.RemoveAt(num); return true; } } return false; } internal static string FindStoredGroupKey(Dictionary> groups, string key) { if (groups == null) { return null; } foreach (string key2 in groups.Keys) { if (NormalizeGroupKey(key2).Equals(key, StringComparison.OrdinalIgnoreCase)) { return key2; } } return null; } internal static void WriteGroupOverlay(ulong playerId, string name, IEnumerable<(string guid, string itemName)> members) { if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ItemGroups == null) { Dictionary> dictionary = (reference.ItemGroups = new Dictionary>()); } reference = ref settings; if (reference.ItemGroupNames == null) { Dictionary> dictionary3 = (reference.ItemGroupNames = new Dictionary>()); } reference = ref settings; if (reference.OverlaidGroups == null) { List list = (reference.OverlaidGroups = new List()); } reference = ref settings; if (reference.DeletedGroups == null) { List list = (reference.DeletedGroups = new List()); } string text = NormalizeGroupKey(name); string key = FindStoredGroupKey(settings.ItemGroups, text) ?? text; List list4 = new List(); Dictionary dictionary5 = new Dictionary(); foreach (var (text2, value) in members) { if (!string.IsNullOrEmpty(text2) && !list4.Contains(text2)) { list4.Add(text2); if (!string.IsNullOrEmpty(value)) { dictionary5[text2] = value; } } } settings.ItemGroups[key] = list4; settings.ItemGroupNames[key] = dictionary5; ListRemoveNormalized(settings.DeletedGroups, text); ListAddNormalized(settings.OverlaidGroups, text); S.Put(playerId, settings); S.MarkDirty(); } internal static bool DeleteBuiltInGroup(ulong playerId, string name) { if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ItemGroups == null) { Dictionary> dictionary = (reference.ItemGroups = new Dictionary>()); } reference = ref settings; if (reference.ItemGroupNames == null) { Dictionary> dictionary3 = (reference.ItemGroupNames = new Dictionary>()); } reference = ref settings; if (reference.OverlaidGroups == null) { List list = (reference.OverlaidGroups = new List()); } reference = ref settings; if (reference.DeletedGroups == null) { List list = (reference.DeletedGroups = new List()); } string key = NormalizeGroupKey(name); string text = FindStoredGroupKey(settings.ItemGroups, key); if (text != null) { settings.ItemGroups.Remove(text); settings.ItemGroupNames?.Remove(text); } ListRemoveNormalized(settings.OverlaidGroups, key); ListAddNormalized(settings.DeletedGroups, key); S.Put(playerId, settings); S.MarkDirty(); return true; } internal static bool RestoreBuiltInGroup(ulong playerId, string name) { if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ItemGroups == null) { Dictionary> dictionary = (reference.ItemGroups = new Dictionary>()); } reference = ref settings; if (reference.ItemGroupNames == null) { Dictionary> dictionary3 = (reference.ItemGroupNames = new Dictionary>()); } reference = ref settings; if (reference.OverlaidGroups == null) { List list = (reference.OverlaidGroups = new List()); } reference = ref settings; if (reference.DeletedGroups == null) { List list = (reference.DeletedGroups = new List()); } string key = NormalizeGroupKey(name); string text = FindStoredGroupKey(settings.ItemGroups, key); if (text != null) { settings.ItemGroups.Remove(text); settings.ItemGroupNames?.Remove(text); } bool result = (ListRemoveNormalized(settings.OverlaidGroups, key) | ListRemoveNormalized(settings.DeletedGroups, key)) || text != null; S.Put(playerId, settings); S.MarkDirty(); return result; } internal static List RestoreAllBuiltInGroups(ulong playerId, IEnumerable builtInNames) { if (!S.TryRow(playerId, out var settings)) { settings = new SettingsRow(); } ref SettingsRow reference = ref settings; if (reference.ItemGroups == null) { Dictionary> dictionary = (reference.ItemGroups = new Dictionary>()); } reference = ref settings; if (reference.ItemGroupNames == null) { Dictionary> dictionary3 = (reference.ItemGroupNames = new Dictionary>()); } reference = ref settings; if (reference.OverlaidGroups == null) { List list = (reference.OverlaidGroups = new List()); } reference = ref settings; if (reference.DeletedGroups == null) { List list = (reference.DeletedGroups = new List()); } List list4 = new List(); foreach (string builtInName in builtInNames) { string text = NormalizeGroupKey(builtInName); string text2 = FindStoredGroupKey(settings.ItemGroups, text); if (text2 != null) { settings.ItemGroups.Remove(text2); settings.ItemGroupNames?.Remove(text2); } ListRemoveNormalized(settings.OverlaidGroups, text); ListRemoveNormalized(settings.DeletedGroups, text); list4.Add(text); } S.Put(playerId, settings); S.MarkDirty(); return list4; } internal static void ImportGroundScoop(PlayerSettingsService store) { string path = Path.Combine(Paths.ConfigPath, "GroundScoop", "playerSettings.json"); if (!File.Exists(path)) { return; } try { using JsonDocument jsonDocument = JsonDocument.Parse(File.ReadAllText(path)); if (jsonDocument.RootElement.ValueKind != JsonValueKind.Object) { return; } foreach (JsonProperty item in jsonDocument.RootElement.EnumerateObject()) { if (ulong.TryParse(item.Name, out var result)) { SettingsRow orCreate = store.GetOrCreate(result); JsonElement value = item.Value; if (value.TryGetProperty("AutoScoop", out var value2)) { orCreate.AutoScoop = value2.GetBoolean(); } if (value.TryGetProperty("AutoFilter", out var value3)) { orCreate.AutoFilter = value3.GetString(); } if (value.TryGetProperty("NotifyMode", out var value4)) { orCreate.NotifyMode = value4.GetString(); } if (value.TryGetProperty("Radius", out var value5) && value5.TryGetSingle(out var value6)) { orCreate.Radius = value6; } if (value.TryGetProperty("Mode", out var value7)) { orCreate.ScoopMode = value7.GetString(); } CopyStringList(value, "Excludes", orCreate.ScoopExcludes); CopyStringMap(value, "ExcludeNames", orCreate.ScoopExcludeNames); CopyIntMap(value, "Caps", orCreate.ScoopCaps); CopyStringMap(value, "CapNames", orCreate.ScoopCapNames); store.Rows[result] = orCreate; } } store.MarkDirty(); } catch { } } private static void CopyStringList(JsonElement el, string name, List dest) { if (!el.TryGetProperty(name, out var value) || value.ValueKind != JsonValueKind.Array) { return; } foreach (JsonElement item in value.EnumerateArray()) { string text = item.GetString(); if (!string.IsNullOrEmpty(text) && !dest.Contains(text)) { dest.Add(text); } } } private static void CopyStringMap(JsonElement el, string name, Dictionary dest) { if (!el.TryGetProperty(name, out var value) || value.ValueKind != JsonValueKind.Object) { return; } foreach (JsonProperty item in value.EnumerateObject()) { dest[item.Name] = item.Value.GetString(); } } private static void CopyIntMap(JsonElement el, string name, Dictionary dest) { if (!el.TryGetProperty(name, out var value) || value.ValueKind != JsonValueKind.Object) { return; } foreach (JsonProperty item in value.EnumerateObject()) { if (item.Value.TryGetInt32(out var value2)) { dest[item.Name] = value2; } } } } internal struct SettingsRow { public bool SortStash { get; set; } public bool Pull { get; set; } public bool CraftPull { get; set; } public bool DontPullLast { get; set; } public int PullReserve { get; set; } public Dictionary ItemReserves { get; set; } public Dictionary ItemReserveNames { get; set; } public Dictionary ItemCaps { get; set; } public Dictionary ItemCapNames { get; set; } public Dictionary> ItemGroups { get; set; } public Dictionary> ItemGroupNames { get; set; } public List DeletedGroups { get; set; } public List OverlaidGroups { get; set; } public bool AutoStashMissions { get; set; } public bool Conveyor { get; set; } public bool ConveyorLoops { get; set; } public bool Salvage { get; set; } public bool UnitSpawner { get; set; } public bool Brazier { get; set; } public bool Named { get; set; } public bool SilentPull { get; set; } public bool SilentStash { get; set; } public bool Trash { get; set; } public bool RrGlobal { get; set; } public bool RrGlobalAllow { get; set; } public bool ClanShare { get; set; } public Dictionary PlotSalvage { get; set; } public Dictionary HeartFeed { get; set; } public List HeartFuelSeeded { get; set; } public List HeartFuelOptOut { get; set; } public Dictionary ClanShareByClan { get; set; } public List ClanShareExcludedTerritories { get; set; } public List StarterKitSeeded { get; set; } public List StarterKitChestSeeded { get; set; } public List StarterKitChestOptOut { get; set; } public bool AutoScoop { get; set; } public string AutoFilter { get; set; } public string NotifyMode { get; set; } public float Radius { get; set; } public string ScoopMode { get; set; } public List ScoopExcludes { get; set; } public Dictionary ScoopExcludeNames { get; set; } public Dictionary ScoopCaps { get; set; } public Dictionary ScoopCapNames { get; set; } public bool AppliedSgAllOn { get; set; } public bool RepeatHunt { get; set; } public List RepeatHuntOffPlots { get; set; } public int RepeatHuntMaxSuccess { get; set; } public Dictionary ItemAliases { get; set; } public Dictionary ItemAliasNames { get; set; } public SettingsRow() { SortStash = false; Pull = false; CraftPull = false; AutoStashMissions = false; Conveyor = false; ConveyorLoops = false; Salvage = false; UnitSpawner = false; Brazier = false; Named = false; SilentPull = false; SilentStash = false; Trash = false; RrGlobal = false; ClanShare = false; AppliedSgAllOn = false; RepeatHunt = false; RrGlobalAllow = true; DontPullLast = true; PullReserve = 10; ItemReserves = new Dictionary(); ItemReserveNames = new Dictionary(); ItemCaps = new Dictionary(); ItemCapNames = new Dictionary(); ItemGroups = new Dictionary>(); ItemGroupNames = new Dictionary>(); DeletedGroups = new List(); OverlaidGroups = new List(); PlotSalvage = new Dictionary(); HeartFeed = new Dictionary(); HeartFuelSeeded = new List(); HeartFuelOptOut = new List(); ClanShareByClan = new Dictionary(); ClanShareExcludedTerritories = new List(); RepeatHuntOffPlots = new List(); RepeatHuntMaxSuccess = 99; ItemAliases = new Dictionary(); ItemAliasNames = new Dictionary(); StarterKitSeeded = new List(); StarterKitChestSeeded = new List(); StarterKitChestOptOut = new List(); AutoScoop = true; AutoFilter = "all"; NotifyMode = "manual"; Radius = 10f; ScoopMode = "bags"; ScoopExcludes = new List(); ScoopExcludeNames = new Dictionary(); ScoopCaps = new Dictionary(); ScoopCapNames = new Dictionary(); } } internal static class StashRouting { public struct DepositRank : IComparable { public int Class; public int Spec; public bool Seeded; public bool Treasury; public bool Local; public string Label; public bool IsDepositUsable => Class <= 5; public int CompareTo(DepositRank other) { int num = Class.CompareTo(other.Class); if (num != 0) { return num; } num = other.Spec.CompareTo(Spec); if (num != 0) { return num; } num = other.Seeded.CompareTo(Seeded); if (num != 0) { return num; } num = other.Treasury.CompareTo(Treasury); if (num != 0) { return num; } return other.Local.CompareTo(Local); } } public struct SortRank : IComparable { public int Class; public int Spec; public bool Seeded; public bool UsableDest; public bool UsableSource; public string Label; public int CompareTo(SortRank other) { int num = Class.CompareTo(other.Class); if (num != 0) { return num; } num = other.Spec.CompareTo(Spec); if (num != 0) { return num; } return other.Seeded.CompareTo(Seeded); } public bool StrictlyBetterDestThan(SortRank source) { if (!UsableDest) { return false; } if (Class < source.Class) { return true; } if (Class == source.Class && Spec > source.Spec) { return true; } return false; } } private static readonly Regex NoShareToken = new Regex("\\bns\\b", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex SendRx = new Regex("s(\\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex ReceiveRx = new Regex("r(\\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); public const string LabelSkipNs = "skip-NS"; public const string LabelSkipQuotes = "skip-quotes"; public const string SkipSuffix = "''"; public const string LabelGeneric = "generic"; public const string LabelNameMatch = "name-match"; public const string LabelCategory = "category"; public const string LabelSender = "s#"; public const string LabelCustomLast = "custom-last"; public const string LabelOverflow = "overflow"; private static readonly HashSet AndCategoryTokens = new HashSet(StringComparer.OrdinalIgnoreCase) { "weapon", "armor", "armour", "material", "mineral" }; private static readonly Dictionary CategoryByToken = new Dictionary(StringComparer.OrdinalIgnoreCase) { ["weapon"] = (ItemCategory)1, ["armor"] = (ItemCategory)2, ["armour"] = (ItemCategory)2, ["gem"] = (ItemCategory)4, ["flower"] = (ItemCategory)16, ["lumber"] = (ItemCategory)32, ["stone"] = (ItemCategory)64, ["bloodessence"] = (ItemCategory)128, ["silver"] = (ItemCategory)1024, ["knowledge"] = (ItemCategory)4096, ["blood"] = (ItemCategory)8192, ["relic"] = (ItemCategory)16384, ["coin"] = (ItemCategory)32768, ["consumable"] = (ItemCategory)65536, ["herb"] = (ItemCategory)131072, ["bag"] = (ItemCategory)262144, ["saddle"] = (ItemCategory)524288, ["fish"] = (ItemCategory)1048576, ["jewel"] = (ItemCategory)8388608, ["alchemy"] = (ItemCategory)16777216, ["scroll"] = (ItemCategory)4096, ["scrolls"] = (ItemCategory)4096, ["paper"] = (ItemCategory)4096, ["book"] = (ItemCategory)4096, ["books"] = (ItemCategory)4096, ["tailoring"] = (ItemCategory)33554432, ["mineral"] = (ItemCategory)67108864, ["material"] = (ItemCategory)67108864, ["woodworking"] = (ItemCategory)134217728, ["magic"] = (ItemCategory)268435456, ["bloodpotion"] = (ItemCategory)536870912, ["soulshard"] = (ItemCategory)1073741824, ["soulshards"] = (ItemCategory)1073741824, ["shard"] = (ItemCategory)1073741824, ["shards"] = (ItemCategory)1073741824, ["bags"] = (ItemCategory)262144, ["saddles"] = (ItemCategory)524288, ["relics"] = (ItemCategory)16384 }; private static readonly Dictionary SpellingFold = BuildSpellingFold(); private static Dictionary> plotInvStash; private static DateTime plotInvStashAt; private static readonly HashSet loggedNs = new HashSet(); private static readonly HashSet loggedPicks = new HashSet(); public unsafe static string RawName(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!(stash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash) && stash.Has()) { NameableInteractable val = stash.Read(); return ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString() ?? ""; } } return ""; } public static string DestName(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) string text = RawName(stash); if (!string.IsNullOrWhiteSpace(text)) { return text; } try { if (!(stash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash) && stash.Has()) { string text2 = stash.Read().PrefabName(); if (string.IsNullOrEmpty(text2)) { return ""; } if (text2.IndexOf("GUID Not Found", StringComparison.OrdinalIgnoreCase) >= 0) { return ""; } return text2; } } return ""; } catch { return ""; } } public static bool IsSkipQuotesName(string name) { if (string.IsNullOrEmpty(name)) { return false; } return name.EndsWith("''", StringComparison.Ordinal); } public static string SkipLabel(string name) { if (!IsSkipQuotesName(name)) { return "skip-NS"; } return "skip-quotes"; } public static bool IsNoShareName(string name) { if (string.IsNullOrWhiteSpace(name)) { return false; } if (IsSkipQuotesName(name)) { return true; } return NoShareToken.IsMatch(name); } public static bool IsNoShare(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return IsNoShareName(RawName(stash)); } public static bool IsGenericName(string name) { if (string.IsNullOrWhiteSpace(name)) { return true; } string text = name.Trim(); if (text.Equals("Chest", StringComparison.OrdinalIgnoreCase) || text.Equals("Container", StringComparison.OrdinalIgnoreCase) || text.Equals("Empty", StringComparison.OrdinalIgnoreCase) || text.Equals("General", StringComparison.OrdinalIgnoreCase) || text.Equals("Misc", StringComparison.OrdinalIgnoreCase) || text.Equals("Miscellaneous", StringComparison.OrdinalIgnoreCase) || text.Equals("Everything", StringComparison.OrdinalIgnoreCase) || text.Equals("Everything Else", StringComparison.OrdinalIgnoreCase) || text.Equals("All", StringComparison.OrdinalIgnoreCase) || text.Equals("Other", StringComparison.OrdinalIgnoreCase) || text.Equals("Others", StringComparison.OrdinalIgnoreCase) || text.Equals("Extra", StringComparison.OrdinalIgnoreCase) || text.Equals("Dump", StringComparison.OrdinalIgnoreCase) || text.Equals("Stuff", StringComparison.OrdinalIgnoreCase)) { return true; } return false; } public static bool IsOverflowName(string name) { if (!string.IsNullOrEmpty(name)) { return name.IndexOf("overflow", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } public static bool IsSpecialName(string name) { if (string.IsNullOrEmpty(name)) { return false; } string text = name.ToLowerInvariant(); if (!text.Contains("salvage") && !text.Contains("spoils") && !text.Contains("brazier") && !text.Contains("spawner")) { return text.Contains("trash"); } return true; } public static bool IsSenderName(string name) { if (string.IsNullOrWhiteSpace(name)) { return false; } return SendRx.IsMatch(name.ToLowerInvariant()); } public static bool IsReceiverName(string name) { if (string.IsNullOrWhiteSpace(name)) { return false; } return ReceiveRx.IsMatch(name.ToLowerInvariant()); } public static bool IsConveyorName(string name) { if (!IsSenderName(name)) { return IsReceiverName(name); } return true; } public static bool IsTreasury(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ClanTreasuryShare.IsTreasuryLinked(stash); } public static string ItemLabel(PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) try { string text = item.PrefabName(); if (!string.IsNullOrEmpty(text) && text.IndexOf("GUID Not Found", StringComparison.OrdinalIgnoreCase) < 0) { return CleanItemName(text); } } catch { } if (ItemGroupService.IsGreaterBloodEssence(item)) { return "Greater Blood Essence"; } return ((PrefabGUID)(ref item)).GuidHash.ToString(); } private static string CleanItemName(string n) { if (string.IsNullOrEmpty(n)) { return ""; } int num = n.LastIndexOf(' '); if (num > 0 && int.TryParse(n.Substring(num + 1).TrimStart('-'), out var _)) { return n.Substring(0, num); } return n; } private static string Normalize(string s) { if (string.IsNullOrEmpty(s)) { return ""; } return s.Trim().ToLowerInvariant(); } private static Dictionary BuildSpellingFold() { string[][] obj = new string[12][] { new string[4] { "fiber", "fibre", "fibers", "fibres" }, new string[4] { "sulfur", "sulphur", "sulfurs", "sulphurs" }, new string[4] { "armor", "armour", "armors", "armours" }, new string[4] { "gray", "grey", "grays", "greys" }, new string[4] { "plow", "plough", "plows", "ploughs" }, new string[4] { "defense", "defence", "defenses", "defences" }, new string[2] { "aluminum", "aluminium" }, new string[4] { "mold", "mould", "molds", "moulds" }, new string[4] { "traveler", "traveller", "travelers", "travellers" }, new string[4] { "artifact", "artefact", "artifacts", "artefacts" }, new string[2] { "woolen", "woollen" }, new string[2] { "jewelry", "jewellery" } }; Dictionary dictionary = new Dictionary(StringComparer.Ordinal); string[][] array = obj; foreach (string[] array2 in array) { string[] array3 = array2; foreach (string key in array3) { dictionary[key] = array2; } } return dictionary; } private static bool IsDestClassToken(string token) { if (string.IsNullOrEmpty(token)) { return false; } string text = token.Trim().ToLowerInvariant(); switch (text) { default: return text == "storage"; case "overflow": case "spoils": case "spoil": case "salvage": case "trash": return true; } } public static bool IsOverflowDestName(string name) { if (string.IsNullOrEmpty(name)) { return false; } string text = name.ToLowerInvariant(); if (!text.Contains("overflow") && !text.Contains("spoils") && !text.Contains("salvage")) { return text.Contains("trash"); } return true; } public static bool NamedSinkShouldStay(Entity stash, PrefabGUID item, ulong ownerId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) string text = DestName(stash); if (string.IsNullOrWhiteSpace(text) || IsOverflowDestName(text) || IsNoShareName(RawName(stash))) { return false; } if (((PrefabGUID)(ref item)).GuidHash == 0) { return false; } if (ExactItemNameMatch(text, item, out var specificity)) { return true; } if (CategoryMatch(text, item, ownerId, out specificity)) { return true; } return false; } private static List TokenVariants(string token) { HashSet hashSet = new HashSet(StringComparer.Ordinal); string text = (string.IsNullOrEmpty(token) ? "" : token.Trim().ToLowerInvariant()); if (text.Length == 0) { return new List(); } hashSet.Add(text); if (SpellingFold.TryGetValue(text, out var value)) { string[] array = value; foreach (string item in array) { hashSet.Add(item); } } if (text.Length >= 4 && text.EndsWith("ies")) { string text2 = text.Substring(0, text.Length - 3) + "y"; if (text2.Length >= 3) { hashSet.Add(text2); } } if (text.Length >= 4 && text.EndsWith("s") && !text.EndsWith("ss")) { string text3 = text.Substring(0, text.Length - 1); if (text3.Length >= 3) { hashSet.Add(text3); } } if (!text.EndsWith("s")) { hashSet.Add(text + "s"); if (text.Length >= 3 && text.EndsWith("y")) { char c = text[text.Length - 2]; if (c != 'a' && c != 'e' && c != 'i' && c != 'o' && c != 'u') { hashSet.Add(text.Substring(0, text.Length - 1) + "ies"); } } } return new List(hashSet); } private static bool VariantsOverlap(string a, string b) { List list = TokenVariants(a); List list2 = TokenVariants(b); foreach (string item in list) { foreach (string item2 in list2) { if (item == item2) { return true; } } } return false; } private static string StripConveyorFromToken(string token) { if (string.IsNullOrWhiteSpace(token)) { return ""; } string input = token.Trim().ToLowerInvariant(); input = SendRx.Replace(input, ""); input = ReceiveRx.Replace(input, ""); return input.Trim(' ', '-', '_', '/', '|', '.', ':'); } private static string RemainingNameText(string chestName) { if (string.IsNullOrWhiteSpace(chestName)) { return ""; } List list = new List(); string[] array = chestName.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text = StripConveyorFromToken(array[i]); if (text.Length != 0) { switch (text) { case "overflow": case "spoils": case "spoil": case "salvage": case "trash": case "storage": continue; } list.Add(text); } } return string.Join(" ", list); } private static List RemainingNameTokens(string chestName) { string text = RemainingNameText(chestName); if (text.Length == 0) { return new List(); } return new List(text.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries)); } private static List> ParseAndOrClauses(string remaining) { List> list = new List>(); if (string.IsNullOrWhiteSpace(remaining)) { return list; } string[] array = remaining.Split('+'); foreach (string obj in array) { List list2 = new List(); string[] array2 = obj.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < array2.Length; j++) { string text = array2[j].Trim().Trim('-', '_', '/', '|', '.', ':'); if (text.Length != 0) { list2.Add(text); } } if (list2.Count > 0) { list.Add(list2); } } return list; } private static bool TryGetItemCategory(PrefabGUID item, out ItemCategory cat) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected I8, but got Unknown cat = (ItemCategory)0; if (((PrefabGUID)(ref item)).GuidHash == 0) { return false; } try { if (Core.PrefabCollectionSystem == null) { return false; } PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity val = default(Entity); if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(item, ref val)) { return false; } if (val == Entity.Null || !val.Has()) { return false; } cat = (ItemCategory)(long)val.Read().ItemCategory; return true; } catch { return false; } } private static bool TokenIsAndCategory(string token) { foreach (string item in TokenVariants(token)) { if (AndCategoryTokens.Contains(item)) { return true; } } return false; } private static bool IsSmallMaterialsTokens(List tokens) { if (tokens == null || tokens.Count == 0) { return false; } bool flag = false; bool flag2 = false; foreach (string token in tokens) { foreach (string item in TokenVariants(token)) { if (item == "small") { flag = true; } if (item == "material" || item == "mineral") { flag2 = true; } } } return flag && flag2; } private static bool TokenMatchesItem(string token, PrefabGUID item, string itemName, ItemCategory itemCat, ulong ownerId, bool allowCategory) { //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(token)) { return false; } if (IsDestClassToken(token)) { return false; } if (ItemGroupService.TryExactEssenceAlias(token, out var hash)) { return ((PrefabGUID)(ref item)).GuidHash == hash; } List list = TokenVariants(token); bool flag = false; foreach (string item3 in list) { if (!ItemGroupService.TryGetBuiltInCanonical(item3, out var canonical)) { continue; } flag = true; if (ItemGroupService.IsDeletedBuiltIn(ownerId, canonical)) { continue; } foreach (ItemGroupService.GroupMember item4 in ItemGroupService.ResolveMembers(ownerId, canonical)) { if (item4.GuidHash == ((PrefabGUID)(ref item)).GuidHash) { return true; } } if (!(canonical == "wood")) { continue; } foreach (ItemGroupService.GroupMember item5 in ItemGroupService.ResolveMembers(ownerId, "planks")) { if (item5.GuidHash == ((PrefabGUID)(ref item)).GuidHash) { return true; } } } if (flag) { return false; } foreach (var item6 in Core.PlayerSettings.ListCustomGroups(ownerId)) { string item2 = item6.name; if (string.IsNullOrEmpty(item2)) { continue; } string text = ItemGroupService.NormalizeName(item2); if (text.Length < 3 || !VariantsOverlap(token, text)) { continue; } foreach (ItemGroupService.GroupMember item7 in ItemGroupService.ResolveMembers(ownerId, item2)) { if (item7.GuidHash == ((PrefabGUID)(ref item)).GuidHash) { return true; } } } if (allowCategory && (int)itemCat != 0) { foreach (string item8 in list) { switch (item8) { case "wood": case "woods": case "wooden": if ((itemCat & 0x20) != 0 || (itemCat & 0x8000000) != 0) { return true; } break; } if (CategoryByToken.TryGetValue(item8, out var value) && (int)value != 0 && (itemCat & value) != 0) { return true; } } } string[] array = (string.IsNullOrEmpty(itemName) ? Array.Empty() : itemName.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries)); foreach (string item9 in list) { if (item9.Length >= 3 && !string.IsNullOrEmpty(itemName) && itemName.IndexOf(item9, StringComparison.Ordinal) >= 0) { return true; } string[] array2 = array; foreach (string b in array2) { if (VariantsOverlap(item9, b)) { return true; } } } return false; } public static bool ExactItemNameMatch(string chestName, PrefabGUID item, out int specificity) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) specificity = 0; if (string.IsNullOrWhiteSpace(chestName) || IsGenericName(chestName)) { return false; } string text = Normalize(ItemLabel(item)); if (text.Length < 3) { return false; } string text2 = RemainingNameText(chestName); if (text2.Length == 0) { return false; } if (text2.IndexOf('+') >= 0) { return false; } List list = RemainingNameTokens(chestName); if (list.Count == 0) { return false; } if (ItemGroupService.TryExactEssenceAlias(text2, out var hash) || (list.Count == 1 && ItemGroupService.TryExactEssenceAlias(list[0], out hash))) { if (((PrefabGUID)(ref item)).GuidHash == hash) { specificity = 22; return true; } return false; } if (text2.IndexOf(text, StringComparison.Ordinal) >= 0) { specificity = text.Length; return true; } string text3 = text.Replace(" ", ""); string text4 = text2.Replace(" ", ""); if (text3.Length >= 3 && text4.IndexOf(text3, StringComparison.Ordinal) >= 0) { specificity = text3.Length; return true; } string[] array = text.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries); if (list.Count == 1 && array.Length == 2 && array[0] == "blood" && array[1] == "essence" && VariantsOverlap(list[0], "blood")) { specificity = text.Length + 20; return true; } if (list.Count == array.Length) { bool flag = true; int num = 0; for (int i = 0; i < list.Count; i++) { if (!VariantsOverlap(list[i], array[i])) { flag = false; break; } num += array[i].Length; } if (flag) { specificity = ((num > 0) ? num : text.Length); return true; } } if (array.Length != 0 && list.Count > 0) { bool flag2 = true; string[] array2 = array; foreach (string b in array2) { bool flag3 = false; foreach (string item2 in list) { if (!IsDestClassToken(item2) && VariantsOverlap(item2, b)) { flag3 = true; break; } } if (!flag3) { flag2 = false; break; } } if (flag2) { specificity = text.Length; return true; } } return false; } public static bool CategoryMatch(string chestName, PrefabGUID item, ulong ownerPlatformId, out int specificity) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) specificity = 0; if (string.IsNullOrWhiteSpace(chestName) || IsGenericName(chestName)) { return false; } if (ExactItemNameMatch(chestName, item, out var _)) { return false; } string text = RemainingNameText(chestName); if (text.Length == 0) { return false; } string text2 = Normalize(ItemLabel(item)); TryGetItemCategory(item, out var cat); List list = RemainingNameTokens(chestName); if (IsSmallMaterialsTokens(list)) { if ((cat & 1) != 0) { return false; } if ((cat & 0x4000000) == 0) { return false; } if (string.IsNullOrEmpty(text2) || text2.IndexOf("small", StringComparison.Ordinal) < 0) { return false; } int num = 0; foreach (string item2 in list) { num += item2.Length; } specificity = list.Count * 1000 + num; return true; } bool flag = text.IndexOf('+') >= 0; List> list2 = ParseAndOrClauses(text); if (list2.Count == 0) { return false; } if (flag) { int num2 = 0; foreach (List item3 in list2) { bool flag2 = false; int num3 = 0; foreach (string item4 in item3) { if (TokenMatchesItem(item4, item, text2, cat, ownerPlatformId, allowCategory: true)) { flag2 = true; num3 += item4.Length; } } if (!flag2) { return false; } num2 += num3; } specificity = list2.Count * 1000 + num2; return true; } List list3 = list2[0]; bool flag3 = false; foreach (string item5 in list3) { if (TokenIsAndCategory(item5)) { flag3 = true; break; } } if (flag3) { int num4 = 0; foreach (string item6 in list3) { if (!TokenMatchesItem(item6, item, text2, cat, ownerPlatformId, allowCategory: true)) { return false; } num4 += item6.Length; } specificity = list3.Count * 1000 + num4; return true; } int num5 = 0; int num6 = 0; foreach (string item7 in list3) { if (TokenMatchesItem(item7, item, text2, cat, ownerPlatformId, allowCategory: true)) { num5++; num6 += item7.Length; } } if (num5 == 0) { return false; } specificity = num5 * 1000 + num6; return true; } public static bool IsUnnamedOrGeneric(string name) { if (IsOverflowDestName(name)) { return false; } if (IsGenericName(name)) { return true; } if (IsFurnitureChestName(name)) { return true; } return string.IsNullOrEmpty(RemainingNameText(name)); } private static bool IsFurnitureChestName(string name) { if (string.IsNullOrWhiteSpace(name) || IsOverflowDestName(name)) { return false; } List list = RemainingNameTokens(name); if (list.Count == 0) { return true; } bool result = false; using List.Enumerator enumerator = list.GetEnumerator(); while (enumerator.MoveNext()) { switch (enumerator.Current.Trim().ToLowerInvariant()) { case "chest": case "container": case "stash": case "inventory": result = true; break; default: return false; case "storage": case "small": case "large": case "medium": case "tiny": case "big": case "the": case "of": case "a": case "an": case "and": break; } } return result; } internal static bool IsUnnamedDest(string plate, string destName) { if (IsOverflowDestName(plate) || IsOverflowDestName(destName)) { return false; } if (string.IsNullOrWhiteSpace(plate)) { return true; } if (!IsUnnamedOrGeneric(plate)) { return IsUnnamedOrGeneric(destName); } return true; } internal static string SelfTestDest() { bool flag = IsUnnamedDest("", "Jewel Storage"); bool flag2 = IsUnnamedDest("", ""); bool flag3 = IsUnnamedDest("", "Small Chest"); bool flag4 = IsUnnamedDest("Leather", "Leather"); bool flag5 = IsUnnamedDest("", "overflow"); bool flag6 = IsUnnamedDest("jewels", "Jewel Storage"); string text = RankMatchName("", "Jewel Storage"); string text2 = RankMatchName("", "Small Chest"); string text3 = RankMatchName("", "Bureau"); string text4 = RankMatchName("jewels", "Jewel Storage"); bool flag7 = text == "Jewel Storage" && text2.Length == 0 && text3.Length == 0 && text4 == "Jewel Storage"; bool flag8 = IsGenericName("Empty") && IsUnnamedDest("Empty", "Jewel Storage"); int num = RankClassUnmatched("", "Jewel Storage", hasItem: false); int num2 = RankClassUnmatched("Empty", "Jewel Storage", hasItem: false); int num3 = RankClassUnmatched("Leather", "Leather", hasItem: false); bool flag9 = num == 3 && num2 == 3 && num3 == 6; int num4 = RankClassUnmatched("General", "Jewel Storage", hasItem: false); int num5 = RankClassUnmatched("Everything Else", "Jewel Storage", hasItem: false); bool flag10 = IsGenericName("General") && IsGenericName("Everything Else") && num4 == 3 && num5 == 3; int num6 = SourcePassFromName("", conveyor: false); int num7 = SourcePassFromName("Leather", conveyor: false); int num8 = SourcePassFromName("Planks R0S0", conveyor: true); int num9 = SourcePassFromName("Ore & Ingots", conveyor: false); int num10 = SourcePassFromName("Spoils Overflow", conveyor: false); bool flag11 = num6 == 0 && num7 == 1 && num8 == 2 && num9 == 1 && num10 == 0; bool flag12 = IsConveyorName("Planks R0S0") && !IsConveyorName("Ore & Ingots") && !IsConveyorName("General"); bool flag13 = flag && flag2 && flag3 && !flag4 && !flag5 && !flag6 && flag7 && flag8 && flag9 && flag10 && flag11 && flag12; return "{\"blankJewel\":" + (flag ? "true" : "false") + ",\"blankEmpty\":" + (flag2 ? "true" : "false") + ",\"blankFurniture\":" + (flag3 ? "true" : "false") + ",\"namedLeather\":" + (flag4 ? "true" : "false") + ",\"overflow\":" + (flag5 ? "true" : "false") + ",\"namedJewel\":" + (flag6 ? "true" : "false") + ",\"blankMatchJewel\":" + ((text == "Jewel Storage") ? "true" : "false") + ",\"blankChestGeneric\":" + ((text2.Length == 0) ? "true" : "false") + ",\"blankBureauGeneric\":" + ((text3.Length == 0) ? "true" : "false") + ",\"namedMatchJewel\":" + ((text4 == "Jewel Storage") ? "true" : "false") + ",\"emptyGeneric\":" + (flag8 ? "true" : "false") + ",\"blankClass\":" + num + ",\"emptyClass\":" + num2 + ",\"leatherClass\":" + num3 + ",\"generalClass\":" + num4 + ",\"elseClass\":" + num5 + ",\"passBlank\":" + num6 + ",\"passLeather\":" + num7 + ",\"passBelt\":" + num8 + ",\"passOre\":" + num9 + ",\"passOverflow\":" + num10 + ",\"beltNotDest\":" + (flag12 ? "true" : "false") + ",\"ok\":" + (flag13 ? "true" : "false") + "}"; } internal static int RankClassUnmatched(string plate, string destName, bool hasItem) { if (IsOverflowDestName(plate) || IsOverflowDestName(destName)) { return 5; } if (IsUnnamedDest(plate, destName)) { return 3; } if (!hasItem) { return 6; } return 4; } internal static string RankMatchName(string plate, string destName) { if (!string.IsNullOrWhiteSpace(plate)) { return destName ?? ""; } if (string.IsNullOrWhiteSpace(destName) || PrefabNameIsGenericDest(destName)) { return ""; } return destName; } private static bool PrefabNameIsGenericDest(string destName) { if (IsGenericName(destName) || IsOverflowDestName(destName) || IsFurnitureChestName(destName)) { return true; } List list = RemainingNameTokens(destName); if (list.Count == 0) { return true; } using (List.Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { switch (enumerator.Current.Trim().ToLowerInvariant()) { case "chest": case "container": case "stash": case "inventory": case "storage": case "cabinet": case "bureau": case "wardrobe": case "cupboard": case "locker": case "crate": case "trunk": case "small": case "large": case "medium": case "tiny": case "big": case "the": case "of": case "a": case "an": case "and": continue; } return false; } } return true; } public static DepositRank RankDeposit(Entity stash, PrefabGUID item, ulong ownerId, bool hasItem, int standingPlot = -1) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) string text = RawName(stash); string text2 = DestName(stash); string text3 = text2; string chestName = RankMatchName(text, text2); bool local = standingPlot >= 0 && Core.TerritoryService.GetTerritoryId(stash) == standingPlot; DepositRank result = new DepositRank { Class = 99, Label = SkipLabel(text), Seeded = hasItem, Treasury = IsTreasury(stash), Local = local }; if (IsNoShareName(text)) { return result; } bool flag = IsOverflowDestName(text3) || IsOverflowDestName(text); if ((IsSpecialName(text) || (!string.IsNullOrWhiteSpace(text) && IsSpecialName(text3))) && !flag) { result.Class = 90; result.Label = "custom-last"; return result; } int specificity = 0; int specificity2 = 0; bool flag2 = !flag && ((PrefabGUID)(ref item)).GuidHash != 0 && ExactItemNameMatch(chestName, item, out specificity); bool flag3 = !flag && !flag2 && ((PrefabGUID)(ref item)).GuidHash != 0 && CategoryMatch(chestName, item, ownerId, out specificity2); bool flag4 = !flag && IsUnnamedDest(text, text3); if (!flag && IsSenderName(text) && hasItem && (flag4 || flag2 || flag3)) { result.Class = 0; result.Spec = (flag2 ? (specificity + 20000) : (flag3 ? (specificity2 + 10000) : 0)); result.Label = "s#"; return result; } if (flag2) { result.Class = 1; result.Spec = specificity; result.Label = "name-match"; return result; } if (flag3) { result.Class = 2; result.Spec = specificity2; result.Label = "category"; return result; } switch (result.Class = RankClassUnmatched(text, text2, hasItem)) { case 3: result.Spec = (result.Treasury ? 1 : 0); result.Label = "generic"; return result; case 5: result.Label = "overflow"; return result; default: result.Label = "custom-last"; return result; } } public static SortRank RankSort(Entity stash, PrefabGUID item, ulong ownerId, bool hasItem) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) string text = RawName(stash); string destName = DestName(stash); string chestName = RankMatchName(text, destName); SortRank result = new SortRank { Class = 9, Label = SkipLabel(text), Seeded = hasItem }; if (IsNoShareName(text)) { return result; } if (IsConveyorName(text) || IsSpecialName(text) || IsOverflowDestName(text)) { result.Class = 8; result.UsableSource = false; result.UsableDest = false; result.Label = (IsOverflowDestName(text) ? "overflow" : (IsConveyorName(text) ? "s#" : "custom-last")); return result; } if (((PrefabGUID)(ref item)).GuidHash != 0 && ExactItemNameMatch(chestName, item, out var specificity)) { result.Class = 0; result.Spec = specificity; result.UsableDest = true; result.UsableSource = true; result.Label = "name-match"; return result; } if (((PrefabGUID)(ref item)).GuidHash != 0 && CategoryMatch(chestName, item, ownerId, out var specificity2)) { result.Class = 1; result.Spec = specificity2; result.UsableDest = true; result.UsableSource = true; result.Label = "category"; return result; } result.Class = 3; result.UsableDest = false; result.UsableSource = true; result.Label = ((string.IsNullOrWhiteSpace(text) || IsGenericName(text)) ? "generic" : "custom-last"); return result; } internal static int SourcePassFromName(string plate, bool conveyor) { if (IsNoShareName(plate)) { return -1; } if (conveyor) { return 2; } if (string.IsNullOrWhiteSpace(plate) || IsGenericName(plate) || IsUnnamedOrGeneric(plate) || IsOverflowDestName(plate)) { return 0; } return 1; } public static int SourcePass(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) string text = RawName(stash); return SourcePassFromName(text, IsConveyorName(text)); } public static bool TryGetExternalInventory(Entity stash, out Entity inventory) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) inventory = Entity.Null; if (!(stash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash)) { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val = default(DynamicBuffer); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer(stash, ref val)) { return false; } Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity entity = enumerator.Current.Entity; if (entity == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity) && entity.Has()) { PrefabGUID val2 = entity.Read(); if (((PrefabGUID)(ref val2)).Equals(StashService.ChestBagGuid)) { inventory = entity; return true; } } } return false; } } return false; } public static bool InventoryHasItem(Entity inventory, PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!(inventory == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inventory) && ((PrefabGUID)(ref item)).GuidHash != 0) { ServerGameManager serverGameManager = Core.ServerGameManager; return ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, item) > 0; } } return false; } public static List<(Entity stash, Entity inventory)> OrderDepositDests(List<(Entity stash, Entity inventory)> candidates, PrefabGUID item, ulong ownerId, int standingPlot = -1) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) List<(DepositRank, Entity, Entity)> list = new List<(DepositRank, Entity, Entity)>(); foreach (var (val, val2) in candidates) { if (val == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(val) || val2 == Entity.Null) { continue; } entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val2)) { bool hasItem = InventoryHasItem(val2, item); DepositRank item2 = RankDeposit(val, item, ownerId, hasItem, standingPlot); if (item2.IsDepositUsable) { list.Add((item2, val, val2)); } } } list.Sort(((DepositRank rank, Entity stash, Entity inventory) a, (DepositRank rank, Entity stash, Entity inventory) b) => a.rank.CompareTo(b.rank)); List<(Entity, Entity)> list2 = new List<(Entity, Entity)>(list.Count); foreach (var item3 in list) { list2.Add((item3.Item2, item3.Item3)); } return list2; } internal static void InvalidatePlotStashMap() { plotInvStash = null; plotInvStashAt = DateTime.MinValue; } private static Dictionary InvToStash(int plot) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) DateTime utcNow = DateTime.UtcNow; if (plotInvStash == null || (utcNow - plotInvStashAt).TotalSeconds >= 0.25) { plotInvStash = new Dictionary>(); plotInvStashAt = utcNow; } if (plotInvStash.TryGetValue(plot, out var value)) { return value; } Dictionary dictionary = new Dictionary(); foreach (Entity item in Core.Stash.ChestsOnPlot(plot)) { if (item == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(item) && TryGetExternalInventory(item, out var inventory) && !(inventory == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(inventory)) { dictionary[inventory] = item; } } } plotInvStash[plot] = dictionary; return dictionary; } public static List OrderDepositInventories(int plot, List destInvs, PrefabGUID item, int maxClass = 5) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (destInvs == null || destInvs.Count == 0) { return list; } Core.TerritoryService.TryGetTerritoryOwnerPlatformId(plot, out var platformId); Dictionary dictionary = InvToStash(plot); List<(DepositRank, Entity)> list2 = new List<(DepositRank, Entity)>(); foreach (Entity destInv in destInvs) { if (destInv == Entity.Null) { continue; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(destInv)) { continue; } if (!dictionary.TryGetValue(destInv, out var value)) { value = Entity.Null; } if (!(value == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(value)) { string text = RawName(value); if (!IsConveyorName(text)) { if (IsNoShareName(text) && loggedNs.Add(plot + ":" + text)) { LogDestPick(SkipLabel(text), plot, item, text, "deposit-filter"); } bool hasItem = InventoryHasItem(destInv, item); DepositRank item2 = RankDeposit(value, item, platformId, hasItem, plot); if (item2.IsDepositUsable && item2.Class <= maxClass) { list2.Add((item2, destInv)); } } continue; } } DepositRank item3 = new DepositRank { Class = 3, Label = "generic", Local = true }; if (item3.IsDepositUsable && item3.Class <= maxClass) { list2.Add((item3, destInv)); } } list2.Sort(((DepositRank rank, Entity inv) a, (DepositRank rank, Entity inv) b) => a.rank.CompareTo(b.rank)); foreach (var item4 in list2) { list.Add(item4.Item2); } return list; } public static List SenderGroups(string name) { List list = new List(); if (string.IsNullOrWhiteSpace(name)) { return list; } foreach (Match item in SendRx.Matches(name.ToLowerInvariant())) { if (int.TryParse(item.Groups[1].Value, out var result) && !list.Contains(result)) { list.Add(result); } } return list; } public static List PredictBeltReceivers(Entity destStash) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (!(destStash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(destStash)) { List list2 = SenderGroups(RawName(destStash)); if (list2.Count == 0) { return list; } int territoryId = Core.TerritoryService.GetTerritoryId(destStash); IReadOnlyList readOnlyList = Array.Empty(); try { readOnlyList = Core.TerritoryService.GetLogisticsTerritoryIds(territoryId); } catch { } if (readOnlyList == null || readOnlyList.Count == 0) { readOnlyList = new int[1] { territoryId }; } HashSet hashSet = new HashSet(); { foreach (int item2 in readOnlyList) { foreach (var item3 in Core.Stash.ReceiveChests(item2)) { var (item, val) = item3; if (list2.Contains(item) && !((Entity)(ref val)).Equals(destStash) && hashSet.Add(val)) { string text = RawName(val); if (!string.IsNullOrWhiteSpace(text)) { list.Add(text); } } } } return list; } } } return list; } public static string FormatBeltTo(Entity destStash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) string name = RawName(destStash); if (!IsSenderName(name)) { return null; } List list = SenderGroups(name); List list2 = PredictBeltReceivers(destStash); if (list2.Count == 0) { if (list.Count == 0) { return "r# with no receiver found"; } List list3 = new List(list.Count); foreach (int item in list) { list3.Add("r" + item); } return string.Join("/", list3) + " with no receiver found"; } return string.Join(", ", list2); } public static Entity PredictNextBeltDest(Entity destStash, PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) string name = RawName(destStash); if (!IsSenderName(name)) { return Entity.Null; } List list = SenderGroups(name); if (list.Count == 0) { return Entity.Null; } int territoryId = Core.TerritoryService.GetTerritoryId(destStash); Core.TerritoryService.TryGetTerritoryOwnerPlatformId(territoryId, out var platformId); IReadOnlyList readOnlyList = Array.Empty(); try { readOnlyList = Core.TerritoryService.GetLogisticsTerritoryIds(territoryId); } catch { } if (readOnlyList == null || readOnlyList.Count == 0) { readOnlyList = new int[1] { territoryId }; } List<(Entity, Entity)> list2 = new List<(Entity, Entity)>(); HashSet hashSet = new HashSet(); foreach (int item3 in readOnlyList) { foreach (var item4 in Core.Stash.ReceiveChests(item3)) { var (item2, val) = item4; if (list.Contains(item2) && !((Entity)(ref val)).Equals(destStash) && hashSet.Add(val) && !IsNoShareName(RawName(val)) && TryGetExternalInventory(val, out var inventory)) { list2.Add((val, inventory)); } } } if (list2.Count == 0) { return Entity.Null; } List<(Entity, Entity)> list3 = OrderDepositDests(list2, item, platformId, territoryId); if (list3.Count == 0) { return Entity.Null; } (Entity, Entity) tuple2 = list3[0]; TryGetExternalInventory(destStash, out var inventory2); bool hasItem = InventoryHasItem(inventory2, item); DepositRank depositRank = RankDeposit(destStash, item, platformId, hasItem); bool hasItem2 = InventoryHasItem(tuple2.Item2, item); DepositRank other = RankDeposit(tuple2.Item1, item, platformId, hasItem2); if (NamedSinkShouldStay(destStash, item, platformId)) { return Entity.Null; } if (IsOverflowDestName(RawName(tuple2.Item1))) { return Entity.Null; } if (depositRank.CompareTo(other) <= 0) { return Entity.Null; } return tuple2.Item1; } public static string FormatBeltChat(Entity destStash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return FormatBeltChat(destStash, default(PrefabGUID)); } public static string FormatBeltChat(Entity destStash, PrefabGUID item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Entity val = PredictNextBeltDest(destStash, item); if (val == Entity.Null) { return ""; } if (IsOverflowDestName(RawName(val))) { return ""; } string text = RawName(val); if (string.IsNullOrWhiteSpace(text)) { return ""; } return "; will be belted to " + text; } public static void LogDestPick(string label, int plot, PrefabGUID item, string chestName, string via, string beltTo = null) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) string item2 = via + ":" + plot + ":" + ((PrefabGUID)(ref item)).GuidHash + ":" + label; if (loggedPicks.Add(item2)) { string text = (string.IsNullOrEmpty(beltTo) ? "" : (" belt-to=" + beltTo)); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Satisvampory] dest-pick "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(label); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" via="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(via); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" plot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(plot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" item="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ItemLabel(item)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" chest="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(chestName); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); } log.LogInfo(val); } } public static void LogDestPickAlways(string label, int plot, PrefabGUID item, string chestName, string via, string beltTo = null) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) string text = (string.IsNullOrEmpty(beltTo) ? "" : (" belt-to=" + beltTo)); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Satisvampory] dest-pick "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(label); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" via="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(via); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" plot="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(plot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" item="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ItemLabel(item)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" chest="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(chestName); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); } log.LogInfo(val); } public static void LogBeltTo(Entity destStash, PrefabGUID item, int plot, string via) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) string text = RawName(destStash); if (!IsSenderName(text)) { return; } Entity val = PredictNextBeltDest(destStash, item); string text2 = ((val == Entity.Null) ? "stays" : RawName(val)); string item2 = via + ":belt:" + plot + ":" + ((PrefabGUID)(ref item)).GuidHash + ":" + text; if (loggedPicks.Add(item2)) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(58, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Satisvampory] dest-pick "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("s#"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" via="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(via); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" plot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(plot); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" item="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ItemLabel(item)); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" chest="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" belt-to="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text2); } log.LogInfo(val2); } } } internal class StashService { public const string SpoilsLabel = "spoils"; public static readonly PrefabGUID ChestBagGuid = new PrefabGUID(1183666186); private readonly Regex receiveRx; private readonly Regex sendRx; private readonly ChestIndex chests; private readonly FindSpotlight spotlight = new FindSpotlight(); private readonly FindReport finder; private const float StashCooldown = 1f; private readonly Dictionary lastStashed = new Dictionary(); public Regex ReceiveToken => receiveRx; public Regex SendToken => sendRx; public StashService() { receiveRx = new Regex("r(\\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); sendRx = new Regex("s(\\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); chests = new ChestIndex(sendRx, receiveRx); finder = new FindReport(spotlight); } internal void InvalidateTerritory(int territoryId) { chests.Forget(territoryId); } internal void InvalidateAllStashLists() { chests.ForgetAll(); } public unsafe bool HasBeltToken(Entity stash) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!(stash == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(stash) && stash.Has()) { NameableInteractable val = stash.Read(); string text = ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString().ToLower(); if (!string.IsNullOrWhiteSpace(text)) { if (!sendRx.IsMatch(text)) { return receiveRx.IsMatch(text); } return true; } return false; } } return false; } public IEnumerable IslandChests(Entity character) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) foreach (int item in Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(character)) { Entity castleHeart = Core.TerritoryService.GetCastleHeart(item); if (castleHeart == Entity.Null) { continue; } ServerGameManager serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).IsAllies(castleHeart, character) || TerritoryService.IsHeartRaided(castleHeart)) { continue; } foreach (Entity item2 in ChestsOnPlot(item)) { yield return item2; } } } public IEnumerable IslandPlotIds(int standingTerritoryId) { return Core.TerritoryService.GetLogisticsTerritoryIds(standingTerritoryId); } public IEnumerable ChestsOnPlot(int territoryIndex) { return chests.OnPlot(territoryIndex); } public IEnumerable<(int group, Entity station)> ReceiveChests(int territoryId) { return chests.Receivers(territoryId); } public IEnumerable<(int group, Entity station)> SendChests(int territoryId) { return chests.Senders(territoryId); } public IEnumerable SalvageChests(int territoryId) { return chests.Named(territoryId, "salvage"); } public IEnumerable SpawnerChests(int territoryId) { return chests.Named(territoryId, "spawner"); } public IEnumerable BrazierChests(int territoryId) { return chests.Named(territoryId, "brazier"); } public IEnumerable OverflowChests(int territoryId) { return chests.Named(territoryId, "overflow"); } public IEnumerable TrashChests(int territoryId) { return chests.Named(territoryId, "trash"); } public void StashCharacterInventory(Entity charEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) try { DepositNow(charEntity); } catch (Exception e) { Core.LogException(e, "Stash Character Inventory"); } } private void DepositNow(Entity charEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (charEntity == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(charEntity) || !charEntity.Has()) { return; } User user = charEntity.Read().UserEntity.Read(); PlayerActionGate.Context ctx; string deny; if (lastStashed.TryGetValue(charEntity, out var value) && Core.ServerTime - value < 1.0) { Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Wait a moment before stashing again."); } else if (!PlayerActionGate.TryOpenForStash(charEntity, out ctx, out deny)) { if (ctx.UserEntity != Entity.Null) { PlayerActionGate.Deny(ctx.User, deny); } } else { lastStashed[charEntity] = Core.ServerTime; PlayerDeposit.FromCharacter(charEntity, ctx); } } public void AdminStash(Entity charEntity, PrefabGUID itemType, int amountToGive) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) AdminGive.IntoPlot(charEntity, itemType, amountToGive); } public void ReportWhereItemIsLocated(Entity charEntity, PrefabGUID item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) finder.Items(charEntity, item); } public void ReportWhereChestIsLocated(Entity charEntity, string chestName) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) finder.Chests(charEntity, chestName); } internal void ShowItems(Entity character, PrefabGUID item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) finder.Items(character, item); } internal void ShowChests(Entity character, string name) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) finder.Chests(character, name); } public int StashServantLoot(Entity servant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ServantLoot.Deposit(servant); } internal string DebugListServants(int plotFilter) { return ServantLoot.List(plotFilter); } internal string DebugStashAllServants(int plotFilter) { return ServantLoot.StashAll(plotFilter); } } internal class TerritoryService { private readonly Dictionary> plotsByRegion = new Dictionary>(); private readonly Dictionary heartByPlot = new Dictionary(); private readonly HashSet rebuilding = new HashSet(); private readonly Dictionary entityPlot = new Dictionary(); private readonly Dictionary> clanPlotCache = new Dictionary>(); private readonly Dictionary clanPlotCacheAt = new Dictionary(); private DateTime clanStandingAt; private readonly Dictionary clanStanding = new Dictionary(); private readonly List> territoryUpdateCallbacks = new List>(); private readonly float timeBudget; private double sliceStart; private EntityQuery connectedUsers; private bool connectedUsersReady; public const int MIN_TERRITORY_ID = 0; public const int MAX_TERRITORY_ID = 146; internal IReadOnlyList> UpdateCallbacks => territoryUpdateCallbacks; public TerritoryService() { ScanPlots(); ScanHearts(); int serverFps = SettingsManager.ServerHostSettings.ServerFps; timeBudget = 1f / (float)serverFps * 0.15f; } public void RegisterTerritoryUpdateCallback(Func callback) { territoryUpdateCallbacks.Add(callback); } internal bool IsTerritoryRebuilding(int territoryId) { return rebuilding.Contains(territoryId); } internal void StartTimer() { sliceStart = Time.realtimeSinceStartup; } internal bool ShouldUpdateYield() { return (double)Time.realtimeSinceStartup - sliceStart > (double)timeBudget; } public Entity GetCastleHeart(int territoryId) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!heartByPlot.TryGetValue(territoryId, out var value) || !HeartStillMapsTo(territoryId, value)) { return Entity.Null; } return value; } internal void AddCastleHeart(Entity plotHeart) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Remember(plotHeart); } internal void RemoveCastleHeart(Entity plotHeart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(plotHeart)) { Entity castleTerritoryEntity = plotHeart.Read().CastleTerritoryEntity; entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleTerritoryEntity)) { Forget(castleTerritoryEntity.Read().CastleTerritoryIndex); } } } public void FlushTerritoryCache() { entityPlot.Clear(); } public int GetTerritoryId(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (entity != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity) && entity.Has()) { return GetStandingTerritoryId(entity); } } return ResolvePlot(entity); } public int GetStandingTerritoryId(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!(entity == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity) && entity.Has()) { return PlotUnderTile(entity); } } return -1; } public void MarkTerritoryRebuilding(int territoryId) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plot "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(territoryId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" entered rebuild; logistics deferred."); } log.LogInfo(val); rebuilding.Add(territoryId); } private void ScanPlots() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) plotsByRegion.Clear(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadWrite(Il2CppType.Of())); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val4.Length; i++) { IndexPlot(val4[i]); } } finally { val4.Dispose(); ((EntityQuery)(ref val3)).Dispose(); } } private void ScanHearts() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) heartByPlot.Clear(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly(Il2CppType.Of())); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val4.Length; i++) { Remember(val4[i], notify: false); } } finally { val4.Dispose(); ((EntityQuery)(ref val3)).Dispose(); } } private bool HeartStillMapsTo(int plot, Entity heart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(heart)) { Forget(plot); return false; } Entity castleTerritoryEntity = heart.Read().CastleTerritoryEntity; if (!(castleTerritoryEntity == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleTerritoryEntity)) { if (castleTerritoryEntity.Read().CastleTerritoryIndex == plot) { return true; } Forget(plot); Remember(heart); return false; } } Forget(plot); return false; } private void IndexPlot(Entity plot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) WorldRegionType region = plot.Read().Region; if (!plotsByRegion.TryGetValue(region, out var value)) { value = (plotsByRegion[region] = new List()); } value.Add(plot); } private void Remember(Entity heart, bool notify = true) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(heart)) { return; } Entity castleTerritoryEntity = heart.Read().CastleTerritoryEntity; entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleTerritoryEntity)) { heartByPlot[castleTerritoryEntity.Read().CastleTerritoryIndex] = heart; if (notify) { InvalidateClanPlotCache(); } } } private void Forget(int plot) { heartByPlot.Remove(plot); rebuilding.Remove(plot); InvalidateClanPlotCache(); } private int ResolvePlot(Entity entity) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (entityPlot.TryGetValue(entity, out var value)) { return value; } if (!entity.Has()) { return PlotUnderTile(entity); } CastleHeartConnection val = entity.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.CastleHeartEntity)).GetEntityOnServer(); EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entityOnServer) || entityOnServer == Entity.Null) { return PlotUnderTile(entity); } Entity castleTerritoryEntity = entityOnServer.Read().CastleTerritoryEntity; if (!castleTerritoryEntity.Has()) { return PlotUnderTile(entity); } int castleTerritoryIndex = castleTerritoryEntity.Read().CastleTerritoryIndex; entityPlot[entity] = castleTerritoryIndex; return castleTerritoryIndex; } private int PlotUnderTile(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (entity == Entity.Null || !entity.Has()) { return -1; } WorldRegionType region = Core.RegionService.GetRegion(entity); if (!plotsByRegion.TryGetValue(region, out var value)) { return -1; } TilePosition val = entity.Read(); CastleTerritory val2 = default(CastleTerritory); for (int i = 0; i < value.Count; i++) { Entity entity2 = value[i]; if (CastleTerritoryExtensions.IsTileInTerritory(Core.EntityManager, val.Tile, ref entity2, ref val2) && entity2.Has()) { return entity2.Read().CastleTerritoryIndex; } } return -1; } private static bool TryGetHeartOwner(Entity castleHeart, out Entity userEntity, out User user) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) userEntity = Entity.Null; user = default(User); if (!(castleHeart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { UserOwner val = castleHeart.Read(); userEntity = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (!(userEntity == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEntity) && userEntity.Has()) { user = userEntity.Read(); return true; } } return false; } } return false; } public bool TryGetTerritoryOwnerPlatformId(int territoryId, out ulong platformId) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) platformId = 0uL; if (!TryGetHeartOwner(GetCastleHeart(territoryId), out var _, out var user)) { return false; } platformId = user.PlatformId; return true; } public bool TryGetHeartLevel(int territoryId, out int level) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) level = -1; Entity castleHeart = GetCastleHeart(territoryId); if (!(castleHeart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleHeart) && castleHeart.Has()) { level = castleHeart.Read().Level; return true; } } return false; } public string FormatPlotLabel(int territoryId) { if (territoryId >= 0) { if (TryGetHeartLevel(territoryId, out var level) && level >= 0) { return $"plot {territoryId} L{level}"; } return $"plot {territoryId}"; } return "no plot"; } public bool IsSameClanAsHeart(Entity character, Entity heart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (!(character == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && character.Has()) { Entity userEntity = character.Read().UserEntity; if (!(userEntity == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEntity) && userEntity.Has()) { return IsSameClanAsHeartOwner(userEntity.Read(), heart); } } return false; } } return false; } public bool ClanMemberStandingOnHeart(Entity heart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!(heart == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(heart) && heart.Has()) { Entity castleTerritoryEntity = heart.Read().CastleTerritoryEntity; if (!(castleTerritoryEntity == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(castleTerritoryEntity) && castleTerritoryEntity.Has()) { return ClanMemberStandingOnPlot(castleTerritoryEntity.Read().CastleTerritoryIndex); } } return false; } } return false; } public bool ClanMemberStandingOnPlot(int plot) { EnsureClanStanding(); if (plot >= 0) { return clanStanding.ContainsKey(plot); } return false; } internal void EachUser(Action visit) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager; if (!connectedUsersReady) { EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly(Il2CppType.Of())); entityManager = Core.EntityManager; connectedUsers = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); connectedUsersReady = true; } NativeArray val3 = default(NativeArray); try { val3 = ((EntityQuery)(ref connectedUsers)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); for (int i = 0; i < val3.Length; i++) { Entity val4 = val3[i]; if (val4 != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val4) && val4.Has()) { visit(val4, val4.Read()); } } } } finally { if (val3.IsCreated) { val3.Dispose(); } } } internal void EachKnownPlot(Action visit) { foreach (int key in heartByPlot.Keys) { visit(key); } } private void EnsureClanStanding() { DateTime utcNow = DateTime.UtcNow; if (clanStandingAt != default(DateTime) && (utcNow - clanStandingAt).TotalSeconds < 0.25) { return; } clanStanding.Clear(); clanStandingAt = utcNow; EachUser(delegate(Entity _, User user) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (user.IsConnected) { Entity entityOnServer = ((NetworkedEntity)(ref user.LocalCharacter)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has()) { int standingTerritoryId = GetStandingTerritoryId(entityOnServer); if (standingTerritoryId >= 0) { Entity castleHeart = GetCastleHeart(standingTerritoryId); if (castleHeart != Entity.Null && IsSameClanAsHeart(entityOnServer, castleHeart)) { clanStanding[standingTerritoryId] = true; } } } } } }); } public bool IsSameClanAsHeartOwner(User user, Entity heart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!TryGetHeartOwner(heart, out var _, out var user2)) { return false; } Entity entityOnServer = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer(); Entity entityOnServer2 = ((NetworkedEntity)(ref user2.ClanEntity)).GetEntityOnServer(); if (entityOnServer != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer2 != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer2)) { return entityOnServer == entityOnServer2; } } } return false; } public bool TryGetClanKey(User user, out string key) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) key = null; Entity entityOnServer = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { key = (entityOnServer.Has() ? ("c" + ((object)entityOnServer.Read()/*cast due to .constrained prefix*/).ToString()) : ("e" + entityOnServer.Index + ":" + entityOnServer.Version)); return true; } } return false; } public bool AnyClanMemberHasLegacyClanShare(Entity clanEntity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!(clanEntity == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(clanEntity)) { bool found = false; EachUser(delegate(Entity _, User other) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!found) { Entity entityOnServer = ((NetworkedEntity)(ref other.ClanEntity)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager2 = Core.EntityManager; if (((EntityManager)(ref entityManager2)).Exists(entityOnServer) && !(entityOnServer != clanEntity) && Core.PlayerSettings.IsClanShareEnabled(other.PlatformId)) { found = true; } } } }); return found; } } return false; } public bool IsClanShareOn(User standingOwner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!TryGetClanKey(standingOwner, out var key)) { return false; } if (Core.PlayerSettings.TryGetClanShareFlag(key, out var enabled)) { return enabled; } if (!AnyClanMemberHasLegacyClanShare(((NetworkedEntity)(ref standingOwner.ClanEntity)).GetEntityOnServer())) { return false; } Core.PlayerSettings.SetClanShareForClan(key, enabled: true); return true; } public void InvalidateClanPlotCache() { clanPlotCache.Clear(); clanPlotCacheAt.Clear(); } private List GetCachedClanPlots(string clanKey, Entity clanEntity) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (clanPlotCache.TryGetValue(clanKey, out var value) && clanPlotCacheAt.TryGetValue(clanKey, out var value2) && (DateTime.UtcNow - value2).TotalSeconds < 5.0) { return value; } List list = new List(); List list2 = new List(heartByPlot.Keys); for (int i = 0; i < list2.Count; i++) { int num = list2[i]; Entity castleHeart = GetCastleHeart(num); if (castleHeart == Entity.Null || !TryGetHeartOwner(castleHeart, out var _, out var user)) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer(); if (entityOnServer != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer == clanEntity) { list.Add(num); } } } clanPlotCache[clanKey] = list; clanPlotCacheAt[clanKey] = DateTime.UtcNow; return list; } public IReadOnlyList GetLogisticsTerritoryIds(int standingTerritoryId) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (standingTerritoryId < 0) { return list; } list.Add(standingTerritoryId); if (!TryGetHeartOwner(GetCastleHeart(standingTerritoryId), out var _, out var user) || !IsClanShareOn(user)) { return list; } Entity entityOnServer = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && TryGetClanKey(user, out var key)) { { foreach (int cachedClanPlot in GetCachedClanPlots(key, entityOnServer)) { if (cachedClanPlot != standingTerritoryId && !Core.PlayerSettings.IsTerritoryClanShareExcluded(cachedClanPlot)) { list.Add(cachedClanPlot); } } return list; } } } return list; } public IReadOnlyList GetClanLogisticsTerritoryIds(User user) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (!IsClanShareOn(user) || !TryGetClanKey(user, out var key)) { return list; } Entity entityOnServer = ((NetworkedEntity)(ref user.ClanEntity)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { { foreach (int cachedClanPlot in GetCachedClanPlots(key, entityOnServer)) { if (!Core.PlayerSettings.IsTerritoryClanShareExcluded(cachedClanPlot)) { list.Add(cachedClanPlot); } } return list; } } } return list; } public IReadOnlyList GetLogisticsTerritoryIdsForCharacter(Entity character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) int standingTerritoryId = GetStandingTerritoryId(character); User val = default(User); bool flag = false; if (character != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(character) && character.Has()) { Entity userEntity = character.Read().UserEntity; if (userEntity != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEntity) && userEntity.Has()) { val = userEntity.Read(); flag = true; } } } } Entity val2 = ((standingTerritoryId >= 0) ? GetCastleHeart(standingTerritoryId) : Entity.Null); bool flag2 = flag && val2 != Entity.Null && IsSameClanAsHeartOwner(val, val2); ServerGameManager serverGameManager; if (flag && IsClanShareOn(val)) { if (flag2 && standingTerritoryId >= 0 && Core.PlayerSettings.IsTerritoryClanShareExcluded(standingTerritoryId)) { serverGameManager = Core.ServerGameManager; if (((ServerGameManager)(ref serverGameManager)).IsAllies(val2, character)) { return new List { standingTerritoryId }; } } return GetClanLogisticsTerritoryIds(val); } if (standingTerritoryId >= 0 && val2 != Entity.Null && flag) { serverGameManager = Core.ServerGameManager; if (((ServerGameManager)(ref serverGameManager)).IsAllies(val2, character)) { return new List { standingTerritoryId }; } } return new List(); } public IReadOnlyList GetServantStashPlotIds(int homePlot) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (homePlot < 0) { return new List(); } Entity castleHeart = GetCastleHeart(homePlot); if (castleHeart == Entity.Null) { return new List { homePlot }; } if (IsHeartRaided(castleHeart)) { return new List(); } if (!TryGetHeartOwner(castleHeart, out var _, out var user) || !IsClanShareOn(user) || Core.PlayerSettings.IsTerritoryClanShareExcluded(homePlot)) { return new List { homePlot }; } IReadOnlyList clanLogisticsTerritoryIds = GetClanLogisticsTerritoryIds(user); if (clanLogisticsTerritoryIds != null && clanLogisticsTerritoryIds.Count != 0) { return clanLogisticsTerritoryIds; } return new List { homePlot }; } public bool TryFindOwnedTerritory(ulong platformId, out int territoryId, out User owner) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) territoryId = -1; owner = default(User); List list = new List(heartByPlot.Keys); for (int i = 0; i < list.Count; i++) { int num = list[i]; if (TryGetHeartOwner(GetCastleHeart(num), out var _, out var user) && user.PlatformId == platformId) { territoryId = num; owner = user; return true; } } return false; } public static bool IsHeartRaided(Entity heart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 if (heart != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(heart) && heart.Has()) { return (int)heart.Read().ActiveEvent >= 2; } } return false; } } internal sealed class TrashService { public void AshAll(Entity character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) EmptyTrash(character); } public void EmptyTrash(Entity character) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!Gate(character, out var ctx)) { return; } int num = 0; foreach (Entity item in Core.Stash.TrashChests(ctx.StandingPlot)) { if (Wipe(item)) { num++; } } PlayerActionGate.Deny(ctx.User, "Trash emptied from " + Format.Color(num.ToString(), Color.White) + "x trash containers."); } public void EmptyTrash(Entity character, Entity trashContainer) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (Gate(character, out var ctx)) { Wipe(trashContainer); PlayerActionGate.Deny(ctx.User, "Sunlight, at this hour, in this castle, localized entirely within this trash bin? This trash is ashed."); } } private static bool Gate(Entity character, out PlayerActionGate.Context ctx) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) ctx = default(PlayerActionGate.Context); if (!PlayerActionGate.TryOpen(character, "empty trash", requireAlliedHeart: true, out ctx, out var deny)) { if (ctx.UserEntity != Entity.Null) { PlayerActionGate.Deny(ctx.User, deny); } return false; } if (!Core.PlayerSettings.IsTrashEnabled()) { return true; } PlayerActionGate.Deny(ctx.User, "Trash is globally disabled."); return false; } private static bool Wipe(Entity container) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (!InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, container, ref val, 0)) { return false; } EntityManager entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(val, false); bool result = false; for (int i = 0; i < buffer.Length; i++) { if (buffer[i].Amount > 0) { InventoryUtilitiesServer.ClearSlot(Core.EntityManager, val, i); result = true; } } return result; } } internal sealed class UnitSpawnerstationService { private readonly HeartBoundIndex index; private static ComponentType[] QueryTypes => (ComponentType[])(object)new ComponentType[7] { ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()) }; public UnitSpawnerstationService() { index = HeartBoundIndex.Scan(includeDisabled: true, QueryTypes); } internal void AddUnitSpawnerStation(Entity station) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) index.Track(station); } internal void RemoveUnitSpawnerStation(Entity station) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) index.Untrack(station); } public IEnumerable GetAllUnitSpawners(int territoryId) { return index.OnTerritory(territoryId); } } internal class WorkQueueService { internal readonly HashSet queued = new HashSet(); internal readonly Queue pending = new Queue(); internal readonly HashSet rebuildDeferred = new HashSet(); internal int processing = -1; internal bool reprocessCurrent; private int transferSuppress; internal int DrainGeneration { get; set; } public int QueueDepth => pending.Count; public bool IsSelfTransferring => transferSuppress > 0; public WorkQueueService() { Core.StartCoroutine(CastleWorkDrain.Loop(this)); } public void BeginSelfTransfer() { transferSuppress++; } public void EndSelfTransfer() { transferSuppress = ((transferSuppress > 0) ? (transferSuppress - 1) : 0); } public bool IsQueued(int territoryId) { if (territoryId != processing) { return queued.Contains(territoryId); } return true; } public void Enqueue(int plot) { if ((plot >= 0 && plot <= 146) || 1 == 0) { Core.Stash?.InvalidateTerritory(plot); ClanTreasuryLend.MarkDirty(plot); if (plot == processing) { reprocessCurrent = true; } else if (queued.Add(plot)) { pending.Enqueue(plot); } } } public void EnqueueOwner(Entity owner) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (owner != Entity.Null) { Enqueue(Core.TerritoryService.GetTerritoryId(owner)); } } public void EnqueueAll() { Core.TerritoryService.EachKnownPlot(Enqueue); } internal void FlushRebuildDeferred() { if (rebuildDeferred.Count != 0) { List list = new List(rebuildDeferred); rebuildDeferred.Clear(); for (int i = 0; i < list.Count; i++) { Enqueue(list[i]); } } } } } namespace Satisvampory.Patches { [HarmonyPatch(typeof(BonfireSystem_Server), "OnUpdate")] public static class BonfireSystem_ServerPatch { private static bool duskArmed; public static void Prefix(BonfireSystem_Server __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 if (Core.HasInitialized && Core.PlayerSettings.IsSolarEnabled(0uL)) { ServerGameManager serverGameManager = Core.ServerGameManager; if ((int)((DayNightCycle)(ref serverGameManager.DayNightCycle)).TimeOfDay == 2) { duskArmed = true; } else if (duskArmed) { duskArmed = false; SetLit(__instance, lit: false); } } } public static void Postfix(BonfireSystem_Server __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 if (Core.HasInitialized && Core.PlayerSettings.IsSolarEnabled(0uL)) { ServerGameManager serverGameManager = Core.ServerGameManager; if ((int)((DayNightCycle)(ref serverGameManager.DayNightCycle)).TimeOfDay != 1) { SetLit(__instance, lit: true); } } } private unsafe static void SetLit(BonfireSystem_Server system, bool lit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) EntityQuery _query_1818188685_ = system.__query_1818188685_0; NativeArray val = ((EntityQuery)(ref _query_1818188685_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val.Length; i++) { Entity entity = val[i]; if (entity.Has() && entity.Has() && entity.Has() && entity.Read().Enabled) { NameableInteractable val2 = entity.Read(); if (((object)(*(FixedString64Bytes*)(&val2.Name))/*cast due to .constrained prefix*/).ToString().IndexOf("night", StringComparison.OrdinalIgnoreCase) >= 0) { Bonfire componentData = entity.Read(); componentData.IsActive = lit; entity.Write(componentData); } } } } finally { val.Dispose(); } } } public static class CastleBuildClanSharePatch { [HarmonyPatch(typeof(GetPlacementResourcesResult), "HasEnoughResources")] public static class HasEnough_Patch { private static void Postfix(MapZoneCollection mapZoneCollection, PlacementResourcesResult resourcesResult, EntityManager entityManager, Entity character, BuildResourceConsumeType resourceConsumeType, ref bool __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (__result || !CanShareBuild(character, resourceConsumeType, out var heart)) { return; } try { __result = ClanTreasuryShare.HasEnoughForBuild(entityManager, heart, character, resourcesResult.ResourceRequirements); } catch (Exception e) { Core.LogException(e, "Postfix"); } } } [HarmonyPatch] public static class RemoveItems_Patch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(ApplyPlacementResourcesResult), "RemoveItemsDueToResourceRequirements", (Type[])null, (Type[])null); } private static bool Prefix(PlacementResourcesResult result, MapZoneCollection mapZoneCollection, EntityManager entityManager, Entity character, BuildResourceConsumeType resourceConsumeType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!CanShareBuild(character, resourceConsumeType, out var heart)) { return true; } try { if (!ClanTreasuryShare.HasEnoughForBuild(entityManager, heart, character, result.ResourceRequirements)) { return true; } if (!ClanTreasuryShare.ConsumeBuildRequirements(entityManager, mapZoneCollection, heart, character, result.ResourceRequirements)) { return true; } return false; } catch (Exception e) { Core.LogException(e, "Prefix"); return true; } } } private static bool CanShareBuild(Entity character, BuildResourceConsumeType resourceConsumeType, out Entity heart) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) heart = Entity.Null; if ((int)resourceConsumeType != 0) { return false; } if (!Core.HasInitialized) { return false; } int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(character); heart = ((standingTerritoryId >= 0) ? Core.TerritoryService.GetCastleHeart(standingTerritoryId) : Entity.Null); if (!ClanTreasuryShare.ShouldShare(heart)) { return false; } return Core.TerritoryService.IsSameClanAsHeart(character, heart); } } [HarmonyPatch(typeof(SpawnCastleTeamSystem), "OnUpdate")] internal class CastleHeartSpawnSystemPatch { public static bool Prefix(SpawnCastleTeamSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Visit(__instance._MainQuery, delegate(Entity heart) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Core.TerritoryService.AddCastleHeart(heart); }); return true; } internal static void Visit(EntityQuery query, Action visit) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) NativeArray val = ((EntityQuery)(ref query)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val.Length; i++) { visit(val[i]); } } finally { val.Dispose(); } } } [HarmonyPatch(typeof(CastleHeartClearRaidStateSystem), "OnUpdate")] internal class CastleHeartDestroySystemPatch { public static bool Prefix(CastleHeartClearRaidStateSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) CastleHeartSpawnSystemPatch.Visit(__instance._DestroyedCastleHeartQuery, delegate(Entity heart) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Core.TerritoryService.RemoveCastleHeart(heart); }); return true; } } public static class CastleRebuildPatches { private static EntityQuery transferQuery; [EcsSystemUpdatePrefix(typeof(CastleRebuildRegistryServerEventSystem), true)] public static void OnRegistryPrefix() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { return; } if (transferQuery == default(EntityQuery)) { EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly(Il2CppType.Of())); EntityManager entityManager = Core.EntityManager; transferQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); } NativeArray val3 = ((EntityQuery)(ref transferQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val3.Length; i++) { TerritoryService territoryService = Core.TerritoryService; CastleRebuildTransferEvent val4 = val3[i].Read(); territoryService.MarkTerritoryRebuilding(((MapZoneId)(ref val4.SourceTerritory)).ZoneIndex); } } finally { val3.Dispose(); } } } [HarmonyPatch(typeof(CastleRebuildRegistryOnDestroySystem), "OnUpdate")] internal class CastleRebuildRegistryOnDestroySystemPatch { private static void Prefix() { Core.TerritoryService?.FlushTerritoryCache(); Core.WorkQueue?.FlushRebuildDeferred(); } } [HarmonyPatch(typeof(CastleHasItemsOnSpawnSystem), "OnUpdate")] internal class CastleStationSpawnSystemPatch { public static bool Prefix(CastleHasItemsOnSpawnSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Track(__instance.__query_60442477_0, spawn: true); return true; } internal static void Track(EntityQuery query, bool spawn) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) NativeArray val = ((EntityQuery)(ref query)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val.Length; i++) { Register(val[i], spawn); } } finally { val.Dispose(); } } private static void Register(Entity station, bool spawn) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) if (station.Has()) { Bind(spawn, delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Core.BrazierService.AddBrazier(station); }, delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Core.BrazierService.RemoveBrazier(station); }); } if (station.Has()) { Bind(spawn, delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Core.RefinementStations.AddRefinementStation(station); }, delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Core.RefinementStations.RemoveRefinementStation(station); }); } if (station.Has()) { Bind(spawn, delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Core.SalvageService.AddSalvageStation(station); }, delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Core.SalvageService.RemoveSalvageStation(station); }); } if (station.Has()) { Bind(spawn, delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Core.UnitSpawnerstationService.AddUnitSpawnerStation(station); }, delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Core.UnitSpawnerstationService.RemoveUnitSpawnerStation(station); }); } if (station.Has()) { Bind(spawn, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ClanTreasuryLend.AddWorkstation(station); }, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ClanTreasuryLend.RemoveWorkstation(station); }); } if (spawn) { Core.WorkQueue?.EnqueueOwner(station); } } private static void Bind(bool spawn, Action add, Action remove) { if (spawn) { add(); } else { remove(); } } } [HarmonyPatch(typeof(CastleHasItemsOnDestroySystem), "OnUpdate")] internal class CastleStationDestroySystemPatch { public static bool Prefix(CastleHasItemsOnDestroySystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) CastleStationSpawnSystemPatch.Track(__instance._DestroyConnectedCastleItem, spawn: false); return true; } } [HarmonyPatch(typeof(ServantInfoEventSystem_Server), "OnUpdate")] public static class ClanThroneInfoRewritePatch { private static void Prefix(ServantInfoEventSystem_Server __instance) { if (!Core.HasInitialized) { return; } try { ClanThroneServants.RewriteInfoRequests(__instance); } catch (Exception e) { Core.LogException(e, "Prefix"); } } private static void Postfix() { if (Core.HasInitialized) { ClanThroneServants.AfterInfoUpdate(); } } } [HarmonyPatch(typeof(ServantMissionActionSystem), "OnUpdate")] public static class ClanThroneMissionRewritePatch { private static void Prefix(ServantMissionActionSystem __instance) { if (!Core.HasInitialized) { return; } try { ClanThroneServants.RewriteMissionEvents(__instance); } catch (Exception e) { Core.LogException(e, "Prefix"); } } private static void Postfix() { RepeatHunts.AfterSends(); RepeatHunts.TickAutoSend(); } } [HarmonyPatch(typeof(ServantMissionActionSystem), "ValidateThroneAndServants")] public static class ClanThroneValidatePatch { private static void Postfix(Entity throneEntity, Entity fromCharacter, ref bool __result) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (__result || !Core.HasInitialized) { return; } try { if (RepeatHunts.IsAutoSend(throneEntity, fromCharacter) || ClanThroneServants.MayManageFrom(fromCharacter, throneEntity)) { __result = true; } } catch (Exception e) { Core.LogException(e, "Postfix"); } } } [HarmonyPatch] public class CraftingPatch { private static bool CraftPullOn(FromCharacter from, out Entity character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) character = from.Character; return Core.PlayerSettings.IsCraftPullEnabled(from.User.Read().PlatformId); } private static void Visit(EntityQuery query, Action visit) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) NativeArray val = ((EntityQuery)(ref query)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val.Length; i++) { visit(val[i]); } } finally { val.Dispose(); } } private static bool AlreadyQueued(Entity station, PrefabGUID recipe) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!station.Has()) { return true; } EntityManager entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(station, false); for (int i = 0; i < buffer.Length; i++) { QueuedWorkstationCraftAction val = buffer[i]; if (((PrefabGUID)(ref val.RecipeGuid)).Equals(recipe)) { return true; } } return false; } private static void RepairIfDamaged(Entity character, Entity item, PrefabGUID prefab) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (item.Has()) { Durability val = item.Read(); if (!(val.Value >= val.MaxDurability)) { PullService.HandleRepairPull(character, val.RepairRecipe, val.Value / val.MaxDurability, prefab); } } } private static void OnStopCraft(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (entity.Has() && entity.Has() && CraftPullOn(entity.Read(), out var character)) { Entity target = character.Read().Target; PrefabGUID recipeGuid = entity.Read().RecipeGuid; if (!AlreadyQueued(target, recipeGuid)) { PullService.HandleRecipePull(character, target, recipeGuid); } } } private static void OnForgeCancel(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (!CraftPullOn(entity.Read(), out var character)) { return; } Entity target = character.Read().Target; if (!target.Has()) { return; } Forge_Shared val = target.Read(); ref ForgeState state = ref val.State; object obj = (object)(ForgeState)2; if (!((object)Unsafe.As(ref state)/*cast due to .constrained prefix*/).Equals(obj)) { Entity entity2 = val.ItemEntity._Entity; if (entity2.Has()) { PullService.HandleForgePull(character, target, entity2); } else if (entity2.Has()) { PullService.HandleForgeUpgradePull(character, target, entity2); } } } private static void OnRepairSlot(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) RepairItemEvent val = entity.Read(); FromCharacter val2 = entity.Read(); Entity val3 = default(Entity); if (InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, val2.Character, ref val3, 0)) { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val4 = default(DynamicBuffer); if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val3, ref val4)) { InventoryBuffer val5 = val4[val.Slot]; RepairIfDamaged(val2.Character, val5.ItemEntity._Entity, val5.ItemType); } } } private static void OnRepairGear(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) RepairEquippedItemEvent val = entity.Read(); FromCharacter val2 = entity.Read(); Equipment val3 = val2.Character.Read(); NetworkedEntity equipmentEntity = ((Equipment)(ref val3)).GetEquipmentEntity(val.EquipmentType); Entity entityOnServer = ((NetworkedEntity)(ref equipmentEntity)).GetEntityOnServer(); if (entityOnServer.Has()) { RepairIfDamaged(val2.Character, entityOnServer, entityOnServer.Read()); } } [HarmonyPatch(typeof(StopCraftingSystem), "OnUpdate")] [HarmonyPrefix] private static void StopCraftPrefix(StopCraftingSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Visit(__instance._EventQuery, OnStopCraft); } [HarmonyPatch(typeof(ForgeSystem_Events), "OnUpdate")] [HarmonyPrefix] private static void ForgePrefix(ForgeSystem_Events __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Visit(__instance._CancelRepairEventQuery, OnForgeCancel); } [HarmonyPatch(typeof(RepairItemSystem), "OnUpdate")] [HarmonyPrefix] private static void RepairPrefix(RepairItemSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Visit(__instance._RepairItemEventQuery, OnRepairSlot); Visit(__instance._RepairEquippedItemEventQuery, OnRepairGear); } } [HarmonyPatch(typeof(SceneSectionStreamingSystem), "ShutdownAsynchrnonousStreamingSupport")] public static class InitializationPatch { [HarmonyPostfix] public static void AfterSceneReady() { Core.Initialize(); Plugin.Harmony.Unpatch((MethodBase)typeof(SceneSectionStreamingSystem).GetMethod("ShutdownAsynchrnonousStreamingSupport"), typeof(InitializationPatch).GetMethod("AfterSceneReady")); } } public static class MergedInventoriesClanSharePatch { [HarmonyPatch(typeof(MergedInventoriesUtility), "GetCastleMergedInventoryDatas", new Type[] { typeof(EntityManager), typeof(Entity), typeof(Entity), typeof(bool), typeof(bool) })] public static class GetMerged_Heart { private static bool Prefix(EntityManager entityManager, Entity castleHeartEntity, Entity target, bool includeCurrentInteractingInventory, bool includeCastleSharedInventories, ref NativeArray __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!TryBeginShare(castleHeartEntity, includeCastleSharedInventories, target)) { return true; } ClanTreasuryShare.Suppress = true; try { __result = ClanTreasuryShare.CombineMerged(entityManager, castleHeartEntity, target, includeCurrentInteractingInventory, includeCastleSharedInventories); return false; } catch (Exception e) { Core.LogException(e, "Prefix"); return true; } finally { ClanTreasuryShare.Suppress = false; } } } [HarmonyPatch(typeof(MergedInventoriesUtility), "GetCastleMergedInventoryDatas", new Type[] { typeof(EntityManager), typeof(MapZoneCollection), typeof(Entity), typeof(bool), typeof(bool) })] public static class GetMerged_MapZone { private static bool Prefix(EntityManager entityManager, Entity target, bool includeCurrentInteractingInventory, bool includeCastleSharedInventories, ref NativeArray __result) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (ClanTreasuryShare.Suppress || !includeCastleSharedInventories || !Core.HasInitialized) { return true; } Entity standingHeart = ClanTreasuryShare.HeartFromTarget(target); if (!TryBeginShare(standingHeart, includeCastleSharedInventories, target)) { return true; } ClanTreasuryShare.Suppress = true; try { __result = ClanTreasuryShare.CombineMerged(entityManager, standingHeart, target, includeCurrentInteractingInventory, includeCastleSharedInventories); return false; } catch (Exception e) { Core.LogException(e, "Prefix"); return true; } finally { ClanTreasuryShare.Suppress = false; } } } [HarmonyPatch] public static class Remove_Heart { private static MethodBase TargetMethod() { return FindRemove(typeof(EntityManager), typeof(Entity), typeof(Entity), typeof(PrefabGUID), typeof(int), typeof(int).MakeByRefType(), typeof(bool), typeof(bool), typeof(bool)); } private static bool Prefix(EntityManager entityManager, Entity castleHeartEntity, Entity target, PrefabGUID type, int amount, ref int remainder, bool includeCurrentInteractingInventory, bool includeCastleSharedInventories, bool destroyItem) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!TryBeginShare(castleHeartEntity, includeCastleSharedInventories, target)) { return true; } ClanTreasuryShare.Suppress = true; try { MergedInventoriesUtility.RemoveItemGetRemainder(entityManager, castleHeartEntity, target, type, amount, ref remainder, includeCurrentInteractingInventory, includeCastleSharedInventories, destroyItem); if (remainder > 0) { ClanTreasuryShare.ConsumeRemainderFromOtherTreasuries(castleHeartEntity, type, ref remainder); } return false; } catch (Exception e) { Core.LogException(e, "Prefix"); return true; } finally { ClanTreasuryShare.Suppress = false; } } } [HarmonyPatch] public static class Remove_Heart_ItemEntity { private static MethodBase TargetMethod() { return FindRemove(typeof(EntityManager), typeof(Entity), typeof(Entity), typeof(PrefabGUID), typeof(int), typeof(int).MakeByRefType(), typeof(Entity).MakeByRefType(), typeof(bool), typeof(bool), typeof(bool)); } private static bool Prefix(EntityManager entityManager, Entity castleHeartEntity, Entity target, PrefabGUID type, int amount, ref int remainder, ref Entity itemEntity, bool includeCurrentInteractingInventory, bool includeCastleSharedInventories, bool destroyItem) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!TryBeginShare(castleHeartEntity, includeCastleSharedInventories, target)) { return true; } ClanTreasuryShare.Suppress = true; try { MergedInventoriesUtility.RemoveItemGetRemainder(entityManager, castleHeartEntity, target, type, amount, ref remainder, ref itemEntity, includeCurrentInteractingInventory, includeCastleSharedInventories, destroyItem); if (remainder > 0) { ClanTreasuryShare.ConsumeRemainderFromOtherTreasuries(castleHeartEntity, type, ref remainder); } return false; } catch (Exception e) { Core.LogException(e, "Prefix"); return true; } finally { ClanTreasuryShare.Suppress = false; } } } [HarmonyPatch] public static class Remove_MapZone { private static MethodBase TargetMethod() { return FindRemove(typeof(EntityManager), typeof(MapZoneCollection), typeof(Entity), typeof(PrefabGUID), typeof(int), typeof(int).MakeByRefType(), typeof(bool), typeof(bool), typeof(bool)); } private static bool Prefix(EntityManager entityManager, MapZoneCollection mapZoneCollection, Entity target, PrefabGUID type, int amount, ref int remainder, bool includeCurrentInteractingInventory, bool includeCastleSharedInventories, bool destroyItem) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (ClanTreasuryShare.Suppress || !includeCastleSharedInventories || !Core.HasInitialized) { return true; } Entity standingHeart = ClanTreasuryShare.HeartFromTarget(target); if (!TryBeginShare(standingHeart, includeCastleSharedInventories, target)) { return true; } ClanTreasuryShare.Suppress = true; try { MergedInventoriesUtility.RemoveItemGetRemainder(entityManager, mapZoneCollection, target, type, amount, ref remainder, includeCurrentInteractingInventory, includeCastleSharedInventories, destroyItem); if (remainder > 0) { ClanTreasuryShare.ConsumeRemainderFromOtherTreasuries(standingHeart, type, ref remainder); } return false; } catch (Exception e) { Core.LogException(e, "Prefix"); return true; } finally { ClanTreasuryShare.Suppress = false; } } } [HarmonyPatch] public static class Remove_MapZone_ItemEntity { private static MethodBase TargetMethod() { return FindRemove(typeof(EntityManager), typeof(MapZoneCollection), typeof(Entity), typeof(PrefabGUID), typeof(int), typeof(int).MakeByRefType(), typeof(Entity).MakeByRefType(), typeof(bool), typeof(bool), typeof(bool)); } private static bool Prefix(EntityManager entityManager, MapZoneCollection mapZoneCollection, Entity target, PrefabGUID type, int amount, ref int remainder, ref Entity itemEntity, bool includeCurrentInteractingInventory, bool includeCastleSharedInventories, bool destroyItem) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (ClanTreasuryShare.Suppress || !includeCastleSharedInventories || !Core.HasInitialized) { return true; } Entity standingHeart = ClanTreasuryShare.HeartFromTarget(target); if (!TryBeginShare(standingHeart, includeCastleSharedInventories, target)) { return true; } ClanTreasuryShare.Suppress = true; try { MergedInventoriesUtility.RemoveItemGetRemainder(entityManager, mapZoneCollection, target, type, amount, ref remainder, ref itemEntity, includeCurrentInteractingInventory, includeCastleSharedInventories, destroyItem); if (remainder > 0) { ClanTreasuryShare.ConsumeRemainderFromOtherTreasuries(standingHeart, type, ref remainder); } return false; } catch (Exception e) { Core.LogException(e, "Prefix"); return true; } finally { ClanTreasuryShare.Suppress = false; } } } private static bool TryBeginShare(Entity standingHeart, bool includeCastleSharedInventories, Entity actor = default(Entity)) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (ClanTreasuryShare.Suppress) { return false; } if (!includeCastleSharedInventories) { return false; } if (!Core.HasInitialized) { return false; } if (!ClanTreasuryShare.ShouldShare(standingHeart)) { return false; } if (actor != Entity.Null) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(actor) && actor.Has()) { return Core.TerritoryService.IsSameClanAsHeart(actor, standingHeart); } } return Core.TerritoryService.ClanMemberStandingOnHeart(standingHeart); } private static MethodBase FindRemove(params Type[] args) { return AccessTools.Method(typeof(MergedInventoriesUtility), "RemoveItemGetRemainder", args, (Type[])null); } } [HarmonyPatch(typeof(NameableInteractableSystem), "OnUpdate")] internal static class NameableInteractableSystemPatch { [HarmonyPrefix] private static void Prefix(NameableInteractableSystem __instance) { Drain(__instance); } private static void Drain(NameableInteractableSystem system) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized || Core.WorkQueue == null) { return; } EntityQuery renameQuery = system._RenameQuery; NativeArray val = ((EntityQuery)(ref renameQuery)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val.Length; i++) { if (Core.TryGetEntityFromNetworkId(val[i].InteractableId, out var entity)) { Core.WorkQueue.EnqueueOwner(entity); } } } finally { val.Dispose(); } } } [HarmonyPatch(typeof(DropItemSystem), "OnUpdate")] internal static class DropItemSystem_PlayerDropPatch { private static void Prefix() { DropTrackerHooks.ScanPlayerDropEvents(); } } [HarmonyPatch(typeof(DropInventoryItemSystem), "OnUpdate")] internal static class DropInventoryItemSystem_PlayerDropPatch { private static void Prefix() { DropTrackerHooks.ScanPlayerDropEvents(); } } [HarmonyPatch(typeof(DropItemThrowSystem), "OnUpdate")] internal static class DropItemThrowSystem_PlayerDropPatch { private static void Prefix() { DropTrackerHooks.ScanPlayerDropEvents(); } } internal static class DropTrackerHooks { private static float lastScanUnscaled = float.NaN; public static void ScanPlayerDropEvents() { if (!Core.HasInitialized) { return; } float unscaledTime = Time.unscaledTime; if (unscaledTime == lastScanUnscaled) { return; } lastScanUnscaled = unscaledTime; try { Scan((Action)ReadSlotDrop); Scan((Action)ReadInventoryDrop); Scan((Action)ReadEntireDrop); } catch (Exception e) { Core.LogException(e, "ScanPlayerDropEvents"); } } private static void Scan(Action read) where TEvent : struct { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of(), (AccessMode)1)); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); NativeArray val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val4.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!(current == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(current) && current.Has()) { read(current); } } } } finally { val4.Dispose(); ((EntityQuery)(ref val3)).Dispose(); } } private static void ReadSlotDrop(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) DropItemAtSlotEvent val = entity.Read(); NoteFromCharacter(entity.Read(), val.SlotIndex); } private static void ReadInventoryDrop(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) DropInventoryItemEvent val = entity.Read(); NoteFromCharacter(entity.Read(), val.SlotIndex); } private static void ReadEntireDrop(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) NoteFromCharacter(entity.Read(), -1); } private unsafe static void NoteFromCharacter(FromCharacter from, int slotIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Entity character = from.Character; if (character == Entity.Null) { return; } EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(character) || !character.Has()) { return; } float3 value = character.Read().Value; PrefabGUID item = default(PrefabGUID); int num = 0; Entity val = default(Entity); if (slotIndex >= 0 && InventoryUtilities.TryGetInventoryEntity(Core.EntityManager, character, ref val, 0) && val != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(val)) { ServerGameManager serverGameManager = Core.ServerGameManager; DynamicBuffer val2 = default(DynamicBuffer); if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer(val, ref val2) && slotIndex < val2.Length) { InventoryBuffer val3 = val2[slotIndex]; item = val3.ItemType; num = val3.Amount; } } } DropTracker.NotePlayerDrop(value, item, num); string text = "?"; if (from.User != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(from.User) && from.User.Has()) { User val4 = from.User.Read(); text = ((object)(*(FixedString64Bytes*)(&val4.CharacterName))/*cast due to .constrained prefix*/).ToString(); } } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(38, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Player drop noted "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" item="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((PrefabGUID)(ref item)).GuidHash); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" amount="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" slot="); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(slotIndex); } log.LogInfo(val5); } } [HarmonyPatch(typeof(ReactToInventoryChangedSystem), "OnUpdate")] internal static class ReactToInventoryChangedSystemPatch { [HarmonyPrefix] private static void Prefix(ReactToInventoryChangedSystem __instance) { Drain(__instance); } private static void Drain(ReactToInventoryChangedSystem system) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { return; } WorkQueueService workQueue = Core.WorkQueue; if (workQueue == null || workQueue.IsSelfTransferring) { return; } EntityQuery val = ((Il2CppArrayBase)(object)((ComponentSystemBase)system).EntityQueries)[0]; NativeArray val2 = ((EntityQuery)(ref val)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val2.Length; i++) { EnqueueCastle(val2[i].InventoryEntity); } } finally { val2.Dispose(); } } private static void EnqueueCastle(Entity inventory) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (inventory.Has()) { Entity inventoryOwner = inventory.Read().InventoryOwner; if (inventoryOwner != Entity.Null && inventoryOwner.Has()) { Core.WorkQueue.EnqueueOwner(inventoryOwner); } } } } [HarmonyPatch(typeof(ServantMissionUpdateSystem), "OnUpdate")] public static class ServantMissionUpdateSystemPatch { private static int lastStashFrame = -1; private static readonly HashSet stashed = new HashSet(); private static void Prefix(ServantMissionUpdateSystem __instance) { TryStash(__instance, "prefix"); } private static void Postfix(ServantMissionUpdateSystem __instance) { TryStash(__instance, "postfix"); } internal static void TryStash(ServantMissionUpdateSystem instance, string via) { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (instance == null || !Core.HasInitialized) { return; } int frameCount = Time.frameCount; if (frameCount != lastStashFrame) { lastStashFrame = frameCount; stashed.Clear(); } NativeList tempFinishedMissions = instance._TempFinishedMissions; NativeList tempServantList = instance._TempServantList; try { bool flag = false; bool flag2 = false; if (tempFinishedMissions.IsCreated) { for (int i = 0; i < tempFinishedMissions.Length; i++) { flag = true; ulong num = SteamOf(tempFinishedMissions[i].MissionOwner); if (num != 0L && !Core.PlayerSettings.IsAutoStashMissionsEnabled(num)) { DestDebugLog.Miss("servant", -1, default(PrefabGUID), 0, 0, "asm-off steam=" + num + " via=" + via); flag2 = true; } } } if (!flag2 && tempServantList.IsCreated) { for (int j = 0; j < tempServantList.Length; j++) { flag = true; StashOne(tempServantList[j], 0uL); } } if (flag) { DestDebugLog.Note("servant", -1, 0uL, "tick via=" + via + " stashed=" + stashed.Count); } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag3 = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(32, 2, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Exited ServantMission stash ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(via); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static ulong SteamOf(Entity owner) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) try { long result; if (!(owner == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(owner) && owner.Has()) { Entity entity = owner.Read().Owner._Entity; if (entity != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity) && entity.Has()) { result = (long)entity.Read().PlatformId; goto IL_006f; } } result = 0L; goto IL_006f; } } return 0uL; IL_006f: return (ulong)result; } catch { return 0uL; } } private static void StashOne(Entity servant, ulong steamId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!(servant == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(servant) && !servant.Has() && stashed.Add(servant.Index) && (steamId == 0L || Core.PlayerSettings.IsAutoStashMissionsEnabled(steamId))) { Utilities.StashServantInventory(servant); } } } } [HarmonyPatch] public static class ServantMissionFinishMissionsPatch { private static bool Prepare() { return TargetMethod() != null; } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(ServantMissionUpdateSystem), "FinishMissions", (Type[])null, (Type[])null) ?? AccessTools.DeclaredMethod(typeof(ServantMissionUpdateSystem), "FinishMissions", (Type[])null, (Type[])null); } private static void Prefix(NativeList finishedMissisons) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { return; } try { RepeatHunts.SnapshotFinishing(finishedMissisons); } catch (Exception ex) { Core.Log.LogError((object)("RepeatHunt snapshot: " + ex)); } } private static void Postfix(ServantMissionUpdateSystem __instance) { if (__instance != null) { try { RepeatHunts.AfterReturn(); } catch (Exception ex) { Core.Log.LogError((object)("RepeatHunt return: " + ex)); } ServantMissionUpdateSystemPatch.TryStash(__instance, "finish"); } } } [HarmonyPatch] public class SortSingleInventorySystemPatch { private static readonly Dictionary stashArmed = new Dictionary(); private static readonly Dictionary trashArmed = new Dictionary(); [HarmonyPatch(typeof(SortSingleInventorySystem), "OnUpdate")] [HarmonyPrefix] private static void Prefix(SortSingleInventorySystem __instance) { Drain(__instance); } private static void Drain(SortSingleInventorySystem system) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) EntityQuery eventQuery = system._EventQuery; NativeArray val = ((EntityQuery)(ref eventQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { double serverTime = Core.ServerTime; DropStale(stashArmed, serverTime); DropStale(trashArmed, serverTime); for (int i = 0; i < val.Length; i++) { Handle(val[i], serverTime); } } finally { val.Dispose(); } } private static void Handle(Entity entity, double now) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) if (((Entity)(ref entity)).Equals(Entity.Null)) { return; } FromCharacter val = entity.Read(); SortSingleInventoryEvent val2 = entity.Read(); ulong platformId = val.User.Read().PlatformId; if (val2.Inventory == val.Character.Read()) { if (Core.PlayerSettings.IsSortStashEnabled(platformId) && Armed(stashArmed, platformId, now)) { Core.Stash.StashCharacterInventory(val.Character); } } else { if (!Armed(trashArmed, platformId, now)) { return; } int territoryId = Core.TerritoryService.GetTerritoryId(val.Character); foreach (Entity item in Core.Stash.TrashChests(territoryId)) { if (item.Read() == val2.Inventory) { Core.Trash.EmptyTrash(val.Character, item); break; } } } } private static bool Armed(Dictionary clicks, ulong steam, double now) { if (clicks.TryGetValue(steam, out var value) && now - value < 1.0) { clicks.Remove(steam); return true; } clicks[steam] = now; return false; } private static void DropStale(Dictionary clicks, double now) { if (clicks.Count == 0) { return; } List list = null; foreach (KeyValuePair click in clicks) { if (now - click.Value >= 1.0) { (list ?? (list = new List())).Add(click.Key); } } if (list != null) { for (int i = 0; i < list.Count; i++) { clicks.Remove(list[i]); } } } } [HarmonyPatch(typeof(ToggleRefiningRecipeSystem), "OnUpdate")] internal static class ToggleRefiningRecipeSystemPatch { [HarmonyPrefix] private static void Prefix(ToggleRefiningRecipeSystem __instance) { Drain(__instance); } private static void Drain(ToggleRefiningRecipeSystem system) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized || Core.WorkQueue == null) { return; } EntityQuery eventQuery = system._EventQuery; NativeArray val = ((EntityQuery)(ref eventQuery)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val.Length; i++) { if (Core.TryGetEntityFromNetworkId(val[i].RefinementStation, out var entity)) { Core.WorkQueue.EnqueueOwner(entity); } } } finally { val.Dispose(); } } } } namespace Satisvampory.Commands { [CommandGroup("satisvampory", "s")] public static class CastleCommands { private static bool TryGetStandingCastleSettingsOwner(ChatCommandContext ctx, out ulong ownerPlatformId, out string ownerName, bool replyIfMissing = true) { return ItemGroupService.TryGetStandingCastleSettingsOwner(ctx, out ownerPlatformId, out ownerName, replyIfMissing); } private static bool TryGetCastleSettingsOwner(ChatCommandContext ctx, bool forSet, out ulong ownerPlatformId, out string ownerName, bool replyIfMissing = true) { return ItemGroupService.TryGetCastleSettingsOwner(ctx, forSet, out ownerPlatformId, out ownerName, replyIfMissing); } private static bool HandleAmbiguousTarget(ChatCommandContext ctx, FoundItemOrGroup target, PendingItemCommand command, int amount = 0, string groupName = null) { if (target.IsGroup || !target.Item.Ambiguous) { return false; } return LogisticsCommands.HandleAmbiguousItem(ctx, target.Item, command, amount, groupName); } [Command("help", "h", ".s help", "Satisvampory commands. Scopes: you, plot, castle, clan, server.", null, false)] public static void ShowHelp(ChatCommandContext ctx) { ctx.Reply("Satisvampory prefix .s admin .sg (full list: COMMANDS.md)"); ctx.Reply("YOU scoop: .s / .scoop .s auto .s radius .s exclude .s bagcap .s mode bags|guild .s notify"); ctx.Reply("YOU stash/pull (dest is plot, or clan if .s cs on): .stash .pull plank 50 .fi .fc .s tidy .s ss .s cr .s co .s rrglobal"); ctx.Reply("CASTLE (stand on the plot, stored on heart owner): .s reserve .s reserve plank 50 .s cap .s group. Not leftover. .pull ignores reserve; craft-pull/conveyors honor it."); ctx.Reply("PLOT (feet): .s sal salvage .s hf heart feed .s cse exclude this plot (owner only)"); ctx.Reply("CLAN: .s cs all clan plots as one. .s rh repeat hunts per castle. SERVER admin: .sg s .sg rh .sg sal (need adminauth). Player toggles still start off except scoop auto and .s dpl."); ctx.Reply("Example: .s bagcap cotton 200 then .s — your bags. .s cap cotton 200 — castle conveyors."); ctx.Reply("Example: .s reserve plank 50 then .pull plank 200 — pull ignores reserve. Name chests s1/r1 then .s co."); ctx.Reply("Ambiguous names: numbered list, then .s 2 or .s pick 2. .s settings .s conv plank .s need"); } [Command("pick", "p", ".s pick ", "Pick a numbered item from the last ambiguous name search.", null, false)] public static void PickPending(ChatCommandContext ctx, int number) { LogisticsCommands.ReplayPendingPick(ctx, number); } [Command("clanshare", "cs", ".s clanshare", "Toggle clan-wide sharing of pull/stash/find/caps/conveyors and vanilla treasury for ALL clan members and ALL clan plots. OFF by default. Items will move between clan castles.", null, false)] public unsafe static void ToggleClanShareCmd(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) User user = ctx.Event.User; string value = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrWhiteSpace(value)) { value = user.PlatformId.ToString(); } if (!Core.TerritoryService.TryGetClanKey(user, out var key)) { ctx.Reply("ClanShare is clan-wide. Join or create a clan first."); return; } bool current = Core.TerritoryService.IsClanShareOn(user); bool flag = Core.PlayerSettings.ToggleClanShareForClan(key, current); ctx.Reply($"ClanShare is now {(flag ? "ON" : "OFF")} for the whole clan (all members, all castles, including {value}'s)."); ctx.Reply("OFF by default. When ON, pull, stash, finditem, craft-pull, cap counts, conveyors, and vanilla treasury floors use all clan plots except owner-excluded ones (.s cse). Works from the wild. New plots are included automatically. Items will move between clan castles."); } [Command("csexclude", "cse", ".s cse", "Owner-only: exclude or include THIS plot from clan-wide ClanShare. Standing on an excluded plot is local-only.", null, false)] public static void ToggleClanShareExcludeCmd(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) int territoryId = Core.TerritoryService.GetTerritoryId(ctx.Event.SenderCharacterEntity); ulong platformId; if (territoryId < 0) { ctx.Reply("You must stand on a claimed castle plot you own to exclude it from ClanShare."); } else if (!Core.TerritoryService.TryGetTerritoryOwnerPlatformId(territoryId, out platformId)) { ctx.Reply("You must stand on a claimed castle plot you own to exclude it from ClanShare."); } else if (ctx.Event.User.PlatformId != platformId) { ctx.Reply("You must own this plot to exclude it from ClanShare. Clanmates and allies cannot exclude someone else's castle."); } else if (Core.PlayerSettings.ToggleTerritoryClanShareExclude(territoryId)) { ctx.Reply("This plot is now EXCLUDED from ClanShare. Other clan plots will not pull/stash/lend from it. Standing here is local-only (this castle alone)."); } else { ctx.Reply("This plot is now INCLUDED in ClanShare (clan-wide CS still has to be ON)."); } } [Command("rh", null, ".s rh [all|on|off|n]", "List castle repeat-hunt status. .s rh all enables all. .s rh off this castle. .s rh 2 toggles that row.", null, false)] public static void RepeatHuntCastleCmd(ChatCommandContext ctx, string arg = null) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { ctx.Reply("Satisvampory is not initialized yet."); } else { ctx.Reply(RepeatHunts.ChatRh(ctx.Event.SenderCharacterEntity, ctx.Event.User, arg)); } } [Command("throne", null, ".s throne [n|here]", "ClanShare: pick which clan plot the next hunt map click sends from. Stay on this throne.", null, false)] public static void ThronePlotCmd(ChatCommandContext ctx, string plot = null) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { ctx.Reply("Satisvampory is not initialized yet."); } else { ctx.Reply(ClanThroneServants.ChatSelect(ctx.Event.SenderCharacterEntity, ctx.Event.User.PlatformId, plot)); } } [Command("hunt", null, ".s hunt [1] [2] [3]", "ClanShare: pick up to 3 servants on the managed plot, then click a discovered zone on this throne's map.", null, false)] public static void HuntCmd(ChatCommandContext ctx, int first = 0, int second = 0, int third = 0) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { ctx.Reply("Satisvampory is not initialized yet."); return; } string text = null; if (first > 0) { text = first.ToString(); if (second > 0) { text = text + " " + second; } if (third > 0) { text = text + " " + third; } } ctx.Reply(ClanThroneServants.ChatHunt(ctx.Event.SenderCharacterEntity, ctx.Event.User.PlatformId, text)); } [Command("guildshare", "gs", ".s guildshare", "Same as .s clanshare. OFF by default.", null, false)] public static void ToggleGuildShareCmd(ChatCommandContext ctx) { ToggleClanShareCmd(ctx); } [Command("finditem", "fi", ".s fi ", "Finds the item in chests. Shows the plot you are standing on. ClanShare ON: groups by plot and heart level.", null, false)] public static void FindItemAlias(ChatCommandContext ctx, FoundItem item) { InventoryCommands.LocateItem(ctx, item); } [Command("rrglobal", "rrg", ".s rrglobal", "Toggle RR/stash off-plot. OFF by default. Does not change on-plot dest: ClanShare still dumps to all clan plots as one.", null, false)] public static void ToggleRrGlobal(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.Event.User.PlatformId; bool flag = Core.PlayerSettings.ToggleRrGlobal(platformId); bool flag2 = Core.PlayerSettings.IsRrGlobalServerAllowed(); ctx.Reply($"RR global is {(flag ? "enabled" : "disabled")} (default off). Off-plot RR/stash: {((flag && flag2) ? "allowed" : "blocked")}. On-plot dest is ClanShare (all clan plots as one), not this flag."); if (flag && !flag2) { ctx.Reply("Server RR global is off (.sg rrglobal). Off-plot RR blocked."); } } [Command("reserve", "rsv", ".s reserve [amount]", "Show or set the default reserve. 0 disables reserve.", null, false)] public static void SetReserve(ChatCommandContext ctx, int? amount = null) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!TryGetCastleSettingsOwner(ctx, amount.HasValue, out var ownerPlatformId, out var ownerName)) { return; } if (!amount.HasValue) { int pullReserve = Core.PlayerSettings.GetPullReserve(ownerPlatformId); ctx.Reply("Castle reserves (" + ownerName + "):"); ctx.Reply($"Default reserve is {pullReserve} (0 disables reserve)."); bool flag = false; foreach (var (value, value2) in Core.PlayerSettings.ListItemReserves(ownerPlatformId)) { if (!flag) { ctx.Reply("Item reserves:"); flag = true; } ctx.Reply($" {value}: leave {value2}"); } if (!flag) { ctx.Reply("No per-item reserves set. Use .s reserve to add one."); } } else { int num = Core.PlayerSettings.SetPullReserve(ownerPlatformId, amount.Value); ctx.Reply($"Set default reserve to {num} on {ownerName}'s castle. DontPullLast is {((num > 0) ? "enabled" : "disabled")}."); } } [Command("reserve", "rsv", ".s reserve ", "Show reserve for a specific item or material group.", null, false)] public static void ShowItemReserve(ChatCommandContext ctx, FoundItemOrGroup target) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!HandleAmbiguousTarget(ctx, target, PendingItemCommand.ReserveShow) && TryGetCastleSettingsOwner(ctx, forSet: false, out var ownerPlatformId, out var ownerName)) { if (target.IsGroup) { ReplyGroupAmounts(ctx, ownerPlatformId, ownerName, target.GroupName, isCap: false); return; } string value = target.Item.prefab.PrefabName(); int pullReserve = Core.PlayerSettings.GetPullReserve(ownerPlatformId, target.Item.prefab); int value2 = PullService.CountAlliedStores(ctx.Event.SenderCharacterEntity, target.Item.prefab); int value3 = PullService.CountAlliedTakeable(ctx.Event.SenderCharacterEntity, target.Item.prefab, ownerPlatformId); ctx.Reply($"Reserve for {value} is {pullReserve} on {ownerName}'s castle. Stores: {value2} (takeable {value3}). Clear this override with .s rsvc {value} or .s reserve \"{value}\" -1."); } } [Command("reserve", "rsv", ".s reserve ", "Set reserve for an item or every item in a material group. Use -1 to clear the override.", null, false)] public static void SetItemReserveCmd(ChatCommandContext ctx, FoundItemOrGroup target, int amount) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (HandleAmbiguousTarget(ctx, target, PendingItemCommand.ReserveSet, amount) || !TryGetCastleSettingsOwner(ctx, forSet: true, out var ownerPlatformId, out var ownerName)) { return; } if (target.IsGroup) { ApplyGroupAmount(ctx, ownerPlatformId, ownerName, target.GroupName, amount, isCap: false); return; } string text = target.Item.prefab.PrefabName(); if (amount < 0) { if (Core.PlayerSettings.ClearItemReserve(ownerPlatformId, target.Item.prefab)) { ctx.Reply($"Cleared reserve override for {text} on {ownerName}'s castle; now uses the default."); } else { ctx.Reply($"No reserve override for {text} on {ownerName}'s castle."); } } else { int value = Core.PlayerSettings.SetItemReserve(ownerPlatformId, target.Item.prefab, text, amount); ctx.Reply($"Set {text} reserve to {value} on {ownerName}'s castle."); } } [Command("reserveclear", "rsvc", ".s reserveclear ", "Clear a per-item reserve override so it uses the default.", null, false)] public static void ClearItemReserveCmd(ChatCommandContext ctx, FoundItem item) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!LogisticsCommands.HandleAmbiguousItem(ctx, item, PendingItemCommand.ReserveClear) && TryGetCastleSettingsOwner(ctx, forSet: true, out var ownerPlatformId, out var ownerName)) { string value = item.prefab.PrefabName(); if (Core.PlayerSettings.ClearItemReserve(ownerPlatformId, item.prefab)) { ctx.Reply($"Cleared reserve override for {value} on {ownerName}'s castle; now uses the default."); } else { ctx.Reply($"No reserve override for {value} on {ownerName}'s castle."); } } } [Command("cap", "c", ".s cap", "List production caps. Conveyors stop feeding an item once the plot has this many.", null, false)] public static void ListCaps(ChatCommandContext ctx) { if (!TryGetCastleSettingsOwner(ctx, forSet: false, out var ownerPlatformId, out var ownerName)) { return; } bool flag = false; foreach (var (value, value2) in Core.PlayerSettings.ListItemCaps(ownerPlatformId)) { if (!flag) { ctx.Reply("Castle production caps (" + ownerName + "):"); flag = true; } ctx.Reply($" {value}: stop at {value2}"); } if (!flag) { ctx.Reply("No production caps set on " + ownerName + "'s castle. Use .s cap to add one. 0 = make none, -1 = unlimited."); } } [Command("cap", "c", ".s cap ", "Show the production cap for a specific item or material group.", null, false)] public static void ShowItemCap(ChatCommandContext ctx, FoundItemOrGroup target) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) if (HandleAmbiguousTarget(ctx, target, PendingItemCommand.CapShow) || !TryGetCastleSettingsOwner(ctx, forSet: false, out var ownerPlatformId, out var ownerName)) { return; } if (target.IsGroup) { ReplyGroupAmounts(ctx, ownerPlatformId, ownerName, target.GroupName, isCap: true); return; } string value = target.Item.prefab.PrefabName(); if (!Core.PlayerSettings.TryGetItemCap(ownerPlatformId, target.Item.prefab, out var cap)) { ctx.Reply($"No production cap for {value} on {ownerName}'s castle (unlimited). Set with .s cap \"{value}\" ."); } else { ctx.Reply($"Production cap for {value} is {cap} on {ownerName}'s castle. Clear with .s capc {value} or .s cap \"{value}\" -1."); } IReadOnlyList logisticsTerritoryIdsForCharacter = Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(ctx.Event.SenderCharacterEntity); if (logisticsTerritoryIdsForCharacter.Count <= 0 || Core.ConveyorService == null) { return; } int num = 0; foreach (int item in logisticsTerritoryIdsForCharacter) { Core.ConveyorService.CountTerritoryItems(item).TryGetValue(target.Item.prefab, out var value2); num += value2; } string value3 = ((logisticsTerritoryIdsForCharacter.Count > 1) ? "Clan plots currently have" : "This territory currently has"); ctx.Reply($"{value3} {num}."); } [Command("cap", "c", ".s cap ", "Set a production cap for an item or every item in a material group. 0 = make none. -1 = unlimited.", null, false)] public static void SetItemCapCmd(ChatCommandContext ctx, FoundItemOrGroup target, int amount) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (HandleAmbiguousTarget(ctx, target, PendingItemCommand.CapSet, amount) || !TryGetCastleSettingsOwner(ctx, forSet: true, out var ownerPlatformId, out var ownerName)) { return; } if (target.IsGroup) { ApplyGroupAmount(ctx, ownerPlatformId, ownerName, target.GroupName, amount, isCap: true); return; } string text = target.Item.prefab.PrefabName(); if (amount < 0) { if (Core.PlayerSettings.ClearItemCap(ownerPlatformId, target.Item.prefab)) { ctx.Reply($"Cleared production cap for {text} on {ownerName}'s castle; now unlimited."); } else { ctx.Reply($"No production cap for {text} on {ownerName}'s castle."); } } else { int value = Core.PlayerSettings.SetItemCap(ownerPlatformId, target.Item.prefab, text, amount); ctx.Reply($"Set {text} production cap to {value} on {ownerName}'s castle."); } } [Command("capclear", "capc", ".s capclear ", "Clear a production cap so the item is unlimited.", null, false)] public static void ClearItemCapCmd(ChatCommandContext ctx, FoundItem item) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!LogisticsCommands.HandleAmbiguousItem(ctx, item, PendingItemCommand.CapClear) && TryGetCastleSettingsOwner(ctx, forSet: true, out var ownerPlatformId, out var ownerName)) { string value = item.prefab.PrefabName(); if (Core.PlayerSettings.ClearItemCap(ownerPlatformId, item.prefab)) { ctx.Reply($"Cleared production cap for {value} on {ownerName}'s castle; now unlimited."); } else { ctx.Reply($"No production cap for {value} on {ownerName}'s castle."); } } } [Command("group", null, ".s group", "List built-in and custom material groups on this castle.", null, false)] public static void ListGroups(ChatCommandContext ctx) { if (!TryGetStandingCastleSettingsOwner(ctx, out var ownerPlatformId, out var ownerName)) { return; } ctx.Reply("Material groups on " + ownerName + "'s castle:"); foreach (string builtInName in ItemGroupService.BuiltInNames) { if (!ItemGroupService.IsDeletedBuiltIn(ownerPlatformId, builtInName)) { List list = ItemGroupService.ResolveMembers(ownerPlatformId, builtInName); string value = (ItemGroupService.HasCastleOverlay(ownerPlatformId, builtInName) ? ", edited" : ""); ctx.Reply($" {builtInName} (built-in{value}, {list.Count} items)"); } } bool flag = false; foreach (var item2 in Core.PlayerSettings.ListCustomGroups(ownerPlatformId)) { string item = item2.name; if (!ItemGroupService.IsBuiltInName(item)) { if (!flag) { ctx.Reply("Custom groups:"); flag = true; } List list2 = ItemGroupService.ResolveMembers(ownerPlatformId, item); ctx.Reply($" {item} ({list2.Count} items)"); } } if (!flag) { ctx.Reply("No custom groups. Use .s group create then .s group add ."); } } [Command("group", null, ".s group ", "List group members with island totals and a grand total.", null, false)] public static void ShowGroup(ChatCommandContext ctx, string name) { ShowGroup(ctx, name, null); } [Command("group", null, ".s group full", "Same as .s group , plus each item's reserve and production cap.", null, false)] public static void ShowGroup(ChatCommandContext ctx, string name, string option) { //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) if (!TryGetStandingCastleSettingsOwner(ctx, out var ownerPlatformId, out var ownerName)) { return; } if (name.Trim().Equals("restore", StringComparison.OrdinalIgnoreCase) && string.IsNullOrWhiteSpace(option)) { List values = Core.PlayerSettings.RestoreAllBuiltInGroups(ownerPlatformId, ItemGroupService.BuiltInNames); ctx.Reply($"Restored default groups on {ownerName}'s castle: {string.Join(", ", values)}. Custom groups were left as-is."); return; } bool flag = false; if (!string.IsNullOrWhiteSpace(option)) { bool flag2; switch (name.Trim().ToLowerInvariant()) { case "create": case "delete": case "remove": case "del": case "new": case "addgroup": case "restore": flag2 = true; break; default: flag2 = false; break; } if (flag2) { CreateOrDeleteGroup(ctx, name, option); return; } switch (option.Trim().ToLowerInvariant()) { case "caps": case "full": case "more": case "adv": case "all": case "detail": case "advanced": flag2 = true; break; default: flag2 = false; break; } if (!flag2) { ctx.Reply("Usage: .s group or .s group full"); return; } flag = true; } if (!ItemGroupService.TryResolveGroup(ownerPlatformId, name, out var resolvedName, out var isBuiltIn)) { if (ItemGroupService.IsDeletedBuiltIn(ownerPlatformId, name)) { ctx.Reply($"Group {ItemGroupService.NormalizeName(name)} is gone on {ownerName}'s castle. Use .s group restore {ItemGroupService.NormalizeName(name)} to bring it back."); } else { ctx.Reply($"No group named {name} on {ownerName}'s castle."); } return; } List list = ItemGroupService.ResolveMembers(ownerPlatformId, resolvedName); string value = ((!isBuiltIn) ? "custom" : (ItemGroupService.HasCastleOverlay(ownerPlatformId, resolvedName) ? "edited built-in" : "built-in")); string value2 = ((Core.TerritoryService.GetLogisticsTerritoryIdsForCharacter(ctx.Event.SenderCharacterEntity).Count > 1) ? "clan island" : "this plot"); ctx.Reply($"{value} group {resolvedName} on {ownerName}'s castle ({list.Count} items, {value2}):"); if (list.Count == 0) { ctx.Reply(" (empty)"); return; } List<(string, int, int, string)> list2 = new List<(string, int, int, string)>(list.Count); int num = 0; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; for (int i = 0; i < list.Count; i++) { ItemGroupService.GroupMember groupMember = list[i]; int num2 = PullService.CountAlliedStores(senderCharacterEntity, groupMember.Prefab); num += num2; int pullReserve = Core.PlayerSettings.GetPullReserve(ownerPlatformId, groupMember.Prefab); int cap; string item = (Core.PlayerSettings.TryGetItemCap(ownerPlatformId, groupMember.Prefab, out cap) ? cap.ToString() : "unlimited"); list2.Add((groupMember.Name, num2, pullReserve, item)); } list2.Sort(delegate((string name, int have, int reserve, string cap) a, (string name, int have, int reserve, string cap) b) { int num4 = b.have.CompareTo(a.have); return (num4 == 0) ? string.Compare(a.name, b.name, StringComparison.OrdinalIgnoreCase) : num4; }); for (int num3 = 0; num3 < list2.Count; num3++) { (string, int, int, string) tuple = list2[num3]; if (flag) { ctx.Reply($" {tuple.Item1}: {tuple.Item2} reserve {tuple.Item3} cap {tuple.Item4}"); } else { ctx.Reply($" {tuple.Item1}: {tuple.Item2}"); } } ctx.Reply($"total: {num} ({list2.Count} kinds)"); } [Command("group", null, ".s group create|delete|restore ", "Create a custom group, delete a group, or restore a built-in default.", null, false)] public static void CreateOrDeleteGroup(ChatCommandContext ctx, string action, string name) { if (!TryGetStandingCastleSettingsOwner(ctx, out var ownerPlatformId, out var ownerName)) { return; } action = action.Trim().ToLowerInvariant(); string canonical = ItemGroupService.NormalizeName(name); bool flag; switch (action) { case "create": case "addgroup": case "new": flag = true; break; default: flag = false; break; } if (flag) { if (ItemGroupService.IsBuiltInName(canonical)) { ctx.Reply("" + canonical + " is a built-in group name and cannot be created."); } else if (ItemGroupService.IsExactItemName(canonical)) { ctx.Reply("" + canonical + " is an item name. Use a different group name."); } else if (Core.PlayerSettings.HasItemGroup(ownerPlatformId, canonical)) { ctx.Reply($"Custom group {canonical} already exists on {ownerName}'s castle."); } else { Core.PlayerSettings.CreateItemGroup(ownerPlatformId, canonical); ctx.Reply($"Created custom group {canonical} on {ownerName}'s castle. Add items with .s group {canonical} add ."); } return; } switch (action) { case "delete": case "remove": case "del": flag = true; break; default: flag = false; break; } if (flag) { if (ItemGroupService.IsBuiltInName(canonical)) { ItemGroupService.TryGetBuiltInCanonical(canonical, out canonical); if (ItemGroupService.IsDeletedBuiltIn(ownerPlatformId, canonical)) { ctx.Reply($"Group {canonical} is already gone on {ownerName}'s castle."); } else { Core.PlayerSettings.DeleteBuiltInGroup(ownerPlatformId, canonical); ctx.Reply($"Deleted built-in group {canonical} on {ownerName}'s castle. Restore with .s group restore {canonical}."); } } else if (!Core.PlayerSettings.DeleteItemGroup(ownerPlatformId, canonical)) { ctx.Reply($"No custom group named {canonical} on {ownerName}'s castle."); } else { ctx.Reply($"Deleted custom group {canonical} on {ownerName}'s castle."); } } else if (action == "restore") { if (!ItemGroupService.IsBuiltInName(canonical)) { ctx.Reply("" + canonical + " is not a default group. Only built-in groups can be restored."); return; } ItemGroupService.TryGetBuiltInCanonical(canonical, out canonical); Core.PlayerSettings.RestoreBuiltInGroup(ownerPlatformId, canonical); List list = ItemGroupService.ResolveMembers(ownerPlatformId, canonical); ctx.Reply($"Restored default group {canonical} on {ownerName}'s castle ({list.Count} items)."); } else { ctx.Reply("Usage: .s group create , .s group delete , or .s group restore [name]."); } } [Command("group", null, ".s group add|remove [ ...]", "Add or remove one or more items on a group. Quote names with spaces. First edit of a built-in copies the default list.", null, false)] public static void ModifyGroup(ChatCommandContext ctx, string name, string action, string item1, string item2 = null, string item3 = null, string item4 = null, string item5 = null, string item6 = null, string item7 = null, string item8 = null, string item9 = null, string item10 = null, string item11 = null, string item12 = null, string item13 = null, string item14 = null, string item15 = null, string item16 = null) { action = action.Trim().ToLowerInvariant(); if ((!(action == "add") && !(action == "remove")) || 1 == 0) { ctx.Reply("Usage: .s group add [ ...] or .s group remove [ ...]. Quote names with spaces."); return; } List list = new List(); string message = ctx.Event.Message; if (!string.IsNullOrWhiteSpace(message)) { List list2 = ItemGroupService.ParseItemTokens(message); int num = 0; if (list2.Count > 0 && list2[0].StartsWith(".", StringComparison.Ordinal)) { num = 1; } if (num < list2.Count && list2[num].Equals("l", StringComparison.OrdinalIgnoreCase)) { num++; } else if (num < list2.Count && list2[num].Equals("logistics", StringComparison.OrdinalIgnoreCase)) { num++; } if (num < list2.Count && list2[num].Equals("group", StringComparison.OrdinalIgnoreCase)) { num++; } if (num < list2.Count && list2[num].Equals(name, StringComparison.OrdinalIgnoreCase)) { num++; } if (num < list2.Count && list2[num].Equals(action, StringComparison.OrdinalIgnoreCase)) { num++; } for (int i = num; i < list2.Count; i++) { if (!string.IsNullOrWhiteSpace(list2[i])) { list.Add(list2[i]); } } } if (list.Count == 0) { string[] array = new string[16] { item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16 }; foreach (string text in array) { if (!string.IsNullOrWhiteSpace(text)) { list.Add(text); } } } if (list.Count == 0) { ctx.Reply("Usage: .s group add [ ...] or .s group remove [ ...]. Quote names with spaces."); } else { ApplyGroupItemTokens(ctx, name, action, list); } } internal static void ApplyGroupItemTokens(ChatCommandContext ctx, string name, string action, List tokens) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) if (!TryGetStandingCastleSettingsOwner(ctx, out var ownerPlatformId, out var ownerName) || !TryPrepareGroupEdit(ctx, ownerPlatformId, ownerName, name, out var normalized)) { return; } List<(PrefabGUID, string)> list = new List<(PrefabGUID, string)>(); HashSet hashSet = new HashSet(); string text = null; List<(PrefabGUID, string)> candidates = null; List list2 = new List(); List list3 = new List(); foreach (string token in tokens) { FoundItem item; List<(PrefabGUID, string)> candidates2; switch (FoundItemConverter.TryResolve(token, out item, out candidates2)) { case ItemResolveStatus.None: list2.Add(token); continue; case ItemResolveStatus.Ambiguous: if (text == null) { text = token; candidates = candidates2; } else { list3.Add(token); } continue; } PrefabGUID prefab = item.prefab; if (hashSet.Add(((PrefabGUID)(ref prefab)).GuidHash)) { string text2 = item.prefab.PrefabName(); if (string.IsNullOrEmpty(text2)) { text2 = token; } list.Add((item.prefab, text2)); } } ApplyResolvedGroupItems(ctx, normalized, action, list, ownerAlreadyChecked: true, ownerPlatformId, ownerName); if (list2.Count > 0) { ctx.Reply("No items found matching: " + string.Join(", ", list2)); } if (list3.Count > 0) { ctx.Reply("Also ambiguous (be more specific): " + string.Join(", ", list3)); } if (text != null) { PendingItemChoiceService.BeginAmbiguous(ctx.Event.User.PlatformId, candidates); PendingItemCommand command = ((action == "remove") ? PendingItemCommand.GroupRemove : PendingItemCommand.GroupAdd); PendingItemChoiceService.AttachCommand(ctx.Event.User.PlatformId, command, 0, normalized); ctx.Reply("Multiple matches for " + text + ". Unique matches were applied."); PendingItemChoiceService.ReplyNumberedList(ctx); } } private static bool TryPrepareGroupEdit(ChatCommandContext ctx, ulong steamId, string ownerName, string name, out string normalized) { normalized = ItemGroupService.NormalizeName(name); if (ItemGroupService.IsDeletedBuiltIn(steamId, normalized)) { ItemGroupService.TryGetBuiltInCanonical(normalized, out normalized); ctx.Reply($"Group {normalized} is gone on {ownerName}'s castle. Use .s group restore {normalized} to bring it back."); return false; } bool flag = ItemGroupService.IsBuiltInName(normalized); if (!flag && !Core.PlayerSettings.HasItemGroup(steamId, normalized)) { ctx.Reply($"No group named {normalized} on {ownerName}'s castle. Create one with .s group create {normalized}."); return false; } if (flag) { ItemGroupService.TryGetBuiltInCanonical(normalized, out normalized); ItemGroupService.EnsureCastleOverlay(steamId, normalized); } return true; } internal static void ApplyResolvedGroupItems(ChatCommandContext ctx, string name, string action, List<(PrefabGUID prefab, string name)> items, bool ownerAlreadyChecked = false, ulong steamId = 0uL, string ownerName = null) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) if ((!ownerAlreadyChecked && !TryGetStandingCastleSettingsOwner(ctx, out steamId, out ownerName)) || !TryPrepareGroupEdit(ctx, steamId, ownerName, name, out var normalized)) { return; } action = action.Trim().ToLowerInvariant(); List list = new List(); List list2 = new List(); HashSet hashSet = new HashSet(from m in ItemGroupService.ResolveMembers(steamId, normalized) select m.GuidHash); foreach (var item2 in items) { var (item, text) = item2; if (((PrefabGUID)(ref item)).GuidHash == 0) { continue; } if (action == "add") { if (hashSet.Contains(((PrefabGUID)(ref item)).GuidHash)) { list2.Add(text); continue; } Core.PlayerSettings.AddItemToGroup(steamId, normalized, item, text); hashSet.Add(((PrefabGUID)(ref item)).GuidHash); list.Add(text); } else if (action == "remove") { if (!hashSet.Contains(((PrefabGUID)(ref item)).GuidHash)) { list2.Add(text); continue; } Core.PlayerSettings.RemoveItemFromGroup(steamId, normalized, item); hashSet.Remove(((PrefabGUID)(ref item)).GuidHash); list.Add(text); } } if (list.Count > 0) { string value = ((action == "remove") ? "Removed" : "Added"); string value2 = ((action == "remove") ? "from" : "to"); string value3 = ((list.Count == 1) ? "item" : "items"); ctx.Reply($"{value} {list.Count} {value3} {value2} {normalized} on {ownerName}'s castle: {ItemGroupService.FormatMemberNames(list)}"); } else if (list2.Count > 0 && items.Count > 0) { if (action == "add") { ctx.Reply($"Already in {normalized} on {ownerName}'s castle: {ItemGroupService.FormatMemberNames(list2)}"); } else { ctx.Reply($"Not in {normalized} on {ownerName}'s castle: {ItemGroupService.FormatMemberNames(list2)}"); } } } private static void ApplyGroupAmount(ChatCommandContext ctx, ulong steamId, string ownerName, string groupName, int amount, bool isCap) { if (!ItemGroupService.TryResolveGroup(steamId, groupName, out groupName, out var _)) { ctx.Reply($"Group {groupName} is gone on {ownerName}'s castle."); return; } List list = ItemGroupService.ResolveMembers(steamId, groupName); if (list.Count == 0) { ctx.Reply($"Group {groupName} on {ownerName}'s castle has no items."); return; } List<(PrefabGUID, string)> items = list.Select((ItemGroupService.GroupMember m) => (Prefab: m.Prefab, Name: m.Name)).ToList(); int value = Core.PlayerSettings.ApplyGroupAmounts(steamId, items, isCap, amount); string value2 = ItemGroupService.FormatMemberNames(list.Select((ItemGroupService.GroupMember m) => m.Name)); if (isCap) { if (amount < 0) { ctx.Reply($"Cleared cap on {ownerName}'s castle for {groupName} ({value} items): {value2}"); } else { ctx.Reply($"Set cap {amount} on {ownerName}'s castle for {groupName} ({value} items): {value2}"); } } else if (amount < 0) { ctx.Reply($"Cleared reserve override on {ownerName}'s castle for {groupName} ({value} items): {value2}"); } else { ctx.Reply($"Set reserve {amount} on {ownerName}'s castle for {groupName} ({value} items): {value2}"); } } private static void ReplyGroupAmounts(ChatCommandContext ctx, ulong steamId, string ownerName, string groupName, bool isCap) { //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) if (!ItemGroupService.TryResolveGroup(steamId, groupName, out groupName, out var _)) { ctx.Reply($"Group {groupName} is gone on {ownerName}'s castle."); return; } List list = ItemGroupService.ResolveMembers(steamId, groupName); if (list.Count == 0) { ctx.Reply($"Group {groupName} on {ownerName}'s castle has no items."); return; } string value = (isCap ? "caps" : "reserves"); ctx.Reply($"{value} for {groupName} on {ownerName}'s castle ({list.Count} items):"); foreach (ItemGroupService.GroupMember item in list) { if (isCap) { if (Core.PlayerSettings.TryGetItemCap(steamId, item.Prefab, out var cap)) { ctx.Reply($" {item.Name}: stop at {cap}"); } else { ctx.Reply(" " + item.Name + ": unlimited"); } } else { int pullReserve = Core.PlayerSettings.GetPullReserve(steamId, item.Prefab); int value2 = PullService.CountAlliedStores(ctx.Event.SenderCharacterEntity, item.Prefab); int value3 = PullService.CountAlliedTakeable(ctx.Event.SenderCharacterEntity, item.Prefab, steamId); ctx.Reply($" {item.Name}: leave {pullReserve}. Stores: {value2} (takeable {value3})"); } } } [Command("conv", null, ".s conv ", "Troubleshoot conveyor for a crafted item (station, line, why not moving).", null, false)] public static void ConvTroubleshoot(ChatCommandContext ctx, FoundItem item) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (LogisticsCommands.HandleAmbiguousItem(ctx, item, PendingItemCommand.Conv)) { return; } int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(ctx.Event.SenderCharacterEntity); if (standingTerritoryId < 0) { ctx.Reply("You must stand on a castle plot to troubleshoot conveyors."); return; } if (Core.ConveyorService == null) { ctx.Reply("Satisvampory is not ready."); return; } foreach (string item2 in BeltInspect.Product(standingTerritoryId, item.prefab)) { ctx.Reply(item2); } } [Command("need", null, ".s need", "Top 10 items receiving stations want. Higher tier first, then lowest stock after reserve.", null, false)] public static void ConveyorNeed(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(ctx.Event.SenderCharacterEntity); if (standingTerritoryId < 0) { ctx.Reply("You must stand on a castle plot to list conveyor need."); return; } if (Core.ConveyorService == null) { ctx.Reply("Satisvampory is not ready."); return; } foreach (string item in BeltInspect.Need(standingTerritoryId)) { ctx.Reply(item); } } [Command("tidy", null, ".s tidy", "Restack chests onto better dests (same rank as .stash/RR: matching s# first). Never drains s#/r#, NS, skip-quotes, hearts. Treasury floor is a source. ClanShare ON: whole clan island.", null, false)] public static void TidyChests(ChatCommandContext ctx) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { ctx.Reply("Satisvampory is not initialized yet."); return; } Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; User user = ctx.Event.User; if (!ChestTidy.TryStart(senderCharacterEntity, user, out var deny)) { ctx.Reply(string.IsNullOrEmpty(deny) ? "Unable to tidy chests." : deny); return; } bool flag = Core.TerritoryService.IsClanShareOn(user); ctx.Reply(flag ? "Tidying chests on the clan island (named dests first). You will get a chat line when it finishes." : "Tidying chests on this plot (named dests first). You will get a chat line when it finishes."); } private static bool IsHeartOwnerOrClanmate(User player, User owner) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (player.PlatformId == owner.PlatformId) { return true; } Entity entityOnServer = ((NetworkedEntity)(ref player.ClanEntity)).GetEntityOnServer(); Entity entityOnServer2 = ((NetworkedEntity)(ref owner.ClanEntity)).GetEntityOnServer(); if (entityOnServer == Entity.Null || entityOnServer2 == Entity.Null) { return false; } return ((Entity)(ref entityOnServer)).Equals(entityOnServer2); } [Command("salvage", "sal", ".s sal", "Toggles salvage for the plot you are standing on. Clanmates of the heart owner can toggle it. Feeds a chest named 'salvage' into the Devourer.", null, false)] public static void ToggleSalvage(ChatCommandContext ctx) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown if (!TryGetStandingCastleSettingsOwner(ctx, out var ownerPlatformId, out var ownerName, replyIfMissing: false)) { ctx.Reply("You must stand on a claimed castle plot to toggle salvage for that plot."); return; } int territoryId = Core.TerritoryService.GetTerritoryId(ctx.Event.SenderCharacterEntity); Entity castleHeart = Core.TerritoryService.GetCastleHeart(territoryId); if (castleHeart == Entity.Null || !castleHeart.Has()) { ctx.Reply("You must stand on a claimed castle plot to toggle salvage for that plot."); return; } UserOwner val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer == Entity.Null || !entityOnServer.Has()) { ctx.Reply("You must stand on a claimed castle plot to toggle salvage for that plot."); return; } User owner = entityOnServer.Read(); if (!IsHeartOwnerOrClanmate(ctx.Event.User, owner)) { ctx.Reply("This is not your clan's plot."); return; } bool flag = Core.PlayerSettings.TogglePlotSalvage(ownerPlatformId, territoryId); bool num = Core.PlayerSettings.IsGlobalSalvageEnabled(); if (!num) { ManualLogSource log = Core.Log; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(93, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Salvage plot toggle t="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(territoryId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" owner="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ownerPlatformId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" plot="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(flag); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" but GLOBAL Salvage is off; ProcessSalvagers will not run."); } log.LogInfo(val2); } if (flag) { Core.WorkQueue?.Enqueue(territoryId); } string value = (flag ? "enabled" : "disabled"); if (!num) { ctx.Reply($"Salvage on this plot ({ownerName}) is {value}, but global salvage is Server Off. An admin must enable it with .sg sal."); } else { ctx.Reply($"Salvage on this plot ({ownerName}) is {value}."); } } [Command("heartfeed", "hf", ".s heartfeed", "Toggle castle-heart Blood Essence auto-feed on the plot you are standing on. ON by default.", null, false)] public static void ToggleHeartFeed(ChatCommandContext ctx) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (!TryGetStandingCastleSettingsOwner(ctx, out var ownerPlatformId, out var ownerName, replyIfMissing: false)) { ctx.Reply("You must stand on a claimed castle plot to toggle heart auto-feed for that plot."); return; } int territoryId = Core.TerritoryService.GetTerritoryId(ctx.Event.SenderCharacterEntity); Entity castleHeart = Core.TerritoryService.GetCastleHeart(territoryId); if (castleHeart == Entity.Null || !castleHeart.Has()) { ctx.Reply("You must stand on a claimed castle plot to toggle heart auto-feed for that plot."); return; } UserOwner val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer == Entity.Null || !entityOnServer.Has()) { ctx.Reply("You must stand on a claimed castle plot to toggle heart auto-feed for that plot."); return; } User owner = entityOnServer.Read(); if (!IsHeartOwnerOrClanmate(ctx.Event.User, owner)) { ctx.Reply("This is not your clan's plot."); return; } bool flag = Core.PlayerSettings.ToggleHeartFeed(ownerPlatformId, territoryId); ctx.Reply($"Heart auto-feed on this plot ({ownerName}) is {(flag ? "ON" : "OFF")} (ON by default; fills the heart fuel slots from clan treasury/unnamed, reserve honored)."); } [Command("diag", null, ".s diag", "Mark a diagnostic snapshot in the rolling log (dupe / missing items / lag). Tell an admin the time.", null, false)] public static void Diag(ChatCommandContext ctx) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { ctx.Reply("Satisvampory is not initialized yet."); return; } ulong platformId = ctx.Event.User.PlatformId; Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity; int standingTerritoryId = Core.TerritoryService.GetStandingTerritoryId(senderCharacterEntity); bool flag = Core.TerritoryService.IsClanShareOn(ctx.Event.User); int value = ((Core.WorkQueue != null) ? Core.WorkQueue.QueueDepth : 0); DestDebugLog.Note("diag", standingTerritoryId, platformId, $"cs={(flag ? "on" : "off")} queue={value} name={ctx.Event.User.CharacterName}"); ctx.Reply($"Logged diag steam={platformId} plot={standingTerritoryId} cs={(flag ? "on" : "off")} queue={value}. Admin: mailbox {{\"op\":\"log\",\"name\":\"diag\"}} or BepInEx/Log/Satisvampory.log"); } [Command("peek", null, ".s peek [plot]", "Write a live plot dump to BepInEx/config/Satisvampory/debug/res.json.", null, true)] public static void Peek(ChatCommandContext ctx, int plot = -1) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { ctx.Reply("Satisvampory is not initialized yet."); return; } if (plot < 0) { plot = Core.TerritoryService.GetStandingTerritoryId(ctx.Event.SenderCharacterEntity); } try { DebugPeekService.PeekNow(plot); ctx.Reply($"Wrote debug dump for plot {plot} to BepInEx/config/Satisvampory/debug/res.json"); } catch (Exception ex) { ctx.Reply("peek failed: " + ex.Message); } } internal static IEnumerable SettingsLines(ChatCommandContext ctx) { ulong platformId = ctx.Event.User.PlatformId; SettingsRow settings = Core.PlayerSettings.GetSettings(platformId); SettingsRow globalSettings = Core.PlayerSettings.GetGlobalSettings(); string leftoverLine = "DontPullLast: " + LogisticsCommands.OnOff(settings.DontPullLast); string capsLine = ""; string salvageLine = (globalSettings.Salvage ? "Salvage: stand on a claimed plot to view/toggle (.s sal)" : "Salvage: Server Off"); if (ItemGroupService.TryGetStandingCastleSettingsOwner(ctx, out var ownerPlatformId, out var ownerName, replyIfMissing: false)) { int pullReserve = Core.PlayerSettings.GetPullReserve(ownerPlatformId); int itemReserveOverrideCount = Core.PlayerSettings.GetItemReserveOverrideCount(ownerPlatformId); leftoverLine = leftoverLine + $" | Castle reserves ({ownerName}): leave {pullReserve}" + ((itemReserveOverrideCount > 0) ? $", {itemReserveOverrideCount} item override{((itemReserveOverrideCount == 1) ? "" : "s")}" : ""); int itemCapOverrideCount = Core.PlayerSettings.GetItemCapOverrideCount(ownerPlatformId); capsLine = "Castle caps (" + ownerName + "): " + ((itemCapOverrideCount > 0) ? $"{itemCapOverrideCount} item cap{((itemCapOverrideCount == 1) ? "" : "s")}" : "none"); int territoryId = Core.TerritoryService.GetTerritoryId(ctx.Event.SenderCharacterEntity); Entity castleHeart = Core.TerritoryService.GetCastleHeart(territoryId); bool flag = false; if (castleHeart != Entity.Null && castleHeart.Has()) { UserOwner val = castleHeart.Read(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer != Entity.Null && entityOnServer.Has()) { flag = Core.TerritoryService.IsClanShareOn(entityOnServer.Read()); } } bool flag2 = Core.PlayerSettings.IsTerritoryClanShareExcluded(territoryId); capsLine = capsLine + "\nClanShare (clan-wide): " + LogisticsCommands.OnOff(flag) + " (OFF by default; all members, all castles. .s cs)"; capsLine = capsLine + "\nRR global: " + LogisticsCommands.OnOff(Core.PlayerSettings.IsRrGlobalEnabled(platformId)) + " (OFF by default; only allows RR/stash off-plot. On-plot dest is ClanShare. .s rrglobal)"; capsLine += $"\nClanShare exclude (this plot, {ownerName}): {(flag2 ? "Excluded / local-only" : "Included")} (owner-only .s cse)"; bool plotSalvageFlag = Core.PlayerSettings.GetPlotSalvageFlag(ownerPlatformId, territoryId); salvageLine = ((!globalSettings.Salvage) ? $"Salvage (this plot, {ownerName}): {LogisticsCommands.OnOff(plotSalvageFlag)} | Server Off" : ("Salvage (this plot, " + ownerName + "): " + LogisticsCommands.OnOff(plotSalvageFlag))); salvageLine += $"\nHeartFeed (this plot, {ownerName}): {LogisticsCommands.OnOff(Core.PlayerSettings.IsHeartFeedEnabled(ownerPlatformId, territoryId))} (ON by default; .s hf)"; } yield return "Satisvampory Settings:"; yield return "SortStash: " + LogisticsCommands.CombinedFlag(globalSettings.SortStash, settings.SortStash); yield return "Pull (server): " + (globalSettings.Pull ? "Server On" : "Server Off"); yield return "CraftPull: " + LogisticsCommands.CombinedFlag(globalSettings.CraftPull, settings.CraftPull); yield return leftoverLine; if (capsLine.Length > 0) { yield return capsLine; } yield return "AutoStashMissions: " + LogisticsCommands.CombinedFlag(globalSettings.AutoStashMissions, settings.AutoStashMissions); yield return "Conveyor: " + LogisticsCommands.CombinedFlag(globalSettings.Conveyor, settings.Conveyor); yield return "ConveyorLoops: " + LogisticsCommands.OnOff(globalSettings.ConveyorLoops) + " (admin .sg convloop; default OFF)"; yield return ".s conv troubleshoot conveyor for a crafted item (station, line, why not moving)."; yield return salvageLine; yield return "UnitSpawner: " + LogisticsCommands.CombinedFlag(globalSettings.UnitSpawner, settings.UnitSpawner); yield return "Brazier: " + LogisticsCommands.CombinedFlag(globalSettings.Brazier, settings.Brazier) + " | Named: " + (globalSettings.Named ? "Server On" : "Server Off"); yield return "Silent pull " + LogisticsCommands.OnOff(settings.SilentPull) + " | stash " + LogisticsCommands.OnOff(settings.SilentStash); } [Command("catalog", "ic", ".s catalog", "Dump the live PrefabCollection item catalog to BepInEx\\Log\\item-catalog.csv without a restart.", null, false)] public static void DumpCatalog(ChatCommandContext ctx) { int value = ItemGroupService.DumpItemCatalog(); ctx.Reply($"Item catalog dumped {value} items to BepInEx\\Log\\item-catalog.csv (and Satisvampory-src if present). Dest groups are already live in memory."); IReadOnlyList missingRequestedNames = ItemGroupService.MissingRequestedNames; if (missingRequestedNames != null && missingRequestedNames.Count > 0) { ctx.Reply($"Unresolved dest names ({missingRequestedNames.Count}): {ItemGroupService.FormatMemberNames(missingRequestedNames, 280)}"); } else { ctx.Reply("Unresolved dest names: none (FakeItem_/Any* recipe placeholders omitted)."); } } } [CommandGroup("satisvampory", "s")] public static class LogisticsCommands { internal static void ReplyOnOff(ChatCommandContext ctx, string label, bool on) { ctx.Reply(label + " is " + (on ? "enabled" : "disabled") + "."); } internal static void FlipWake(ChatCommandContext ctx, string label, bool on) { if (on) { Core.WorkQueue?.EnqueueAll(); } ReplyOnOff(ctx, label, on); } internal static string OnOff(bool on) { if (!on) { return "Off"; } return "On"; } internal static string CombinedFlag(bool server, bool player) { if (!server) { return "Server Off"; } return OnOff(player); } internal static bool HandleAmbiguousItem(ChatCommandContext ctx, FoundItem item, PendingItemCommand command, int amount = 0, string groupName = null) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!item.Ambiguous) { return false; } PendingItemChoiceService.AttachCommand(ctx.Event.User.PlatformId, command, amount, groupName); PendingItemChoiceService.ReplyNumberedList(ctx); return true; } internal static void ReplayPendingPick(ChatCommandContext ctx, int number) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) if (ClanThroneServants.TryPickNumber(ctx.Event.SenderCharacterEntity, ctx.Event.User.PlatformId, number, out var reply)) { ctx.Reply(reply); return; } if (!PendingItemChoiceService.TryPick(ctx.Event.User.PlatformId, number, out PendingItemChoice choice, out (PrefabGUID, string) picked, out string error)) { ctx.Reply(error); return; } FoundItem item = new FoundItem(picked.Item1); string text = (string.IsNullOrEmpty(picked.Item2) ? item.prefab.PrefabName() : picked.Item2); PendingItemCommand command = choice.Command; if (command == PendingItemCommand.Pull) { ctx.Reply($"Using {text}. Pulling {choice.Amount}."); InventoryCommands.PullItem(ctx, item, choice.Amount); return; } ctx.Reply("Using " + text + "."); switch (command) { case PendingItemCommand.ReserveShow: CastleCommands.ShowItemReserve(ctx, FoundItemOrGroup.FromItem(item)); break; case PendingItemCommand.ReserveSet: CastleCommands.SetItemReserveCmd(ctx, FoundItemOrGroup.FromItem(item), choice.Amount); break; case PendingItemCommand.ReserveClear: CastleCommands.ClearItemReserveCmd(ctx, item); break; case PendingItemCommand.CapShow: CastleCommands.ShowItemCap(ctx, FoundItemOrGroup.FromItem(item)); break; case PendingItemCommand.CapSet: CastleCommands.SetItemCapCmd(ctx, FoundItemOrGroup.FromItem(item), choice.Amount); break; case PendingItemCommand.CapClear: CastleCommands.ClearItemCapCmd(ctx, item); break; case PendingItemCommand.GroupAdd: CastleCommands.ApplyResolvedGroupItems(ctx, choice.GroupName, "add", new List<(PrefabGUID, string)> { (item.prefab, text) }, ownerAlreadyChecked: false, 0uL); break; case PendingItemCommand.GroupRemove: CastleCommands.ApplyResolvedGroupItems(ctx, choice.GroupName, "remove", new List<(PrefabGUID, string)> { (item.prefab, text) }, ownerAlreadyChecked: false, 0uL); break; case PendingItemCommand.FindItem: InventoryCommands.LocateItem(ctx, item); break; case PendingItemCommand.AdminStash: InventoryCommands.GiveIntoPlot(ctx, item, choice.Amount); break; case PendingItemCommand.Conv: CastleCommands.ConvTroubleshoot(ctx, item); break; case PendingItemCommand.ExcludeToggle: ScoopCommands.DoExcludeToggle(ctx, item); break; case PendingItemCommand.BagCapShow: ScoopCommands.DoBagCapShow(ctx, item); break; case PendingItemCommand.BagCapSet: ScoopCommands.DoBagCapSet(ctx, item, choice.Amount); break; case PendingItemCommand.AliasAdd: LogisticsGlobal.FinishAliasAdd(ctx, choice.GroupName, item); break; } } [Command("verifyqueue", "vq", ".s vq", "Reports the logistics work queue depth and whether your territory is queued.", null, true)] public static void VerifyQueue(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) int territoryId = Core.TerritoryService.GetTerritoryId(ctx.Event.SenderCharacterEntity); WorkQueueService workQueue = Core.WorkQueue; bool flag = territoryId >= 0 && workQueue.IsQueued(territoryId); ctx.Reply($"Queue {workQueue.QueueDepth} deep. Standing plot {((territoryId < 0) ? "none" : territoryId.ToString())} is {(flag ? "queued" : "idle")}."); } [Command("settings", "s", ".s s", "Displays current settings.", null, false)] public static void DisplaySettings(ChatCommandContext ctx) { ctx.Reply(string.Join("\n", CastleCommands.SettingsLines(ctx))); } } [CommandGroup("satisvampory", "s")] public static class PlayerToggles { [Command("sortstash", "ss", ".s ss", "Toggles autostashing on double clicking sort button for player.", null, false)] public static void SortStash(ChatCommandContext ctx) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogisticsCommands.ReplyOnOff(ctx, "SortStash", Core.PlayerSettings.ToggleSortStash(ctx.Event.User.PlatformId)); } [Command("craftpull", "cr", ".s cr", "Toggles right-clicking on recipes for missing ingredients.", null, false)] public static void CraftPull(ChatCommandContext ctx) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogisticsCommands.ReplyOnOff(ctx, "CraftPull", Core.PlayerSettings.ToggleCraftPull(ctx.Event.User.PlatformId)); } [Command("dontpulllast", "dpl", ".s dpl", "Toggles the ability to not pull the last item from a container for Logistics commands.", null, false)] public static void DontPullLast(ChatCommandContext ctx) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogisticsCommands.ReplyOnOff(ctx, "DontPullLast", Core.PlayerSettings.ToggleDontPullLast(ctx.Event.User.PlatformId)); } [Command("autostashmissions", "asm", ".s asm", "Toggles autostashing for servant missions.", null, false)] public static void AutoStashMissions(ChatCommandContext ctx) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogisticsCommands.ReplyOnOff(ctx, "AutoStash for missions", Core.PlayerSettings.ToggleAutoStashMissions(ctx.Event.User.PlatformId)); } [Command("conveyor", "co", ".s co", "Toggles the ability of sender/receiver's to move items around.", null, false)] public static void Conveyor(ChatCommandContext ctx) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogisticsCommands.FlipWake(ctx, "Conveyor", Core.PlayerSettings.ToggleConveyor(ctx.Event.User.PlatformId)); } [Command("unitspawner", "us", ".s sp", "Toggles the ability to fill unit stations from a chest named 'spawner'.", null, false)] public static void UnitSpawner(ChatCommandContext ctx) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogisticsCommands.FlipWake(ctx, "Spawner", Core.PlayerSettings.ToggleUnitSpawner(ctx.Event.User.PlatformId)); } [Command("brazier", "bz", ".s bz", "Toggles the ability to fill braziers from a chest named 'brazier'.", null, false)] public static void Brazier(ChatCommandContext ctx) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogisticsCommands.FlipWake(ctx, "Brazier", Core.PlayerSettings.ToggleBrazier(ctx.Event.User.PlatformId)); } [Command("silentpull", "sp", null, "Hide dest-chest names when pulling.", null, false)] public static void SilentPull(ChatCommandContext ctx) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogisticsCommands.ReplyOnOff(ctx, "SilentPull", Core.PlayerSettings.ToggleSilentPull(ctx.Event.User.PlatformId)); } [Command("silentstash", "ssh", null, "Hide dest-chest names when stashing.", null, false)] public static void SilentStash(ChatCommandContext ctx) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogisticsCommands.ReplyOnOff(ctx, "SilentStash", Core.PlayerSettings.ToggleSilentStash(ctx.Event.User.PlatformId)); } } [CommandGroup("satisvamporyglobal", "sg")] public static class LogisticsGlobal { [Command("sortstash", "ss", ".sg ss", "Toggles autostashing on double clicking sort button for player.", null, true)] public static void GlobalSortStash(ChatCommandContext ctx) { LogisticsCommands.ReplyOnOff(ctx, "Global SortStash", Core.PlayerSettings.ToggleSortStash(0uL)); } [Command("rrglobal", "rrg", ".sg rrglobal", "Server allow for off-plot RR/stash. Default ON (player .s rrglobal still defaults OFF). Does not gate on-plot ClanShare dest.", null, true)] public static void ToggleGlobalRrGlobal(ChatCommandContext ctx) { bool flag = Core.PlayerSettings.ToggleRrGlobal(0uL); ctx.Reply("Server RR global allow is " + (flag ? "enabled" : "disabled") + " (player .s rrglobal still defaults off). Off-plot only; on-plot dest is ClanShare."); } [Command("pull", "p", ".sg p", "Toggles the ability to pull items from containers.", null, true)] public static void GlobalPull(ChatCommandContext ctx) { LogisticsCommands.ReplyOnOff(ctx, "Global Pull", Core.PlayerSettings.TogglePull()); } [Command("craftpull", "cr", ".sg cr", "Toggles right-clicking on recipes for missing ingredients.", null, true)] public static void GlobalCraftPull(ChatCommandContext ctx) { LogisticsCommands.ReplyOnOff(ctx, "CraftPull", Core.PlayerSettings.ToggleCraftPull(0uL)); } [Command("autostashmissions", "asm", ".sg asm", "Toggles autostashing for servant missions.", null, true)] public static void GlobalAutoStashMissions(ChatCommandContext ctx) { LogisticsCommands.ReplyOnOff(ctx, "Global AutoStash for missions", Core.PlayerSettings.ToggleAutoStashMissions(0uL)); } [Command("repeathunt", "rh", ".sg rh", "When ON, servants automatically go back out on the same hunt after they return. Default OFF. Captures hunts already out.", null, true)] public static void GlobalRepeatHunt(ChatCommandContext ctx) { LogisticsCommands.ReplyOnOff(ctx, "Repeat hunts", Core.PlayerSettings.ToggleRepeatHunt()); } [Command("rhmax", null, ".sg rhmax [1-100]", "Max success % for repeat hunts only (first send is vanilla). Default 99.", null, true)] public static void RepeatHuntMax(ChatCommandContext ctx, int? percent = null) { if (!percent.HasValue) { ctx.Reply("Repeat hunt max success is " + Core.PlayerSettings.GetRepeatHuntMaxSuccess() + "% (default 99). .sg rhmax 99"); } else { ctx.Reply("Repeat hunt max success is now " + Core.PlayerSettings.SetRepeatHuntMaxSuccess(percent.Value) + "%. First throne send is unchanged."); } } [Command("conveyor", "co", ".sg co", "Toggles the ability of sender/receiver's to move items around.", null, true)] public static void GlobalConveyor(ChatCommandContext ctx) { LogisticsCommands.FlipWake(ctx, "Global Conveyor", Core.PlayerSettings.ToggleConveyor(0uL)); } [Command("convloop", "cloop", ".sg convloop", "Allow s# chest → r# chest loops (dest is also s# on the same group). Default OFF.", null, true)] public static void ToggleConveyorLoops(ChatCommandContext ctx) { bool flag = Core.PlayerSettings.ToggleConveyorLoops(); if (flag) { Core.WorkQueue?.EnqueueAll(); } ctx.Reply("Conveyor chest loops are " + (flag ? "ON" : "OFF") + " (default OFF). OFF: s# chests fill r# chests unless that dest is also s# on the same group (cycle). ON: s#r# buffers may trade."); } [Command("salvage", "sal", ".sg sal", "Toggles the ability to salvage items from a chest named 'salvage'.", null, true)] public static void GlobalSalvage(ChatCommandContext ctx) { LogisticsCommands.FlipWake(ctx, "Global Salvage", Core.PlayerSettings.ToggleSalvage(0uL)); } [Command("unitspawner", "us", ".sg sp", "Toggles the ability to fill unit stations from a chest named 'spawner'.", null, true)] public static void GlobalUnitSpawner(ChatCommandContext ctx) { LogisticsCommands.FlipWake(ctx, "Global Spawner", Core.PlayerSettings.ToggleUnitSpawner(0uL)); } [Command("brazier", "bz", ".sg bz", "Toggles the ability to fill braziers from a chest named 'brazier'.", null, true)] public static void GlobalBrazier(ChatCommandContext ctx) { LogisticsCommands.FlipWake(ctx, "Global Brazier", Core.PlayerSettings.ToggleBrazier(0uL)); } [Command("named", "nam", ".sg nam", "Toggles the ability allow night/proximity controlled braziers.", null, true)] public static void GlobalNamed(ChatCommandContext ctx) { LogisticsCommands.ReplyOnOff(ctx, "Global Named", Core.PlayerSettings.ToggleSolar(0uL)); } [Command("trash", null, ".sg trash", "Toggles the ability to allowed trashes to delete contents.", null, true)] public static void GlobalTrash(ChatCommandContext ctx) { LogisticsCommands.ReplyOnOff(ctx, "Global Trash", Core.PlayerSettings.ToggleTrash()); } [Command("settings", "s", ".sg s", "Displays current settings.", null, true)] public static void ShowGlobal(ChatCommandContext ctx) { SettingsRow globalSettings = Core.PlayerSettings.GetGlobalSettings(); ctx.Reply("Satisvampory server flags:\nSortStash " + LogisticsCommands.OnOff(globalSettings.SortStash) + "\nPull " + LogisticsCommands.OnOff(globalSettings.Pull) + "\nCraftPull " + LogisticsCommands.OnOff(globalSettings.CraftPull) + "\nAutoStashMissions " + LogisticsCommands.OnOff(globalSettings.AutoStashMissions) + "\nRepeatHunt " + LogisticsCommands.OnOff(globalSettings.RepeatHunt) + " (default OFF; .sg rh) max " + Core.PlayerSettings.GetRepeatHuntMaxSuccess() + "% (.sg rhmax)\nConveyor " + LogisticsCommands.OnOff(globalSettings.Conveyor) + "\nConveyorLoops " + LogisticsCommands.OnOff(globalSettings.ConveyorLoops) + " (default OFF; .sg convloop)\nSalvage " + LogisticsCommands.OnOff(globalSettings.Salvage) + "\nUnitSpawner " + LogisticsCommands.OnOff(globalSettings.UnitSpawner) + "\nBrazier " + LogisticsCommands.OnOff(globalSettings.Brazier) + "\nNamed " + LogisticsCommands.OnOff(globalSettings.Named) + "\nTrash " + LogisticsCommands.OnOff(globalSettings.Trash)); } [Command("alias", null, ".sg alias", "List item aliases (BE, GBE, PBE, GSS, …).", null, true)] public static void ListAliases(ChatCommandContext ctx) { IReadOnlyList<(string, string, bool)> readOnlyList = ItemGroupService.ListExactAliases(); if (readOnlyList.Count == 0) { ctx.Reply("No item aliases. .sg alias add GSS \"Greater Stygian Shard\""); return; } ctx.Reply("Item aliases (find / pull / dest). Built-in cannot be deleted."); int num = 0; string text = ""; for (int i = 0; i < readOnlyList.Count; i++) { (string, string, bool) tuple = readOnlyList[i]; string text2 = "" + tuple.Item1 + "=" + tuple.Item2 + (tuple.Item3 ? " (built-in)" : ""); text = ((text.Length != 0) ? (text + " " + text2) : text2); num++; if (num >= 3 || i == readOnlyList.Count - 1) { ctx.Reply(text); text = ""; num = 0; } } ctx.Reply(".sg alias add .sg alias del "); } [Command("alias", null, ".sg alias add ", "Add an item alias for find / pull / dest names.", null, true)] public static void AddAlias(ChatCommandContext ctx, string action, string alias, FoundItem item) { if (!action.Equals("add", StringComparison.OrdinalIgnoreCase) && !action.Equals("set", StringComparison.OrdinalIgnoreCase)) { ctx.Reply("Use .sg alias add or .sg alias del ."); } else if (!LogisticsCommands.HandleAmbiguousItem(ctx, item, PendingItemCommand.AliasAdd, 0, alias)) { FinishAliasAdd(ctx, alias, item); } } [Command("alias", null, ".sg alias del ", "Remove an admin item alias. Built-ins stay.", null, true)] public static void DelAlias(ChatCommandContext ctx, string action, string alias) { if (!action.Equals("del", StringComparison.OrdinalIgnoreCase) && !action.Equals("rm", StringComparison.OrdinalIgnoreCase) && !action.Equals("remove", StringComparison.OrdinalIgnoreCase)) { ctx.Reply("Use .sg alias add or .sg alias del ."); return; } string text = ItemGroupService.UnbindAdminAlias(alias); if (!string.IsNullOrEmpty(text)) { ctx.Reply(text); } else { ctx.Reply("Removed alias " + FoundItemConverter.Normalize(alias) + "."); } } internal static void FinishAliasAdd(ChatCommandContext ctx, string alias, FoundItem item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) PrefabGUID prefab = item.prefab; if (((PrefabGUID)(ref prefab)).GuidHash == 0) { ctx.Reply("Unknown item."); return; } string text = item.prefab.PrefabName() ?? alias; string text2 = ItemGroupService.BindAdminAlias(alias, item.prefab, text); if (!string.IsNullOrEmpty(text2)) { ctx.Reply(text2); return; } ctx.Reply("Alias " + FoundItemConverter.Normalize(alias) + " → " + text + ". Works for .fi / .pull / dest names."); } } public static class InventoryCommands { [Command("stash", null, null, "Dump inventory into dest chests (ClanShare island if .s cs on).", null, false)] public static void StashNow(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Core.Stash.StashCharacterInventory(ctx.Event.SenderCharacterEntity); } [Command("l", null, ".s ", "Pick a numbered item from the last ambiguous name search.", null, false)] public static void PickItemByNumber(ChatCommandContext ctx, int number) { LogisticsCommands.ReplayPendingPick(ctx, number); } [Command("pull", null, null, "Pull an item from dest chests on this plot or clan island.", null, false)] public static void PullItem(ChatCommandContext ctx, FoundItem item, int quantity = 1) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!LogisticsCommands.HandleAmbiguousItem(ctx, item, PendingItemCommand.Pull, quantity)) { PlayerWithdraw.Pull(ctx.Event.SenderCharacterEntity, item.prefab, quantity); } } [Command("finditem", "fi", null, "Finds the item in chests. Shows the plot you are standing on. ClanShare ON: groups by plot and heart level.", null, false)] public static void LocateItem(ChatCommandContext ctx, FoundItem item) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!LogisticsCommands.HandleAmbiguousItem(ctx, item, PendingItemCommand.FindItem)) { Core.Stash.ShowItems(ctx.Event.SenderCharacterEntity, item.prefab); } } [Command("findchest", "fc", null, "Finds chests by name. Shows the plot you are standing on. ClanShare ON: groups by plot and heart level.", null, false)] public static void LocateChest(ChatCommandContext ctx, string name) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Core.Stash.ShowChests(ctx.Event.SenderCharacterEntity, name); } [Command("emptytrash", null, null, "Empty every trash chest on this plot.", null, true)] public static void AshTrash(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Core.Trash.AshAll(ctx.Event.SenderCharacterEntity); } [Command("adminstash", null, null, "Admin: spawn items into the standing plot dests.", null, true)] public static void GiveIntoPlot(ChatCommandContext ctx, FoundItem item, int quantity = 1) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!LogisticsCommands.HandleAmbiguousItem(ctx, item, PendingItemCommand.AdminStash, quantity)) { AdminGive.IntoPlot(ctx.Event.SenderCharacterEntity, item.prefab, quantity); } } } [CommandGroup("satisvampory", "s")] internal static class ScoopCommands { [Command("auto", null, ".s auto", "Toggle auto-scoop. Default auto all. Keeps current filter.", null, false)] public static void Auto(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) bool flag = Core.PlayerSettings.ToggleAuto(ctx.Event.User.PlatformId); string text = ((Core.PlayerSettings.GetAutoFilter(ctx.Event.User.PlatformId) == AutoFilter.All) ? "all" : "around"); ctx.Reply(flag ? ("Auto-scoop ON (filter " + text + ").") : ("Auto-scoop OFF (filter " + text + ").")); } [Command("auto", null, ".s auto ", "Turn auto-scoop ON and set the auto filter.", null, false)] public static void AutoSet(ChatCommandContext ctx, string filter) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!PlayerSettingsService.TryParseAutoFilter(filter, out var filter2)) { ctx.Reply("Use .s auto around or .s auto all."); return; } Core.PlayerSettings.SetAutoOnWithFilter(ctx.Event.User.PlatformId, filter2); if (filter2 == AutoFilter.Around) { ctx.Reply("Auto-scoop ON, filter around: only piles that spawned while you were in radius."); } else { ctx.Reply("Auto-scoop ON, filter all: any non-player pile in radius."); } } [Command("filter", null, ".s filter", "Show your auto-scoop filter.", null, false)] public static void FilterShow(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.Event.User.PlatformId; string text = (Core.PlayerSettings.IsAutoEnabled(platformId) ? "ON" : "OFF"); if (Core.PlayerSettings.GetAutoFilter(platformId) == AutoFilter.Around) { ctx.Reply("Auto filter around (auto " + text + "): only piles that spawned while you were in radius."); } else { ctx.Reply("Auto filter all (auto " + text + "): any non-player pile in radius."); } } [Command("filter", null, ".s filter ", "Set auto-scoop filter without toggling auto.", null, false)] public static void FilterSet(ChatCommandContext ctx, string filter) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!PlayerSettingsService.TryParseAutoFilter(filter, out var filter2)) { ctx.Reply("Use .s filter around or .s filter all."); return; } Core.PlayerSettings.SetAutoFilter(ctx.Event.User.PlatformId, filter2); FilterShow(ctx); } [Command("notify", null, ".s notify", "Show scoop pickup chat mode.", null, false)] public static void NotifyShow(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) switch (Core.PlayerSettings.GetNotifyMode(ctx.Event.User.PlatformId)) { case NotifyMode.Off: ctx.Reply("Notify off: no pickup chat. .s last still reprints."); break; case NotifyMode.On: ctx.Reply("Notify on: one line per drain on .s and auto."); break; default: ctx.Reply("Notify manual: one line on .s only. Auto is silent."); break; } } [Command("notify", null, ".s notify ", "Set scoop pickup chat: off, manual (.s only), or on (auto too).", null, false)] public static void NotifySet(ChatCommandContext ctx, string mode) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!PlayerSettingsService.TryParseNotifyMode(mode, out var mode2)) { ctx.Reply("Use .s notify off, manual, or on."); return; } Core.PlayerSettings.SetNotifyMode(ctx.Event.User.PlatformId, mode2); NotifyShow(ctx); } [Command("last", null, ".s last", "Reprint your last scoop line.", null, false)] public static void Last(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (ScoopReport.TryGetLast(ctx.Event.User.PlatformId, out var summary)) { ctx.Reply(summary); } else { ctx.Reply("No scoop yet."); } } [Command("radius", null, ".s radius", "Show your scoop radius.", null, false)] public static void RadiusShow(ChatCommandContext ctx) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) ctx.Reply($"Scoop radius: {Core.PlayerSettings.GetRadius(ctx.Event.User.PlatformId):0.#} (1-50)."); } [Command("radius", null, ".s radius ", "Set your scoop radius (1-50).", null, false)] public static void RadiusSet(ChatCommandContext ctx, float n) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) float value = Core.PlayerSettings.SetRadius(ctx.Event.User.PlatformId, n); ctx.Reply($"Scoop radius set to {value:0.#}."); } [Command("exclude", null, ".s exclude", "List items auto-scoop will skip.", null, false)] public static void ExcludeList(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) IReadOnlyList<(PrefabGUID, string)> readOnlyList = Core.PlayerSettings.ListExcludes(ctx.Event.User.PlatformId); if (readOnlyList.Count == 0) { ctx.Reply("No scoop excludes. Soul shards and death bags are always skipped."); return; } ctx.Reply($"Scoop excludes ({readOnlyList.Count}):"); foreach (var item2 in readOnlyList) { string item = item2.Item2; ctx.Reply(" " + item + ""); } } [Command("exclude", null, ".s exclude ", "Toggle scoop-exclude for an item or group.", null, false)] public static void ExcludeToggle(ChatCommandContext ctx, FoundItemOrGroup target) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (!target.IsGroup && LogisticsCommands.HandleAmbiguousItem(ctx, target.Item, PendingItemCommand.ExcludeToggle)) { return; } if (target.IsGroup) { List list = ItemGroupService.ResolveMembers(ctx.Event.User.PlatformId, target.GroupName); if (list.Count == 0) { ctx.Reply("Group " + target.GroupName + " has no members."); return; } int num = 0; int num2 = 0; foreach (ItemGroupService.GroupMember item in list) { if (Core.PlayerSettings.ToggleExclude(ctx.Event.User.PlatformId, item.Prefab, item.Name)) { num++; } else { num2++; } } ctx.Reply($"Group {target.GroupName}: excluded +{num} / unexcluded {num2}."); } else { DoExcludeToggle(ctx, target.Item); } } internal static void DoExcludeToggle(ChatCommandContext ctx, FoundItem item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) PrefabGUID prefab = item.prefab; if (((PrefabGUID)(ref prefab)).GuidHash != 0) { string text = item.prefab.PrefabName(); bool flag = Core.PlayerSettings.ToggleExclude(ctx.Event.User.PlatformId, item.prefab, text); ctx.Reply(flag ? ("Excluded " + text + " from scoop.") : ("No longer excluding " + text + " from scoop.")); } } [Command("bagcap", null, ".s bagcap", "List your scoop bag/guild caps (not castle production caps).", null, false)] public static void BagCapList(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.Event.User.PlatformId; CapMode capMode = Core.PlayerSettings.GetCapMode(platformId); IReadOnlyList<(PrefabGUID, string, int)> readOnlyList = Core.PlayerSettings.ListScoopCaps(platformId); ctx.Reply("Scoop cap mode: " + ((capMode == CapMode.Guild) ? "guild" : "bags") + " (your Steam id only)."); if (readOnlyList.Count == 0) { ctx.Reply("No scoop caps. Missing or -1 = unlimited. 0 = scoop none of that item. Castle conveyor caps are .s cap."); return; } foreach (var item3 in readOnlyList) { string item = item3.Item2; int item2 = item3.Item3; ctx.Reply($" {item} = {item2}"); } } [Command("bagcap", null, ".s bagcap ", "Show scoop cap and current count.", null, false)] public static void BagCapShow(ChatCommandContext ctx, FoundItemOrGroup target) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (!target.IsGroup && LogisticsCommands.HandleAmbiguousItem(ctx, target.Item, PendingItemCommand.BagCapShow)) { return; } if (target.IsGroup) { List list = ItemGroupService.ResolveMembers(ctx.Event.User.PlatformId, target.GroupName); if (list.Count != 0) { ctx.Reply("Scoop caps for " + target.GroupName + ":"); { foreach (ItemGroupService.GroupMember item in list) { DoBagCapShowNamed(ctx, item.Prefab, item.Name); } return; } } ctx.Reply("Group " + target.GroupName + " has no members."); } else { DoBagCapShow(ctx, target.Item); } } [Command("bagcap", null, ".s bagcap ", "Set a scoop cap. 0 = scoop none. -1 = unlimited.", null, false)] public static void BagCapSet(ChatCommandContext ctx, FoundItemOrGroup target, int n) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!target.IsGroup && LogisticsCommands.HandleAmbiguousItem(ctx, target.Item, PendingItemCommand.BagCapSet, n)) { return; } if (target.IsGroup) { List list = ItemGroupService.ResolveMembers(ctx.Event.User.PlatformId, target.GroupName); if (list.Count == 0) { ctx.Reply("Group " + target.GroupName + " has no members."); return; } foreach (ItemGroupService.GroupMember item in list) { Core.PlayerSettings.SetScoopCap(ctx.Event.User.PlatformId, item.Prefab, n, item.Name); } ctx.Reply($"Set scoop cap {n} on {list.Count} item(s) in {target.GroupName}."); } else { DoBagCapSet(ctx, target.Item, n); } } internal static void DoBagCapShow(ChatCommandContext ctx, FoundItem item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) PrefabGUID prefab = item.prefab; if (((PrefabGUID)(ref prefab)).GuidHash != 0) { DoBagCapShowNamed(ctx, item.prefab, item.prefab.PrefabName()); } } private static void DoBagCapShowNamed(ChatCommandContext ctx, PrefabGUID prefab, string name) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.Event.User.PlatformId; int cap = Core.PlayerSettings.GetCap(platformId, prefab); CapMode capMode = Core.PlayerSettings.GetCapMode(platformId); int value = InventoryCountService.CountForCap(ctx.Event.SenderCharacterEntity, ctx.Event.User, prefab, capMode); string value2 = ((cap < 0) ? "unlimited" : cap.ToString()); ctx.Reply($" {name} scoop-cap={value2} have={value} ({capMode})"); } internal static void DoBagCapSet(ChatCommandContext ctx, FoundItem item, int n) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) PrefabGUID prefab = item.prefab; if (((PrefabGUID)(ref prefab)).GuidHash != 0) { string text = item.prefab.PrefabName(); Core.PlayerSettings.SetScoopCap(ctx.Event.User.PlatformId, item.prefab, n, text); if (n < 0) { ctx.Reply("Cleared scoop cap on " + text + " (unlimited)."); return; } ctx.Reply($"Scoop cap {text} = {n}."); } } [Command("bagcapclear", null, ".s bagcapclear", "Clear all of your scoop bag caps.", null, false)] public static void BagCapClear(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Core.PlayerSettings.ClearAllScoopCaps(ctx.Event.User.PlatformId); ctx.Reply("Cleared all your scoop bag caps. Castle production caps are unchanged."); } [Command("mode", null, ".s mode bags|guild", "Scoop cap counting: your bags, or bags + clan stashes.", null, false)] public static void ModeSet(ChatCommandContext ctx, string mode) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (string.Equals(mode, "bags", StringComparison.OrdinalIgnoreCase)) { Core.PlayerSettings.SetCapMode(ctx.Event.User.PlatformId, CapMode.Bags); ctx.Reply("Scoop cap mode bags: count only your inventory."); } else if (string.Equals(mode, "guild", StringComparison.OrdinalIgnoreCase)) { Core.PlayerSettings.SetCapMode(ctx.Event.User.PlatformId, CapMode.Guild); ctx.Reply("Scoop cap mode guild: count your bags plus ClanShare stashes. This is YOUR cap, not a shared clan cap."); } else { ctx.Reply("Use .s mode bags or .s mode guild."); } } } [CommandGroup("logistics", "l")] internal static class LegacyPrefixAlias { [Command("help", "h", ".l help", "Same as .s help", null, false)] public static void Help(ChatCommandContext ctx) { ctx.Reply("Use .s help."); CastleCommands.ShowHelp(ctx); } } internal static class ScoopRootCommands { [Command("scoop", null, ".scoop", "Scoop nearby world drops into your bags.", null, false)] public static void ScoopNow(ChatCommandContext ctx) { RunScoop(ctx); } [Command("s", null, ".s", "Scoop nearby world drops into your bags.", null, false)] public static void SNow(ChatCommandContext ctx) { RunScoop(ctx); } [Command("sc", null, ".sc", "Scoop nearby world drops into your bags.", null, false)] public static void ScNow(ChatCommandContext ctx) { RunScoop(ctx); } [Command("s", null, ".s ", "Pick a numbered item from the last ambiguous search.", null, false)] public static void SPick(ChatCommandContext ctx, int number) { LogisticsCommands.ReplayPendingPick(ctx, number); } [Command("scoop", null, ".scoop ", "Pick a numbered item from the last ambiguous search.", null, false)] public static void ScoopPick(ChatCommandContext ctx, int number) { LogisticsCommands.ReplayPendingPick(ctx, number); } private static void RunScoop(ChatCommandContext ctx) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!Core.HasInitialized) { ctx.Reply("Satisvampory is still starting."); return; } ScoopResult scoopResult = ScoopService.ScoopNow(ctx.Event.SenderCharacterEntity, ctx.Event.User); if (scoopResult.Busy) { ctx.Reply("Scoop is already running for you."); } else if (string.IsNullOrEmpty(scoopResult.Summary)) { ctx.Reply("Nothing to scoop."); } else if (Core.PlayerSettings.GetNotifyMode(ctx.Event.User.PlatformId) != NotifyMode.Off) { ctx.Reply(scoopResult.Summary); } else { ctx.Reply("Scooped. .s last reprints the line."); } } } } namespace Satisvampory.Commands.Converters { public record struct FoundItem(PrefabGUID prefab, bool Ambiguous = false); public enum ItemResolveStatus { Unique, None, Ambiguous } internal class FoundItemConverter : CommandArgumentConverter { public static IReadOnlyDictionary ExactItemNames => ItemCatalog.ExactNames; public override FoundItem Parse(ICommandContext ctx, string input) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) FoundItem item; List<(PrefabGUID, string)> candidates; switch (TryResolve(input, out item, out candidates)) { case ItemResolveStatus.Unique: return item; case ItemResolveStatus.Ambiguous: { ChatCommandContext val = (ChatCommandContext)(object)((ctx is ChatCommandContext) ? ctx : null); if (val != null) { PendingItemChoiceService.BeginAmbiguous(val.Event.User.PlatformId, candidates); return new FoundItem(default(PrefabGUID), Ambiguous: true); } throw MultipleResultsError(ctx, PrefabsFromCandidates(candidates), 60 + "\n...".Length); } default: throw ctx.Error("No items found matching: " + input); } } public static ItemResolveStatus TryResolve(string input, out FoundItem item, out List<(PrefabGUID prefab, string name)> candidates) { return ItemCatalog.TryResolve(input, out item, out candidates); } public static void LoadItemNames() { ItemCatalog.Load(); } public static bool TryGetExact(string input, out FoundItem item) { return ItemCatalog.TryGetExact(input, out item); } public static string Normalize(string s) { return ItemCatalog.Normalize(s); } public static void RegisterExactAlias(string alias, PrefabGUID prefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ItemCatalog.RegisterExactAlias(alias, prefab); } public static void UnregisterExactAlias(string alias) { ItemCatalog.UnregisterExactAlias(alias); } private static Exception MultipleResultsError(ICommandContext ctx, List searchResults, int lengthOfFail) { return ItemCatalog.MultipleResultsError(ctx, searchResults, lengthOfFail); } private static List PrefabsFromCandidates(List<(PrefabGUID prefab, string name)> candidates) { return ItemCatalog.PrefabsFromCandidates(candidates); } } public record struct FoundItemOrGroup { public bool IsGroup; public string GroupName; public FoundItem Item; public static FoundItemOrGroup FromItem(FoundItem item) { return new FoundItemOrGroup { IsGroup = false, GroupName = null, Item = item }; } public static FoundItemOrGroup FromGroup(string name) { return new FoundItemOrGroup { IsGroup = true, GroupName = name, Item = default(FoundItem) }; } } internal class FoundItemOrGroupConverter : CommandArgumentConverter { public override FoundItemOrGroup Parse(ICommandContext ctx, string input) { if (FoundItemConverter.TryGetExact(input, out var item)) { return FoundItemOrGroup.FromItem(item); } string name = FoundItemConverter.Normalize(input); if (ItemGroupService.TryGetBuiltInCanonical(name, out var canonical)) { return FoundItemOrGroup.FromGroup(canonical); } ChatCommandContext val = (ChatCommandContext)(object)((ctx is ChatCommandContext) ? ctx : null); if (val != null && ItemGroupService.TryGetStandingCastleSettingsOwner(val, out var ownerPlatformId, out var _, replyIfMissing: false) && Core.PlayerSettings.HasItemGroup(ownerPlatformId, name)) { return FoundItemOrGroup.FromGroup(ItemGroupService.NormalizeName(name)); } return FoundItemOrGroup.FromItem(((CommandArgumentConverter)(object)new FoundItemConverter()).Parse(ctx, input)); } } internal static class ItemCatalog { private static Dictionary itemNamesToPrefabs = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly HashSet omittedHashes = new HashSet { -625033436, 1217578824, 409678749, 2029158532, -1199259626, 930747930 }; internal static IReadOnlyDictionary ExactNames => itemNamesToPrefabs; internal static ItemResolveStatus TryResolve(string input, out FoundItem item, out List<(PrefabGUID prefab, string name)> candidates) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) item = default(FoundItem); candidates = new List<(PrefabGUID, string)>(); string text = NormalizeName(input); if (TryGet(input, out var item2)) { item = item2; return ItemResolveStatus.Unique; } List list = new List(); foreach (KeyValuePair itemNamesToPrefab in itemNamesToPrefabs) { if (itemNamesToPrefab.Key.Contains(text, StringComparison.OrdinalIgnoreCase)) { list.Add(itemNamesToPrefab.Value); } } if (TryResolveUniqueOrExact(list, text, out var item3)) { item = item3; return ItemResolveStatus.Unique; } if (list.Count > 1) { return AmbiguousFrom(list, out item, out candidates); } for (int i = 3; i < text.Length; i++) { string text2 = NormalizeName(text.Substring(0, i)); string text3 = text; int num = i; string text4 = NormalizeName(text3.Substring(num, text3.Length - num)); if (text2.Length == 0 || text4.Length == 0) { continue; } foreach (KeyValuePair itemNamesToPrefab2 in itemNamesToPrefabs) { if (itemNamesToPrefab2.Key.Contains(text2, StringComparison.OrdinalIgnoreCase) && itemNamesToPrefab2.Key.Contains(text4, StringComparison.OrdinalIgnoreCase)) { list.Add(itemNamesToPrefab2.Value); } } } if (TryResolveUniqueOrExact(list, text, out item3)) { item = item3; return ItemResolveStatus.Unique; } if (list.Count == 0) { foreach (KeyValuePair itemNamesToPrefab3 in itemNamesToPrefabs) { for (int j = 3; j < text.Length - 3; j++) { string text5 = NormalizeName(text.Substring(0, j)); if (text5.Length == 0 || !itemNamesToPrefab3.Key.Contains(text5, StringComparison.OrdinalIgnoreCase)) { continue; } for (int k = j + 3; k < text.Length; k++) { int num = j; string text6 = NormalizeName(text.Substring(num, k - num)); string text3 = text; num = k; string text7 = NormalizeName(text3.Substring(num, text3.Length - num)); if (text6.Length != 0 && text7.Length != 0 && itemNamesToPrefab3.Key.Contains(text6, StringComparison.OrdinalIgnoreCase) && itemNamesToPrefab3.Key.Contains(text7, StringComparison.OrdinalIgnoreCase)) { list.Add(itemNamesToPrefab3.Value); } } } } } if (TryResolveUniqueOrExact(list, text, out item3)) { item = item3; return ItemResolveStatus.Unique; } if (list.Count > 1) { return AmbiguousFrom(list, out item, out candidates); } return ItemResolveStatus.None; } private static ItemResolveStatus AmbiguousFrom(List searchResults, out FoundItem item, out List<(PrefabGUID prefab, string name)> candidates) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) item = default(FoundItem); candidates = new List<(PrefabGUID, string)>(); HashSet hashSet = new HashSet(); foreach (PrefabGUID searchResult in searchResults) { if (hashSet.Add(searchResult)) { string text = searchResult.PrefabName(); if (!string.IsNullOrEmpty(text)) { candidates.Add((searchResult, text)); } } } return ItemResolveStatus.Ambiguous; } internal static List PrefabsFromCandidates(List<(PrefabGUID prefab, string name)> candidates) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (candidates == null) { return list; } foreach (var candidate in candidates) { PrefabGUID item = candidate.prefab; list.Add(item); } return list; } internal static void Load() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) Enumerator enumerator = Core.PrefabCollectionSystem._SpawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; if (IsLiveItemPrefab(current.Key, current.Value)) { string text = current.Value.PrefabName(); if (!string.IsNullOrEmpty(text)) { itemNamesToPrefabs[NormalizeName(text)] = current.Value; } } } RegisterBuiltInItemAliases(); } private static bool IsLiveItemPrefab(string spawnName, PrefabGUID prefab) { if (omittedHashes.Contains(((PrefabGUID)(ref prefab)).GuidHash)) { return false; } if (!spawnName.StartsWith("Item_")) { return false; } if (!spawnName.EndsWith("_Base") && !spawnName.EndsWith("_Trader_Template")) { return !spawnName.EndsWith("_Debug"); } return false; } public static void RegisterExactAlias(string alias, PrefabGUID prefab) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrWhiteSpace(alias) && ((PrefabGUID)(ref prefab)).GuidHash != 0) { itemNamesToPrefabs[NormalizeName(alias)] = prefab; } } public static void UnregisterExactAlias(string alias) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrWhiteSpace(alias)) { string text = NormalizeName(alias); if (itemNamesToPrefabs.TryGetValue(text, out var value) && !NormalizeName(value.PrefabName() ?? "").Equals(text, StringComparison.OrdinalIgnoreCase)) { itemNamesToPrefabs.Remove(text); } } } private static void RegisterBuiltInItemAliases() { RegisterItemAlias("Blood Essence", "BE"); RegisterItemAlias("Greater Blood Essence", "GBE", "greater blood"); RegisterItemAlias("Primal Blood Essence", "PBE", "primal blood"); RegisterItemAlias("Ancestral Blood Essence", "ABE", "ancestral blood"); RegisterItemAlias("Greater Stygian Shard", "GSS", "greater stygian"); RegisterItemAlias("Greater Stygian Shards", "GSS", "greater stygian"); RegisterItemAlias("Siege Golem Stone", "SGS"); RegisterItemAlias("Dark Silver Ingot", "DSI", "dark silver"); RegisterItemAlias("Onyx Tear", "OT"); } private static void RegisterItemAlias(string locName, string shortAlias, string midAlias = null) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (itemNamesToPrefabs.TryGetValue(NormalizeName(locName), out var value) && NormalizeName(value.PrefabName()).Equals(NormalizeName(locName), StringComparison.OrdinalIgnoreCase)) { itemNamesToPrefabs[NormalizeName(shortAlias)] = value; if (!string.IsNullOrEmpty(midAlias)) { itemNamesToPrefabs[NormalizeName(midAlias)] = value; } } } private static string NormalizeName(string s) { if (string.IsNullOrEmpty(s)) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(s.Length); bool flag = false; foreach (char c in s) { char c2; switch (c) { case '\'': case '`': case '\u00b4': case 'ʼ': case '‘': case '’': case '‛': case '′': c2 = '\''; break; case '‐': case '‑': case '–': case '—': c2 = '-'; break; default: c2 = c; break; } char c3 = c2; if (char.IsWhiteSpace(c3)) { if (!flag) { stringBuilder.Append(' '); flag = true; } } else { stringBuilder.Append(c3); flag = false; } } return stringBuilder.ToString().Trim(); } internal static bool TryGetExact(string input, out FoundItem item) { return TryGet(input, out item); } internal static string Normalize(string s) { return NormalizeName(s); } private static bool TryGet(string input, out FoundItem item) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (itemNamesToPrefabs.TryGetValue(NormalizeName(input), out var value)) { item = new FoundItem(value); return true; } item = new FoundItem(new PrefabGUID(0)); return false; } private static bool TryResolveUniqueOrExact(List searchResults, string normalizedInput, out FoundItem item) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (searchResults.Count == 1) { item = new FoundItem(searchResults[0]); return true; } if (searchResults.Count > 1) { PrefabGUID prefab = default(PrefabGUID); int num = 0; HashSet hashSet = new HashSet(); foreach (PrefabGUID searchResult in searchResults) { if (hashSet.Add(searchResult) && NormalizeName(searchResult.PrefabName()).Equals(normalizedInput, StringComparison.OrdinalIgnoreCase)) { prefab = searchResult; num++; } } if (num == 1) { item = new FoundItem(prefab); return true; } } item = default(FoundItem); return false; } internal static Exception MultipleResultsError(ICommandContext ctx, List searchResults, int lengthOfFail) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Multiple results be more specific"); HashSet hashSet = new HashSet(); foreach (PrefabGUID searchResult in searchResults) { if (!hashSet.Add(searchResult)) { continue; } string text = searchResult.PrefabName(); if (!string.IsNullOrEmpty(text)) { if (stringBuilder.Length + text.Length + lengthOfFail >= 509) { stringBuilder.AppendLine("..."); return (Exception)(object)ctx.Error(stringBuilder.ToString()); } stringBuilder.AppendLine(text); } } return (Exception)(object)ctx.Error(stringBuilder.ToString()); } } }