using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using SpaceCraft; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("VirtualStorage")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8140d4d451644dcda56a0246e60a799df212f60d")] [assembly: AssemblyProduct("VirtualStorage")] [assembly: AssemblyTitle("VirtualStorage")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace VirtualStorage { [HarmonyPatch(typeof(StaticDataHandler), "LoadStaticData")] internal static class Patch_RegisterGroup { [HarmonyPostfix] private static void Postfix() { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown if (GroupsHandler.GetGroupViaId("VirtualStorageT1") == null) { Group val = GroupsHandler.GetGroupViaId("CraftStation2") ?? GroupsHandler.GetGroupViaId("CraftStation1"); Group val2 = GroupsHandler.GetGroupViaId("Container2") ?? GroupsHandler.GetGroupViaId("Container1"); if (val2 == null) { Plugin.Log.LogError((object)"[VirtualStorage] No base container group found – Virtual Storage will not be registered."); return; } GameObject val3 = BuildVisualPrefab(val, val2); Plugin.Log.LogInfo((object)("[VirtualStorage] Using prefab '" + ((Object)val3).name + "'.")); GroupDataConstructible val4 = ScriptableObject.CreateInstance(); ((GroupData)val4).id = "VirtualStorageT1"; ((GroupData)val4).associatedGameObject = val3; ((GroupData)val4).icon = ((val != null) ? val.GetImage() : null) ?? val2.GetImage(); val4.unitGenerationEnergy = -10000f; ((GroupData)val4).inventorySize = 9999; GroupData groupData = val2.GetGroupData(); GroupDataConstructible val5 = (GroupDataConstructible)(object)((groupData is GroupDataConstructible) ? groupData : null); val4.groupCategory = (GroupCategory)((val5 == null) ? 2 : ((int)val5.groupCategory)); ((GroupData)val4).logisticInterplanetaryType = (LogisticInterplanetaryType)1; ((GroupData)val4).recipeIngredients = BuildRecipe(("Drone2", 1), ("MultiToolDeconstruct3", 1), ("MultiBuild", 1), ("CircuitBoard1", 1), ("SolarQuartz", 1), ("PulsarQuartz", 1), ("QuasarQuartz", 1), ("MagnetarQuartz", 1), ("BalzarQuartz", 1)); ((GroupData)val4).unlockingWorldUnit = (WorldUnitType)1; ((GroupData)val4).unlockingValue = 0f; ((GroupData)val4).terraformStageUnlock = null; ((GroupData)val4).unlockInPlanets = new List(); ((GroupData)val4).secondaryInventoriesSize = new List(); val4.notAllowedPlanetsRequirement = new List(); val4.terraStageRequirements = Array.Empty(); GroupConstructible val6 = new GroupConstructible(val4); List list = ((GroupData)val4).recipeIngredients ?? new List(); ((Group)val6).SetRecipe(new Recipe(list)); GroupsHandler.SetAllGroups(new List(GroupsHandler.GetAllGroups()) { (Group)(object)val6 }); Plugin.Log.LogInfo((object)("[VirtualStorage] Registered group 'VirtualStorageT1' " + $"(energy: {val4.unitGenerationEnergy} kW, recipe: {((GroupData)val4).recipeIngredients?.Count ?? 0} ingredients).")); } } private static GameObject BuildVisualPrefab(Group? craftGroup, Group containerGroup) { return ((craftGroup != null) ? craftGroup.GetAssociatedGameObject() : null) ?? containerGroup.GetAssociatedGameObject(); } private static List? BuildRecipe(params (string id, int count)[] ingredients) { List list = new List(); for (int i = 0; i < ingredients.Length; i++) { (string id, int count) tuple = ingredients[i]; string item = tuple.id; int item2 = tuple.count; Group groupViaId = GroupsHandler.GetGroupViaId(item); GroupData obj = ((groupViaId != null) ? groupViaId.GetGroupData() : null); GroupDataItem val = (GroupDataItem)(object)((obj is GroupDataItem) ? obj : null); if (val != null && groupViaId is GroupItem) { for (int j = 0; j < item2; j++) { list.Add(val); } } else { Plugin.Log.LogWarning((object)("[VirtualStorage] Recipe ingredient '" + item + "' not found – skipping.")); } } if (list.Count <= 0) { return null; } return list; } } [HarmonyPatch(typeof(InventoryAssociated), "SetInventory")] internal static class Patch_UnlimitedInventory { public static readonly HashSet VirtualStorageInventoryIds = new HashSet(); public static readonly Dictionary InventoryToWoId = new Dictionary(); [HarmonyPostfix] private static void Postfix(InventoryAssociated __instance, Inventory inventory) { WorldObjectAssociated component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null) { return; } WorldObject worldObject = component.GetWorldObject(); if (worldObject != null) { Group obj = worldObject.GetGroup(); if (!(((obj != null) ? obj.GetId() : null) != "VirtualStorageT1")) { inventory.SetSize(int.MaxValue); VirtualStorageInventoryIds.Add(inventory.GetId()); InventoryToWoId[inventory.GetId()] = worldObject.GetId(); VirtualStorageLimits.Load(worldObject.GetId(), worldObject); Plugin.Log.LogInfo((object)$"[VirtualStorage] Inventory {inventory.GetId()} → unlimited (WO {worldObject.GetId()})."); SetupContainerBehavior(((Component)__instance).gameObject, worldObject.GetId()); } } } private static void SetupContainerBehavior(GameObject go, int woId) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) ActionCrafter[] componentsInChildren = go.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } ActionnableInteractive[] componentsInChildren2 = go.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } MachineConvertRecipe[] componentsInChildren3 = go.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } Canvas[] componentsInChildren4 = go.GetComponentsInChildren(); foreach (Canvas val in componentsInChildren4) { if ((Object)(object)((Component)val).gameObject != (Object)(object)go) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } else { Object.DestroyImmediate((Object)(object)val); } } if ((Object)(object)go.GetComponent() == (Object)null) { go.AddComponent(); } if (!((Object)(object)go.GetComponent() != (Object)null)) { ActionOpenable obj = go.AddComponent(); obj.uiType = (UiType)3; obj.hideLogisticsButton = false; obj.infosHoverLocalizationId = ""; Plugin.Log.LogInfo((object)$"[VirtualStorage] Instance configured as container (WO {woId})."); } } } [HarmonyPatch(typeof(Localization), "GetLocalizedString")] internal static class Patch_Localization { private const string NameKey = "GROUP_NAME_VirtualStorageT1"; private const string DescKey = "GROUP_DESC_VirtualStorageT1"; private static readonly Dictionary _strings = new Dictionary { ["GROUP_NAME_VirtualStorageT1"] = "Virtual Storage", ["GROUP_DESC_VirtualStorageT1"] = $"Unlimited storage capacity. Consumes {10000f:0} kW of power." }; [HarmonyPrefix] private static bool Prefix(string stringCode, ref string __result) { if (_strings.TryGetValue(stringCode, out string value)) { __result = value; return false; } return true; } } [HarmonyPatch(typeof(LogisticManager), "CreateNewTaskForWorldObject")] internal static class Patch_LogisticLimit { [HarmonyPrefix] private static bool Prefix(Inventory demandInventory, WorldObject worldObject, ref LogisticTask __result) { if (!Patch_UnlimitedInventory.VirtualStorageInventoryIds.Contains(demandInventory.GetId())) { return true; } if (!Patch_UnlimitedInventory.InventoryToWoId.TryGetValue(demandInventory.GetId(), out var value)) { return true; } if (VirtualStorageLimits.DroneCanDeposit(demandInventory, value, worldObject.GetGroup())) { return true; } __result = null; return false; } } [HarmonyPatch(typeof(LogisticManager), "CreateNewTaskForWorldObjectForSpawnedObject")] internal static class Patch_LogisticLimitSpawned { [HarmonyPrefix] private static bool Prefix(Inventory demandInventory, WorldObject worldObject, ref LogisticTask __result) { if (!Patch_UnlimitedInventory.VirtualStorageInventoryIds.Contains(demandInventory.GetId())) { return true; } if (!Patch_UnlimitedInventory.InventoryToWoId.TryGetValue(demandInventory.GetId(), out var value)) { return true; } if (VirtualStorageLimits.DroneCanDeposit(demandInventory, value, worldObject.GetGroup())) { return true; } __result = null; return false; } } [HarmonyPatch(typeof(LogisticSelector), "InitLogisticSelector")] internal static class Patch_LogisticDemandAll { internal static readonly Dictionary DemandEvTexts = new Dictionary(); [HarmonyPostfix] private static void Postfix(LogisticSelector __instance, Inventory inventory) { if (Patch_UnlimitedInventory.VirtualStorageInventoryIds.Contains(inventory.GetId()) && !DemandEvTexts.ContainsKey(__instance)) { AddDemandAllButton(__instance, inventory); } } private static void AddDemandAllButton(LogisticSelector selector, Inventory inventory) { //IL_006c: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_013e: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_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_022d: Unknown result type (might be due to invalid IL or missing references) GameObject supplyAllIcon = selector.supplyAllIcon; if (!((Object)(object)supplyAllIcon == (Object)null)) { GroupSelector groupSelectorSupply = selector.groupSelectorSupply; RectTransform val = ((groupSelectorSupply != null) ? ((Component)groupSelectorSupply).GetComponent() : null); GroupSelector groupSelectorDemand = selector.groupSelectorDemand; RectTransform val2 = ((groupSelectorDemand != null) ? ((Component)groupSelectorDemand).GetComponent() : null); Vector3 val3 = (((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) ? (((Transform)val2).position - ((Transform)val).position) : Vector3.zero); GameObject val4 = Object.Instantiate(supplyAllIcon, supplyAllIcon.transform.parent); ((Object)val4).name = "VSdemandAllIcon"; RectTransform component = supplyAllIcon.GetComponent(); ((Transform)val4.GetComponent()).position = ((Transform)component).position + val3; Button component2 = val4.GetComponent