Decompiled source of Satisvampory v1.0.85
plugins/Satisvampory.dll
Decompiled 20 hours ago
The result has been truncated due to the large size, download it to view full contents!
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<GameDataSystem>(); 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<string>(caller); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nMessage: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner:"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\nStack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.StackTrace); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nInner Stack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(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<Singleton>(); 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<T>(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<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Il2CppEntity.Read<T>(entity); } public static DynamicBuffer<T> ReadBuffer<T>(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<T>(entity); } public static bool Has<T>(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Il2CppEntity.Has<T>(entity); } public static void Add<T>(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Il2CppEntity.Add<T>(entity); } public static void Remove<T>(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Il2CppEntity.Remove<T>(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<string>("1.0.85"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("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<EntityManager>(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<PrefabGUID, List<Entity>> GetItemStashesOnTerritory(int territoryId) { return InventoryMove.CollectOccupiedChests(territoryId); } public static void StashInventoryEntity(Entity inventory, Dictionary<PrefabGUID, List<Entity>> itemInventories, List<Entity> 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<CastleHeartConnection>() || !character.Has<TilePosition>()) { return false; } CastleHeartConnection val = target.Read<CastleHeartConnection>(); Entity entityOnServer = ((NetworkedEntity)(ref val.CastleHeartEntity)).GetEntityOnServer(); if (entityOnServer == Entity.Null || !entityOnServer.Has<CastleHeart>()) { return false; } int2 tile = character.Read<TilePosition>().Tile; Entity castleTerritoryEntity = entityOnServer.Read<CastleHeart>().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<CastleHeartConnection>() || !output.Has<CastleHeartConnection>()) { return false; } Entity entity = input.Read<CastleHeartConnection>().CastleHeartEntity._Entity; Entity entity2 = output.Read<CastleHeartConnection>().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<InventoryBuffer>().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<PlayerCharacter>()) { return; } User val = character.Read<PlayerCharacter>().UserEntity.Read<User>(); 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<Entity, int> dictionary = new Dictionary<Entity, int>(); 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<Entity, int> item4 in dictionary) { item4.Deconstruct(out key, out var value3); Entity entity = key; int value4 = value3; Utilities.SendSystemMessageToClient(Core.EntityManager, val, $"Admin Stashed <color=white>{value4}</color>x <color=green>{item.PrefabName()}</color> to <color=#FFC0CB>{entity.EntityName()}</color>"); } if (num > 0) { Utilities.SendSystemMessageToClient(Core.EntityManager, val, $"Unable to admin stash <color=white>{num}</color>x <color=green>{item.PrefabName()}</color> 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<BeltSink>> grouped = new Dictionary<(int, int), List<BeltSink>>(); 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<BeltSink>(); grouped[key] = value; } value.Add(new BeltSink(inventory, item, amount, chest)); } } public bool TryGrouped(int group, PrefabGUID item, out List<BeltSink> sinks) { return grouped.TryGetValue((group, ((PrefabGUID)(ref item)).GuidHash), out sinks); } public Dictionary<int, List<List<BeltSink>>> FlattenByItem() { Dictionary<int, List<List<BeltSink>>> dictionary = new Dictionary<int, List<List<BeltSink>>>(); foreach (KeyValuePair<(int, int), List<BeltSink>> item2 in grouped) { int item = item2.Key.Item2; if (!dictionary.TryGetValue(item, out var value)) { value = (dictionary[item] = new List<List<BeltSink>>()); } 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<UserOwner>()) { return false; } UserOwner val = castleHeart.Read<UserOwner>(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer == Entity.Null || !entityOnServer.Has<User>()) { return false; } platformId = entityOnServer.Read<User>().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<string> 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<string> list = new List<string>(); string text = StashRouting.ItemLabel(product); if (standingTerritoryId < 0) { list.Add("You must stand on a castle plot to troubleshoot conveyors."); return list; } IReadOnlyList<int> 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>()) { UserOwner val = castleHeart.Read<UserOwner>(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has<User>()) { num = entityOnServer.Read<User>().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<Entity> list2 = new List<Entity>(); HashSet<Entity> hashSet = new HashSet<Entity>(); foreach (int item13 in logisticsTerritoryIds) { foreach (Entity item14 in Core.RefinementStations.BenchesOnPlot(item13)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(item14) && !item14.Has<Disabled>() && item14.Has<Refinementstation>() && item14.Has<RefinementstationRecipesBuffer>() && hashSet.Add(item14)) { list2.Add(item14); } } } List<(Entity, string, HashSet<int>, bool, bool, bool, int?, List<PrefabGUID>, Dictionary<PrefabGUID, bool>, Dictionary<PrefabGUID, int>)> list3 = new List<(Entity, string, HashSet<int>, bool, bool, bool, int?, List<PrefabGUID>, Dictionary<PrefabGUID, bool>, Dictionary<PrefabGUID, int>)>(); 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<int> 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<int> item5 = item16.Item3; bool item6 = item16.Item4; bool item7 = item16.Item5; bool item8 = item16.Item6; int? item9 = item16.Item7; List<PrefabGUID> item10 = item16.Rest.Item1; Dictionary<PrefabGUID, bool> item11 = item16.Rest.Item2; Dictionary<PrefabGUID, int> 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<Refinementstation>(); 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<PrefabGUID> inputs, out Dictionary<PrefabGUID, bool> inputAtFeedCap, out Dictionary<PrefabGUID, int> 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<PrefabGUID>(); inputAtFeedCap = new Dictionary<PrefabGUID, bool>(); stationHave = new Dictionary<PrefabGUID, int>(); DynamicBuffer<RefinementstationRecipesBuffer> val = station.ReadBuffer<RefinementstationRecipesBuffer>(); float num = 1f; if (station.Has<CastleWorkstation>()) { CastleWorkstation val2 = station.Read<CastleWorkstation>(); if (((Enum)val2.WorkstationLevel).HasFlag((Enum)(object)(WorkstationLevel)2)) { num = 0.75f; } } Refinementstation val3 = station.Read<Refinementstation>(); Entity entityOnServer = ((NetworkedEntity)(ref val3.InputInventoryEntity)).GetEntityOnServer(); Entity entityOnServer2 = ((NetworkedEntity)(ref val3.OutputInventoryEntity)).GetEntityOnServer(); DynamicBuffer<InventoryBuffer> val4 = default(DynamicBuffer<InventoryBuffer>); EntityManager entityManager = Core.EntityManager; int num2; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { ServerGameManager serverGameManager = Core.ServerGameManager; num2 = (((ServerGameManager)(ref serverGameManager)).TryGetBuffer<InventoryBuffer>(entityOnServer, ref val4) ? 1 : 0); } else { num2 = 0; } bool flag = (byte)num2 != 0; List<PrefabGUID> list = new List<PrefabGUID>(); List<PrefabGUID> list2 = new List<PrefabGUID>(); HashSet<int> seen = new HashSet<int>(); HashSet<int> seen2 = new HashSet<int>(); bool flag2 = false; bool flag3 = false; bool flag4 = false; Dictionary<PrefabGUID, int> dictionary = new Dictionary<PrefabGUID, int>(); Enumerator<RefinementstationRecipesBuffer> 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<RecipeOutputBuffer>()) { continue; } DynamicBuffer<RecipeOutputBuffer> val6 = val5.ReadBuffer<RecipeOutputBuffer>(); 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<RecipeRequirementBuffer>()) { continue; } Enumerator<RecipeRequirementBuffer> enumerator2 = val5.ReadBuffer<RecipeRequirementBuffer>().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<InventoryBuffer> 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<InventoryBuffer> 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<PrefabGUID> inputs, HashSet<int> 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<RecipeRequirementBuffer>()) { return; } Enumerator<RecipeRequirementBuffer> enumerator = recipeEntity.ReadBuffer<RecipeRequirementBuffer>().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<int> CollectReceiverGroups(Entity station) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) HashSet<int> hashSet = new HashSet<int>(); 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<int> logisticsIds, HashSet<int> 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<Entity> hashSet = new HashSet<Entity>(); 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<AttachedBuffer> val = default(DynamicBuffer<AttachedBuffer>); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer<AttachedBuffer>(stash, ref val)) { return; } Enumerator<AttachedBuffer> enumerator = val.GetEnumerator(); DynamicBuffer<InventoryBuffer> val3 = default(DynamicBuffer<InventoryBuffer>); while (enumerator.MoveNext()) { Entity entity = enumerator.Current.Entity; if (!entity.Has<PrefabGUID>()) { continue; } PrefabGUID val2 = entity.Read<PrefabGUID>(); if (!((PrefabGUID)(ref val2)).Equals(StashService.ChestBagGuid)) { continue; } serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer<InventoryBuffer>(entity, ref val3)) { continue; } Enumerator<InventoryBuffer> 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<InventoryBuffer> val = default(DynamicBuffer<InventoryBuffer>); if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer<InventoryBuffer>(inventory, ref val)) { return false; } Enumerator<InventoryBuffer> 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<string> 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<string> list = new List<string>(); if (standingTerritoryId < 0) { list.Add("You must stand on a castle plot to list conveyor need."); return list; } IReadOnlyList<int> 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>()) { UserOwner val = castleHeart.Read<UserOwner>(); Entity entityOnServer = ((NetworkedEntity)(ref val.Owner)).GetEntityOnServer(); if (entityOnServer != Entity.Null) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer) && entityOnServer.Has<User>()) { num = entityOnServer.Read<User>().PlatformId; } } } } Dictionary<int, int> dictionary = new Dictionary<int, int>(); Dictionary<int, int> dictionary2 = new Dictionary<int, int>(); List<(PrefabGUID, List<PrefabGUID>)> list2 = new List<(PrefabGUID, List<PrefabGUID>)>(); Dictionary<int, Dictionary<PrefabGUID, int>> dictionary3 = new Dictionary<int, Dictionary<PrefabGUID, int>>(); foreach (int item6 in logisticsTerritoryIds) { dictionary3[item6] = BeltCounts.OfPlot(item6); } Dictionary<PrefabGUID, int> 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<Disabled>() || !item.Has<Refinementstation>() || !item.Has<RefinementstationRecipesBuffer>() || !item.Has<CastleWorkstation>()) { continue; } Refinementstation val2 = item.Read<Refinementstation>(); CastleWorkstation val3 = item.Read<CastleWorkstation>(); 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<InventoryBuffer>() ? 1 : 0); goto IL_020c; } } num3 = 0; goto IL_020c; IL_020c: bool flag = (byte)num3 != 0; NativeArray<InventoryBuffer> val4 = default(NativeArray<InventoryBuffer>); if (flag) { val4 = entityOnServer2.ReadBuffer<InventoryBuffer>().ToNativeArray(AllocatorHandle.op_Implicit((Allocator)2)); } try { Enumerator<RefinementstationRecipesBuffer> enumerator3 = item.ReadBuffer<RefinementstationRecipesBuffer>().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<RecipeOutputBuffer>()) { DynamicBuffer<RecipeOutputBuffer> val7 = val5.ReadBuffer<RecipeOutputBuffer>(); 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<PrefabGUID> list3 = new List<PrefabGUID>(); if (!val5.Has<RecipeRequirementBuffer>()) { continue; } Enumerator<RecipeRequirementBuffer> enumerator4 = val5.ReadBuffer<RecipeRequirementBuffer>().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<PrefabGUID> 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<int, int> 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}. <color=green>{value9}</color> T{tuple.Item6} demand <color=white>{tuple.Item2}</color> total <color=white>{tuple.Item3}</color> reserve <color=white>{tuple.Item5}</color>"); } 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<int> clanConsumed = new HashSet<int>(); private static int clanGeneration = -1; private static readonly HashSet<Entity> salvagerFull = new HashSet<Entity>(); private static readonly HashSet<(Entity entity, PrefabGUID item)> salvagerFullOfItem = new HashSet<(Entity, PrefabGUID)>(); private static readonly Dictionary<int, float> salvageDiagAt = new Dictionary<int, float>(); 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<int> 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<int> plots = Core.TerritoryService.GetLogisticsTerritoryIds(territoryId); MarkClanSiblings(territoryId, plots); ServerGameManager sgm = Core.ServerGameManager; Dictionary<PrefabGUID, int> 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<int, List<List<BeltSink>>> 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<Refinementstation>()) { continue; } Refinementstation val2 = item2.Read<Refinementstation>(); 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<Entity>(); 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<Refinementstation>() && 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<int> plots, ulong ownerId, Dictionary<PrefabGUID, int> 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<InventoryBuffer> val2 = default(DynamicBuffer<InventoryBuffer>); Entity entity2 = default(Entity); foreach (int plot in plots) { foreach (var (num, entity) in Core.RefinementStations.ReceiveBenches(plot)) { if (!entity.Has<Refinementstation>() || !entity.Has<CastleWorkstation>() || !entity.Has<RefinementstationRecipesBuffer>()) { continue; } Refinementstation val = entity.Read<Refinementstation>(); 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<CastleWorkstation>().WorkstationLevel).HasFlag((Enum)(object)(WorkstationLevel)2) ? 0.75f : 1f); ServerGameManager serverGameManager = Core.ServerGameManager; if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer<InventoryBuffer>(entityOnServer, ref val2)) { continue; } DynamicBuffer<RefinementstationRecipesBuffer> val3 = entity.ReadBuffer<RefinementstationRecipesBuffer>(); 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<RecipeOutputBuffer>()) { DynamicBuffer<RecipeOutputBuffer> val5 = entity2.ReadBuffer<RecipeOutputBuffer>(); 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<RecipeRequirementBuffer>()) { continue; } DynamicBuffer<RecipeRequirementBuffer> val7 = entity2.ReadBuffer<RecipeRequirementBuffer>(); 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; i