using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CommonAPI; using CommonAPI.Systems; using CommonAPI.Systems.ModLocalization; using HarmonyLib; using NebulaAPI; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("GigaStations")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+120591bbd7d8ea3b86c8ac91c463b360fadb05e1")] [assembly: AssemblyProduct("GigaStations")] [assembly: AssemblyTitle("GigaStations")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace GigaStations { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("org.kremnev8.plugin.GigaStationsUpdated", "GigaStationsUpdated", "2.4.0")] [CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "UtilSystem", "LocalizationModule" })] public class GigaStationsPlugin : BaseUnityPlugin { public const string MODGUID = "org.kremnev8.plugin.GigaStationsUpdated"; public const string MODNAME = "GigaStationsUpdated"; public const string VERSION = "2.4.0"; public const string LDB_TOOL_GUID = "me.xiaoye97.plugin.Dyson.LDBTool"; public const string WARPERS_MOD_GUID = "ShadowAngel.DSP.DistributeSpaceWarper"; public static ManualLogSource logger; public static ItemProto pls; public static ItemProto ils; public static ItemProto collector; public static ModelProto plsModel; public static ModelProto ilsModel; public static ModelProto collectorModel; public static ResourceData resource; public static int gridXCount { get; set; } = 1; public static int gridYCount { get; set; } = 5; public static Color stationColor { get; set; } = new Color(0.3726f, 0.8f, 1f, 1f); public static int ilsMaxStorage { get; set; } = 30000; public static int ilsMaxWarps { get; set; } = 150; public static int ilsMaxVessels { get; set; } = 30; public static int ilsMaxDrones { get; set; } = 150; public static long ilsMaxAcuGJ { get; set; } = 50L; public static int ilsMaxSlots { get; set; } = 12; public static int plsMaxStorage { get; set; } = 15000; public static int plsMaxDrones { get; set; } = 150; public static long plsMaxAcuMJ { get; set; } = 500L; public static int plsMaxSlots { get; set; } = 12; public static int colMaxStorage { get; set; } = 15000; public static int colSpeedMultiplier { get; set; } = 3; public static int vesselCapacityMultiplier { get; set; } = 3; public static int droneCapacityMultiplier { get; set; } = 3; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Expected O, but got Unknown //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Expected O, but got Unknown logger = ((BaseUnityPlugin)this).Logger; string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); resource = new ResourceData("GigaStationsUpdated", "gigastations", directoryName); resource.LoadAssetBundle("gigastations"); ProtoRegistry.AddResource(resource); gridXCount = ((BaseUnityPlugin)this).Config.Bind("-|0|- General", "-| 1 Grid X Max. Count", 1, new ConfigDescription("Amount of slots visible horizontally.\nIf this value is bigger than 1, layout will form a grid", (AcceptableValueBase)(object)new AcceptableValueRange(1, 3), Array.Empty())).Value; gridYCount = ((BaseUnityPlugin)this).Config.Bind("-|0|- General", "-| 2 Grid Y Max. Count", 5, new ConfigDescription("Amount of slots visible vertically", (AcceptableValueBase)(object)new AcceptableValueRange(3, 12), Array.Empty())).Value; stationColor = ((BaseUnityPlugin)this).Config.Bind("-|0|- General", "-| 3 Station Color", new Color(0.3726f, 0.8f, 1f, 1f), "Color tint of giga stations").Value; ilsMaxSlots = ((BaseUnityPlugin)this).Config.Bind("-|1|- ILS", "-| 1 Max. Item Slots", 12, new ConfigDescription("The maximum Item Slots the Station can have.\nVanilla: 5", (AcceptableValueBase)(object)new AcceptableValueRange(5, 12), Array.Empty())).Value; ilsMaxStorage = ((BaseUnityPlugin)this).Config.Bind("-|1|- ILS", "-| 2 Max. Storage", 30000, "The maximum Storage capacity per Item-Slot.\nVanilla: 10000").Value; ilsMaxVessels = ((BaseUnityPlugin)this).Config.Bind("-|1|- ILS", "-| 3 Max. Vessels", 30, new ConfigDescription("The maximum Logistic Vessels amount.\nVanilla: 10", (AcceptableValueBase)(object)new AcceptableValueRange(10, 30), Array.Empty())).Value; ilsMaxDrones = ((BaseUnityPlugin)this).Config.Bind("-|1|- ILS", "-| 4 Max. Drones", 150, new ConfigDescription("The maximum Logistic Drones amount.\nVanilla: 50", (AcceptableValueBase)(object)new AcceptableValueRange(50, 150), Array.Empty())).Value; ilsMaxAcuGJ = ((BaseUnityPlugin)this).Config.Bind("-|1|- ILS", "-| 5 Max. Accu Capacity (GJ)", 50, "The Stations maximum Accumulator Capacity in GJ.\nVanilla: 12 GJ").Value; ilsMaxWarps = ((BaseUnityPlugin)this).Config.Bind("-|1|- ILS", "-| 6 Max. Warps", 150, "The maximum Warp Cells amount.\nVanilla: 50").Value; plsMaxSlots = ((BaseUnityPlugin)this).Config.Bind("-|2|- PLS", "-| 1 Max. Item Slots", 12, new ConfigDescription("The maximum Item Slots the Station can have.\nVanilla: 3", (AcceptableValueBase)(object)new AcceptableValueRange(3, 12), Array.Empty())).Value; plsMaxStorage = ((BaseUnityPlugin)this).Config.Bind("-|2|- PLS", "-| 2 Max. Storage", 15000, "The maximum Storage capacity per Item-Slot.\nVanilla: 5000").Value; plsMaxDrones = ((BaseUnityPlugin)this).Config.Bind("-|2|- PLS", "-| 3 Max. Drones", 150, new ConfigDescription("The maximum Logistic Drones amount.\nVanilla: 50", (AcceptableValueBase)(object)new AcceptableValueRange(50, 150), Array.Empty())).Value; plsMaxAcuMJ = ((BaseUnityPlugin)this).Config.Bind("-|2|- PLS", "-| 4 Max. Accu Capacity (GJ)", 500, "The Stations maximum Accumulator Capacity in MJ.\nVanilla: 180 MJ").Value; colSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind("-|3|- Collector", "-| 1 Collect Speed Multiplier", 3, "Multiplier for the Orbital Collectors Collection-Speed.\nVanilla: 1").Value; colMaxStorage = ((BaseUnityPlugin)this).Config.Bind("-|3|- Collector", "-| 2 Max. Storage", 15000, "The maximum Storage capacity per Item-Slot.\nVanilla: 5000").Value; vesselCapacityMultiplier = ((BaseUnityPlugin)this).Config.Bind("-|4|- Vessel", "-| 1 Max. Capacity", 3, "Vessel Capacity Multiplier\n1 == 1000 Vessel Capacity at max Level").Value; droneCapacityMultiplier = ((BaseUnityPlugin)this).Config.Bind("-|5|- Drone", "-| 1 Max. Capacity", 3, "Drone Capacity Multiplier\n1 == 100 Drone Capacity at max Level").Value; LocalizationModule.RegisterTranslation("PLS_Name", "Planetary Giga Station"); LocalizationModule.RegisterTranslation("PLS_Desc", "Has more Slots, Capacity, etc. than a usual PLS."); LocalizationModule.RegisterTranslation("ILS_Name", "Interstellar Giga Station"); LocalizationModule.RegisterTranslation("ILS_Desc", "Has more Slots, Capacity, etc. than a usual ILS."); LocalizationModule.RegisterTranslation("Collector_Name", "Orbital Giga Collector"); LocalizationModule.RegisterTranslation("Collector_Desc", $"Has more Capacity and collects {colSpeedMultiplier}x faster than a usual Collector."); LocalizationModule.RegisterTranslation("ModificationWarn", " - [GigaStationsUpdated] Replaced {0} buildings"); LocalizationModule.RegisterTranslation("CantDowngradeWarn", "Downgrading logistic station is not possible!"); pls = ProtoRegistry.RegisterItem(2110, "PLS_Name", "PLS_Desc", "assets/gigastations/texture2d/icon_pls", 2701); ils = ProtoRegistry.RegisterItem(2111, "ILS_Name", "ILS_Desc", "assets/gigastations/texture2d/icon_ils", 2702); collector = ProtoRegistry.RegisterItem(2112, "Collector_Name", "Collector_Desc", "assets/gigastations/texture2d/icon_collector", 2703); collector.BuildInGas = true; ProtoRegistry.RegisterRecipe(410, (ERecipeType)4, 2400, new int[5] { 2103, 1103, 1106, 1303, 1206 }, new int[5] { 1, 40, 40, 40, 20 }, new int[1] { ((Proto)pls).ID }, new int[1] { 1 }, "PGS_Desc", 1604); ProtoRegistry.RegisterRecipe(411, (ERecipeType)4, 3600, new int[3] { 2110, 1107, 1206 }, new int[3] { 1, 40, 20 }, new int[1] { ((Proto)ils).ID }, new int[1] { 1 }, "ILS_Desc", 1605); ProtoRegistry.RegisterRecipe(412, (ERecipeType)4, 3600, new int[4] { 2111, 1205, 1406, 2207 }, new int[4] { 1, 50, 20, 20 }, new int[1] { ((Proto)collector).ID }, new int[1] { 1 }, "Collector_Desc", 1606); ProtoRegistry.RegisterRecipe(413, (ERecipeType)4, 3600, new int[4] { 2104, 1303, 1107, 1206 }, new int[4] { 1, 40, 40, 20 }, new int[1] { ((Proto)ils).ID }, new int[1] { 1 }, "ILS_Desc", 1605, 2704, "ILS_NameAltRecipe", ""); ProtoRegistry.RegisterRecipe(414, (ERecipeType)4, 3600, new int[4] { 2105, 1303, 1107, 1206 }, new int[4] { 1, 40, 40, 20 }, new int[1] { ((Proto)collector).ID }, new int[1] { 1 }, "Collector_Desc", 1606, 2705, "Collector_NameAltRecipe", ""); plsModel = ProtoRegistry.RegisterModel(460, pls, "Entities/Prefabs/logistic-station", (Material[])null, new int[5] { 24, 38, 12, 10, 1 }, 606, 2, new int[2] { 2103, 0 }); ilsModel = ProtoRegistry.RegisterModel(461, ils, "Entities/Prefabs/interstellar-logistic-station", (Material[])null, new int[5] { 24, 38, 12, 10, 1 }, 607, 2, new int[2] { 2104, 0 }); collectorModel = ProtoRegistry.RegisterModel(462, collector, "Entities/Prefabs/orbital-collector", (Material[])null, new int[4] { 18, 11, 32, 1 }, 608, 2, new int[2] { 2105, 0 }); ProtoRegistry.onLoadingFinished += AddGigaPLS; ProtoRegistry.onLoadingFinished += AddGigaILS; ProtoRegistry.onLoadingFinished += AddGigaCollector; Harmony val = new Harmony("org.kremnev8.plugin.GigaStationsUpdated"); val.PatchAll(typeof(StationEditPatch)); val.PatchAll(typeof(SaveFixPatch)); val.PatchAll(typeof(StationUpgradePatch)); val.PatchAll(typeof(UIStationWindowPatch)); val.PatchAll(typeof(BlueprintBuilding_Patch)); val.PatchAll(typeof(UIEntityBriefInfo_Patch)); val.PatchAll(typeof(UIControlPanelStationInspector_Patch)); val.PatchAll(typeof(UIControlPanelWindow_Patch)); foreach (KeyValuePair pluginInfo in Chainloader.PluginInfos) { if (pluginInfo.Value.Metadata.GUID != "ShadowAngel.DSP.DistributeSpaceWarper") { continue; } ((ConfigEntry)(object)pluginInfo.Value.Instance.Config["General", "ShowWarperSlot"]).Value = true; logger.LogInfo((object)"Overriding Distribute Space Warpers config: ShowWarperSlot = true"); break; } UtilSystem.AddLoadMessageHandler((Func)SaveFixPatch.GetFixMessage); logger.LogInfo((object)"GigaStations is initialized!"); } private void AddGigaPLS() { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) ColliderData[] buildColliders = plsModel.prefabDesc.buildColliders; logger.LogInfo((object)$"PLS build collider is null: {buildColliders == null}, length: {((buildColliders != null) ? buildColliders.Length : 0)}"); plsModel.prefabDesc.workEnergyPerTick = 3333334L; plsModel.prefabDesc.stationMaxItemCount = plsMaxStorage; plsModel.prefabDesc.stationMaxItemKinds = plsMaxSlots; plsModel.prefabDesc.stationMaxDroneCount = plsMaxDrones; plsModel.prefabDesc.stationMaxEnergyAcc = Convert.ToInt64(plsMaxAcuMJ * 1000000); Material val = Object.Instantiate(plsModel.prefabDesc.lodMaterials[0][0]); val.color = stationColor; plsModel.prefabDesc.lodMaterials[0][0] = val; } private void AddGigaILS() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) ColliderData[] buildColliders = ilsModel.prefabDesc.buildColliders; logger.LogInfo((object)$"ILS build collider is null: {buildColliders == null}, length: {((buildColliders != null) ? buildColliders.Length : 0)}"); ilsModel.prefabDesc.workEnergyPerTick = 3333334L; ilsModel.prefabDesc.stationMaxItemCount = ilsMaxStorage; ilsModel.prefabDesc.stationMaxItemKinds = ilsMaxSlots; ilsModel.prefabDesc.stationMaxDroneCount = ilsMaxDrones; ilsModel.prefabDesc.stationMaxShipCount = ilsMaxVessels; ilsModel.prefabDesc.stationMaxEnergyAcc = Convert.ToInt64(ilsMaxAcuGJ * 1000000000); Material val = Object.Instantiate(ilsModel.prefabDesc.lodMaterials[0][0]); val.color = stationColor; ilsModel.prefabDesc.lodMaterials[0][0] = val; } private void AddGigaCollector() { //IL_009e: Unknown result type (might be due to invalid IL or missing references) ItemProto val = ((ProtoSet)(object)LDB.items).Select(2105); collectorModel.prefabDesc.stationMaxItemCount = colMaxStorage; collectorModel.prefabDesc.stationCollectSpeed = val.prefabDesc.stationCollectSpeed * colSpeedMultiplier; PrefabDesc prefabDesc = collectorModel.prefabDesc; prefabDesc.workEnergyPerTick /= ((val.prefabDesc.workEnergyPerTick / colSpeedMultiplier >= 0) ? colSpeedMultiplier : val.prefabDesc.workEnergyPerTick); Material val2 = Object.Instantiate(collectorModel.prefabDesc.lodMaterials[0][0]); val2.color = stationColor; collectorModel.prefabDesc.lodMaterials[0][0] = val2; } } [BepInPlugin("org.kremnev8.plugin.GigaStationsNebulaCompat", "Giga Stations Nebula Compatibility", "2.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class NebulaCompat : BaseUnityPlugin { public const string MOD_GUID = "org.kremnev8.plugin.GigaStationsNebulaCompat"; public const string MOD_NAME = "Giga Stations Nebula Compatibility"; private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown if (NebulaModAPI.NebulaIsInstalled) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Patching NebulaWorld!"); Harmony val = new Harmony("org.kremnev8.plugin.GigaStationsNebulaCompat"); MethodInfo method = AccessTools.TypeByName("NebulaWorld.Logistics.StationUIManager").GetMethod("UpdateSettingsUI", AccessTools.all); if (method == null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Error: Not found NebulaWorld.Logistics.StationUIManager. There might be issues!"); return; } MethodInfo method2 = typeof(NebulaCompatPatches).GetMethod("Replace10With1Transpiler"); val.Patch((MethodBase)method, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Success! Nebula Compat is ready!"); } } public static class NebulaCompatPatches { public static IEnumerable Replace10With1Transpiler(IEnumerable instructions) { //IL_0003: 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_0036: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(StationComponent), "deliveryDrones"), (string)null) }).MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_R4 && Mathf.Approximately((float)instr.operand, 10f)), (string)null) }).SetOperandAndAdvance((object)1f); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(StationComponent), "deliveryShips"), (string)null) }).MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_R4 && Mathf.Approximately((float)instr.operand, 10f)), (string)null) }).SetOperandAndAdvance((object)1f); return val.InstructionEnumeration(); } } [HarmonyPatch] public static class BlueprintBuilding_Patch { [HarmonyPatch(typeof(BlueprintBuilding), "Import")] [HarmonyPostfix] public static void UpdateBlueprintData(BlueprintBuilding __instance) { if (__instance.itemId == ((Proto)GigaStationsPlugin.ils).ID || __instance.itemId == ((Proto)GigaStationsPlugin.pls).ID || __instance.itemId == ((Proto)GigaStationsPlugin.collector).ID) { ItemProto val = ((ProtoSet)(object)LDB.items).Select((int)__instance.itemId); __instance.modelIndex = (short)val.prefabDesc.modelIndex; } } } [HarmonyPatch] public static class SaveFixPatch { public static int updateCounter; [HarmonyPatch(typeof(EntityData), "Import")] [HarmonyPostfix] public static void Postfix(ref EntityData __instance) { int protoId = __instance.protoId; int modelIndex = __instance.modelIndex; if (protoId == ((Proto)GigaStationsPlugin.pls).ID) { if (modelIndex != ((Proto)GigaStationsPlugin.plsModel).ID) { __instance.modelIndex = (short)((Proto)GigaStationsPlugin.plsModel).ID; updateCounter++; } } else if (protoId == ((Proto)GigaStationsPlugin.ils).ID) { if (modelIndex != ((Proto)GigaStationsPlugin.ilsModel).ID) { __instance.modelIndex = (short)((Proto)GigaStationsPlugin.ilsModel).ID; updateCounter++; } } else if (protoId == ((Proto)GigaStationsPlugin.collector).ID && modelIndex != ((Proto)GigaStationsPlugin.collectorModel).ID) { __instance.modelIndex = (short)((Proto)GigaStationsPlugin.collectorModel).ID; updateCounter++; } } internal static string GetFixMessage() { if (updateCounter <= 0) { return ""; } return string.Format(Localization.Translate("ModificationWarn"), updateCounter); } } [HarmonyPatch] public static class StationEditPatch { public delegate void RefAction(T1 arg, ref T2 arg2); private static readonly Dictionary storeToLoad = new Dictionary { { OpCodes.Stloc_0, OpCodes.Ldloc_0 }, { OpCodes.Stloc_1, OpCodes.Ldloc_1 }, { OpCodes.Stloc_2, OpCodes.Ldloc_2 }, { OpCodes.Stloc_3, OpCodes.Ldloc_3 }, { OpCodes.Stloc, OpCodes.Ldloc }, { OpCodes.Stloc_S, OpCodes.Ldloc_S } }; [HarmonyPostfix] [HarmonyPatch(typeof(UIRoot), "OnGameMainObjectCreated")] public static void OnGameMainObjectCreatedPostfix(UIRoot __instance) { CalculateCarrierCapacity(); } public static CodeMatcher MoveToLabel(this CodeMatcher matcher, Label label) { while (!matcher.Labels.Contains(label)) { matcher.Advance(1); } return matcher; } public static OpCode ToLoad(this OpCode opCode) { if (Enumerable.Contains(storeToLoad.Keys, opCode)) { return storeToLoad[opCode]; } throw new ArgumentException("Can't convert instruction " + opCode.ToString() + " to a load instruction!"); } [HarmonyTranspiler] [HarmonyPatch(typeof(GameHistoryData), "UnlockTechFunction")] public static IEnumerable MultiplyTechValues(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Switch, (object)null, (string)null) }); Label[] array = (Label[])val.Operand; val.MoveToLabel(array[17]).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Func)(() => GigaStationsPlugin.droneCapacityMultiplier)) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Mul, (object)null) }); val.MoveToLabel(array[18]).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Func)(() => GigaStationsPlugin.vesselCapacityMultiplier)) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Mul, (object)null) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(TechProto), "UnlockFunctionText")] public static IEnumerable MultiplyUnlockText(IEnumerable instructions) { //IL_0003: 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_0036: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TechProto), "UnlockFunctions"), (string)null) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func)((CodeInstruction instr) => CodeInstructionExtensions.IsStloc(instr, (LocalBuilder)null)), (string)null) }); OpCode opCode = val.Opcode.ToLoad(); object operand = val.Operand; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TechProto), "UnlockValues"), (string)null) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }); object operand2 = val.Operand; val.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(opCode, operand) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldloca_S, operand2) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((RefAction)delegate(int type, ref int value) { switch (type) { case 18: value *= GigaStationsPlugin.droneCapacityMultiplier; break; case 19: value *= GigaStationsPlugin.vesselCapacityMultiplier; break; } }) }); return val.InstructionEnumeration(); } private static void CalculateCarrierCapacity() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) int logisticDroneCarries = 25 * GigaStationsPlugin.droneCapacityMultiplier; int logisticShipCarries = 200 * GigaStationsPlugin.vesselCapacityMultiplier; int num = 0; for (int i = 3501; i <= 3510; i++) { if (GameMain.history.TechUnlocked(i)) { TechProto val = ((ProtoSet)(object)LDB.techs).Select(i); num = GameMain.history.techStates[i].curLevel; int levels = 1; if (val.Level != val.MaxLevel) { levels = num - val.Level + 1; } for (int j = 0; j < val.UnlockFunctions.Length; j++) { Accumulate(val.UnlockFunctions[j], val.UnlockValues[j], levels); } } } GigaStationsPlugin.logger.LogInfo((object)$"\nUnlocked Logistic carrier capacity Level {num}\nSetting Carrier Capacity Multipliers from settings..."); GigaStationsPlugin.logger.LogInfo((object)$"\nLevel {num}\nSetting Vessels Capacity: {logisticShipCarries}\nSetting Drones Capacity: {logisticDroneCarries}"); GameMain.history.logisticDroneCarries = logisticDroneCarries; GameMain.history.logisticShipCarries = logisticShipCarries; void Accumulate(int type, double value, int num3) { int num2 = (int)Math.Round(value); switch (type) { case 18: logisticDroneCarries += num2 * GigaStationsPlugin.droneCapacityMultiplier * num3; break; case 19: logisticShipCarries += num2 * GigaStationsPlugin.vesselCapacityMultiplier * num3; break; } } } [HarmonyPrefix] [HarmonyPatch(typeof(PowerSystem), "NewConsumerComponent")] public static bool NewConsumerComponentPrefix(PowerSystem __instance, ref int entityId, ref long work, ref long idle) { int iD = ((Proto)((ProtoSet)(object)LDB.items).Select((int)__instance.factory.entityPool[entityId].protoId)).ID; if (iD != ((Proto)GigaStationsPlugin.ils).ID && iD != ((Proto)GigaStationsPlugin.pls).ID) { return true; } work = 1000000L; return true; } [HarmonyPostfix] [HarmonyPatch(typeof(StationComponent), "Init")] public static void StationComponentInitPostfix(StationComponent __instance, ref int _id, ref int _entityId, ref int _pcId, ref PrefabDesc _desc, ref EntityData[] _entityPool) { __instance.needs = new int[13]; int num = Math.Max(5, Math.Max(GigaStationsPlugin.plsMaxSlots, GigaStationsPlugin.ilsMaxSlots)); __instance.priorityLocks = (StationPriorityLock[])(object)new StationPriorityLock[num]; short protoId = _entityPool[_entityId].protoId; if (protoId == ((Proto)GigaStationsPlugin.ils).ID || protoId == ((Proto)GigaStationsPlugin.pls).ID || protoId == ((Proto)GigaStationsPlugin.collector).ID) { if (!__instance.isStellar && !__instance.isCollector) { _desc.stationMaxEnergyAcc = Convert.ToInt64(GigaStationsPlugin.plsMaxAcuMJ * 1000000); __instance.energyMax = GigaStationsPlugin.plsMaxAcuMJ * 1000000; __instance.storage = (StationStore[])(object)new StationStore[GigaStationsPlugin.plsMaxSlots]; __instance.energyPerTick = 1000000L; } else if (__instance.isStellar && !__instance.isCollector) { _desc.stationMaxEnergyAcc = Convert.ToInt64(GigaStationsPlugin.ilsMaxAcuGJ * 1000000000); __instance.energyMax = GigaStationsPlugin.ilsMaxAcuGJ * 1000000000; __instance.warperMaxCount = GigaStationsPlugin.ilsMaxWarps; __instance.storage = (StationStore[])(object)new StationStore[GigaStationsPlugin.ilsMaxSlots]; __instance.energyPerTick = 1000000L; } } } [HarmonyTranspiler] [HarmonyPatch(typeof(StationComponent), "Import")] public static IEnumerable StationImportTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); FieldInfo fieldInfo = AccessTools.Field(typeof(StationComponent), "storage"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(StationComponent), "priorityLocks"); FieldInfo fieldInfo3 = AccessTools.Field(typeof(StationComponent), "needs"); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((Func)((CodeInstruction instruction) => CodeInstructionExtensions.IsLdloc(instruction, (LocalBuilder)null)), (string)null), new CodeMatch((OpCode?)OpCodes.Newarr, (object)typeof(StationPriorityLock), (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)fieldInfo2, (string)null) }).Advance(2).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Func)GetLocksCount) }); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null), new CodeMatch((OpCode?)OpCodes.Ldlen, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_I4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Newarr, (object)typeof(StationPriorityLock), (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)fieldInfo2, (string)null) }).Advance(4).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Func)GetLocksCount) }); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Newarr, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)fieldInfo3, (string)null) }).Advance(1).Set(OpCodes.Ldc_I4, (object)13); return val.InstructionEnumeration(); } private static int GetLocksCount(int prevCount) { return Math.Max(prevCount, Math.Max(GigaStationsPlugin.plsMaxSlots, GigaStationsPlugin.ilsMaxSlots)); } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetTransport), "Import")] [HarmonyDebug] public static IEnumerable PlanetImportTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(StationComponent), "Import", (Type[])null, (Type[])null), (string)null) }); val.Advance(2).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }).Advance(4) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)delegate(PlanetTransport planet, StationComponent station) { short protoId = planet.factory.entityPool[station.entityId].protoId; if (protoId == ((Proto)GigaStationsPlugin.ils).ID || protoId == ((Proto)GigaStationsPlugin.pls).ID || protoId == ((Proto)GigaStationsPlugin.collector).ID) { if (!station.isStellar && !station.isCollector) { station.priorityLocks = (StationPriorityLock[])(object)new StationPriorityLock[GigaStationsPlugin.plsMaxSlots]; } else if (station.isStellar && !station.isCollector) { station.priorityLocks = (StationPriorityLock[])(object)new StationPriorityLock[GigaStationsPlugin.ilsMaxSlots]; } } }) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlanetTransport), "stationPool")), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Ldelem_Ref, (object)null) }); return val.InstructionEnumeration(); } [HarmonyPrefix] [HarmonyPatch(typeof(StationComponent), "UpdateNeeds")] public static bool UpdateNeeds(StationComponent __instance) { int num = __instance.storage.Length; if (num > 12) { num = 12; } for (int i = 0; i <= num; i++) { if (i == num && !__instance.isCollector) { __instance.needs[num] = ((__instance.isStellar && __instance.warperCount < __instance.warperMaxCount) ? 1210 : 0); } else if (i < __instance.needs.Length) { __instance.needs[i] = ((i < num && __instance.storage[i].count < __instance.storage[i].max) ? __instance.storage[i].itemId : 0); } } return false; } [HarmonyTranspiler] [HarmonyPatch(typeof(StationComponent), "UpdateInputSlots")] public static IEnumerable UpdateInputSlotsTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(StationComponent), "needs"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_5, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldelem_I4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Func)delegate(StationComponent component) { int num = 0; for (int i = 6; i < component.needs.Length; i++) { num += component.needs[i]; } return num; }) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Add, (object)null) }); return val.InstructionEnumeration(); } [HarmonyPrefix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static bool TryPickItemAtRear(CargoPath __instance, int[] needs, out int needIdx, out byte stack, out byte inc, ref int __result) { needIdx = -1; stack = 1; inc = 0; int num = __instance.bufferLength - 5 - 1; if (__instance.buffer[num] == 250) { int num2 = __instance.buffer[num + 1] - 1 + (__instance.buffer[num + 2] - 1) * 100 + (__instance.buffer[num + 3] - 1) * 10000 + (__instance.buffer[num + 4] - 1) * 1000000; int item = __instance.cargoContainer.cargoPool[num2].item; stack = __instance.cargoContainer.cargoPool[num2].stack; inc = __instance.cargoContainer.cargoPool[num2].inc; for (int i = 0; i < needs.Length; i++) { if (item == needs[i]) { Array.Clear(__instance.buffer, num - 4, 10); int num3 = num + 5 + 1; if (__instance.updateLen < num3) { __instance.updateLen = num3; } __instance.cargoContainer.RemoveCargo(num2); needIdx = i; __result = item; return false; } } } __result = 0; return false; } [HarmonyPrefix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static bool TakeItemPrefix(StationComponent __instance, ref int _itemId, ref int _count, ref int[] _needs, out int _inc) { _inc = 0; bool flag = false; if (_needs == null) { flag = true; } else { int[] array = _needs; foreach (int num in array) { if (num == _itemId) { flag = true; } } } if (_itemId > 0 && _count > 0 && flag) { StationStore[] storage = __instance.storage; lock (storage) { int num2 = __instance.storage.Length; for (int j = 0; j < num2; j++) { if (__instance.storage[j].itemId == _itemId && __instance.storage[j].count > 0) { _count = ((_count >= __instance.storage[j].count) ? __instance.storage[j].count : _count); _itemId = __instance.storage[j].itemId; _inc = (int)((double)__instance.storage[j].inc / (double)__instance.storage[j].count * (double)_count + 0.5); StationStore[] storage2 = __instance.storage; storage2[j].count -= _count; storage2[j].inc -= _inc; return false; } } } } _itemId = 0; _count = 0; _inc = 0; return false; } [HarmonyPrefix] [HarmonyPatch(typeof(StationComponent), "AddItem")] public static bool AddItemPrefix(StationComponent __instance, int itemId, int count, int inc, ref int __result) { __result = 0; if (itemId <= 0) { return false; } StationStore[] storage = __instance.storage; lock (storage) { for (int i = 0; i < __instance.storage.Length; i++) { if (__instance.storage[i].itemId == itemId) { StationStore[] storage2 = __instance.storage; storage2[i].count += count; storage2[i].inc += inc; __result = count; return false; } } } return false; } } [HarmonyPatch] public static class StationUpgradePatch { public static void UpdateArray(ref T[] array, int newSize) { T[] array2 = array; array = new T[newSize]; Array.Copy(array2, array, array2.Length); } [HarmonyPatch(typeof(PlanetFactory), "UpgradeEntityWithComponents")] [HarmonyPostfix] public static void Postfix(int entityId, ItemProto newProto, PlanetFactory __instance) { //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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_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_01fc: 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_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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) if (entityId == 0 || __instance.entityPool[entityId].id == 0) { return; } int stationId = __instance.entityPool[entityId].stationId; if (stationId <= 0) { return; } StationComponent val = __instance.transport.stationPool[stationId]; PrefabDesc prefabDesc = newProto.prefabDesc; int newSize = (val.isStellar ? GigaStationsPlugin.ilsMaxSlots : GigaStationsPlugin.plsMaxSlots); UpdateArray(ref val.storage, newSize); if (val.needs.Length != 13) { UpdateArray(ref val.needs, 13); } if (val.isCollector) { val.collectSpeed = prefabDesc.stationCollectSpeed; return; } val.energyPerTick = 1000000L; UpdateArray(ref val.workDroneDatas, prefabDesc.stationMaxDroneCount); UpdateArray(ref val.workDroneOrders, prefabDesc.stationMaxDroneCount); if (val.isStellar) { UpdateArray(ref val.workShipDatas, prefabDesc.stationMaxShipCount); UpdateArray(ref val.workShipOrders, prefabDesc.stationMaxShipCount); UpdateArray(ref val.shipRenderers, prefabDesc.stationMaxShipCount); UpdateArray(ref val.shipUIRenderers, prefabDesc.stationMaxShipCount); val.shipDiskPos = (Vector3[])(object)new Vector3[prefabDesc.stationMaxShipCount]; val.shipDiskRot = (Quaternion[])(object)new Quaternion[prefabDesc.stationMaxShipCount]; int num = val.workShipDatas.Length; for (int i = 0; i < num; i++) { val.shipDiskRot[i] = Quaternion.Euler(0f, 360f / (float)num * (float)i, 0f); val.shipDiskPos[i] = val.shipDiskRot[i] * new Vector3(0f, 0f, 11.5f); } for (int j = 0; j < num; j++) { val.shipDiskRot[j] = val.shipDockRot * val.shipDiskRot[j]; val.shipDiskPos[j] = val.shipDockPos + val.shipDockRot * val.shipDiskPos[j]; } val.energyMax = GigaStationsPlugin.ilsMaxAcuGJ * 1000000000; val.warperMaxCount = GigaStationsPlugin.ilsMaxWarps; } else { val.energyMax = GigaStationsPlugin.plsMaxAcuMJ * 1000000; } } [HarmonyPatch(typeof(PlayerAction_Build), "DoUpgradeObject")] [HarmonyPrefix] public static bool CheckIfCanUpgrade(PlayerAction_Build __instance, int objId, int grade, int upgrade, ref bool __result) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) ItemProto itemProto = ((BuildTool)__instance.noneTool).GetItemProto(objId); if (((Proto)itemProto).ID != ((Proto)GigaStationsPlugin.ils).ID && ((Proto)itemProto).ID != ((Proto)GigaStationsPlugin.pls).ID && ((Proto)itemProto).ID != ((Proto)GigaStationsPlugin.collector).ID) { return true; } if (grade == 1 || upgrade < 0) { __result = false; VFAudio.Create("ui-error", (Transform)null, Vector3.zero, true, 5, -1, -1L); if (VFInput._buildConfirm.onDown || GameMain.gameTick % 10 == 0) { UIRealtimeTip.Popup(Localization.Translate("CantDowngradeWarn"), false, 0); } return false; } return true; } } [HarmonyPatch] public static class UIControlPanelStationInspector_Patch { private static readonly Dictionary storeToOperand = new Dictionary { { OpCodes.Stloc_0, 0 }, { OpCodes.Stloc_1, 1 }, { OpCodes.Stloc_2, 2 }, { OpCodes.Stloc_3, 3 } }; [HarmonyTranspiler] [HarmonyPatch(typeof(UIControlPanelStationInspector), "_OnCreate")] public static IEnumerable EditUIControlPanel(IEnumerable instructions) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null) }); int needCount = Mathf.Max(GigaStationsPlugin.plsMaxSlots, GigaStationsPlugin.ilsMaxSlots); val.Repeat((Action)delegate(CodeMatcher codeMatcher) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown codeMatcher.SetInstruction(new CodeInstruction(OpCodes.Ldc_I4_S, (object)needCount)); }, (Action)null); return val.InstructionEnumeration(); } private static int ToLocalNum(this CodeInstruction codeInstruction) { if (storeToOperand.TryGetValue(codeInstruction.opcode, out var value)) { return value; } return (int)codeInstruction.operand; } [HarmonyTranspiler] [HarmonyPatch(typeof(UIControlPanelStationInspector), "_OnUpdate")] public static IEnumerable HandleUIResize(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((Func)((CodeInstruction i) => CodeInstructionExtensions.IsStloc(i, (LocalBuilder)null)), (string)null) }); object obj = val.Instruction.ToLocalNum(); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)delegate(UIControlPanelStationInspector inspector) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) inspector.stationGroupContentRect.anchorMin = new Vector2(0f, 1f); }) }); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(UIControlPanelStationInspector), "veinCollectorPanel"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null) }); val.Advance(1); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloca_S, obj) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((StationEditPatch.RefAction)delegate(UIControlPanelStationInspector inspector, ref int extraSize) { //IL_0013: 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) Transform transform = ((Component)inspector.storageUIPrefab).transform; RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null); float num = val2.sizeDelta.y + 6f; int num2 = inspector.station.storage.Length; int num3 = num2 - 6; if (num3 > 0) { inspector.stationGroupContentRect.anchorMin = new Vector2(0f, 0f); extraSize = Mathf.RoundToInt((float)num3 * num) + 30; } }) }); return val.InstructionEnumeration(); } } [HarmonyPatch] public static class UIControlPanelWindow_Patch { [HarmonyPatch(typeof(UIControlPanelWindow), "_OnInit")] [HarmonyPostfix] public static void OnInit(UIControlPanelWindow __instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0043: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) int num = Math.Max(5, Math.Max(GigaStationsPlugin.plsMaxSlots, GigaStationsPlugin.ilsMaxSlots)); if (num != 5) { int num2 = (num - 5) * 50 - 100; RectTransform val = (RectTransform)((Component)__instance).transform; val.sizeDelta = new Vector2((float)(1470 + num2), val.sizeDelta.y); RectTransform val2 = (RectTransform)((Component)__instance.leftScrollRect).transform.parent; val2.sizeDelta = new Vector2((float)(850 + num2), val2.sizeDelta.y); } } [HarmonyPatch(typeof(UIControlPanelStationEntry), "_OnCreate")] [HarmonyPostfix] public static void OnStationItemCreate(UIControlPanelStationEntry __instance) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) int num = Math.Max(5, Math.Max(GigaStationsPlugin.plsMaxSlots, GigaStationsPlugin.ilsMaxSlots)); if (num != 5) { int num2 = (num - 5) * 50 - 100; RectTransform val = (RectTransform)((Component)__instance.powerGroup).transform; ((Transform)val).localPosition = ((Transform)val).localPosition + new Vector3((float)(62 + num2), 0f, 0f); RectTransform val2 = (RectTransform)__instance.droneGroupGo.transform.parent; ((Transform)val2).localPosition = ((Transform)val2).localPosition + new Vector3((float)(62 + num2), 0f, 0f); GameObject gameObject = ((Component)__instance.storageItem4).gameObject; Transform parent = gameObject.transform.parent; int num3 = num - 5; for (int i = 0; i < num3; i++) { GameObject val3 = Object.Instantiate(gameObject, parent, true); RectTransform val4 = (RectTransform)val3.transform; UIControlPanelStorageItem component = val3.GetComponent(); __instance.extraStorageItems.Add(component); component.index = 5 + i; ((Transform)val4).localPosition = ((Transform)val4).localPosition + new Vector3((float)(50 * (i + 1)), 0f, 0f); } } } [HarmonyPatch(typeof(UIControlPanelAdvancedMinerEntry), "_OnCreate")] [HarmonyPostfix] public static void OnAdvMinerItemCreate(UIControlPanelAdvancedMinerEntry __instance) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) int num = Math.Max(5, Math.Max(GigaStationsPlugin.plsMaxSlots, GigaStationsPlugin.ilsMaxSlots)); if (num != 5) { int num2 = (num - 5) * 50 - 100; RectTransform val = (RectTransform)__instance.powerGroupGo.transform; ((Transform)val).localPosition = ((Transform)val).localPosition + new Vector3((float)(62 + num2), 0f, 0f); } } [HarmonyPatch(typeof(UIControlPanelStationEntry), "UpdateItems")] [HarmonyPostfix] public static void OnUpdateItems(UIControlPanelStationEntry __instance) { if (!((UIControlPanelObjectEntry)__instance).isTargetDataValid) { return; } int num = Math.Max(5, Math.Max(GigaStationsPlugin.plsMaxSlots, GigaStationsPlugin.ilsMaxSlots)); if (num != 5) { StationStore[] storage = __instance.station.storage; for (int i = 0; i < __instance.extraStorageItems.Count; i++) { UIControlPanelStorageItem val = __instance.extraStorageItems[i]; int num2 = 5 + i; val.SetVisible(storage.Length > num2 && storage[num2].itemId > 0); val._Update(); } } } [HarmonyPatch(typeof(UIControlPanelStationEntry), "OnSetTarget")] [HarmonyPostfix] public static void OnSetTarget(UIControlPanelStationEntry __instance) { for (int i = 0; i < __instance.extraStorageItems.Count; i++) { UIControlPanelStorageItem val = __instance.extraStorageItems[i]; val.station = __instance.station; } } [HarmonyPatch(typeof(UIControlPanelStationEntry), "OnUnsetTarget")] [HarmonyPostfix] public static void OnUnsetTarget(UIControlPanelStationEntry __instance) { for (int i = 0; i < __instance.extraStorageItems.Count; i++) { UIControlPanelStorageItem val = __instance.extraStorageItems[i]; val.station = null; } } } [HarmonyPatch] public static class UIEntityBriefInfo_Patch { [HarmonyPatch(typeof(UIEntityBriefInfo), "_OnCreate")] [HarmonyPrefix] public static void ResizeArray(UIEntityBriefInfo __instance) { int num = Math.Max(GigaStationsPlugin.ilsMaxSlots, GigaStationsPlugin.plsMaxSlots); if (num > __instance.icons.Length) { Array.Resize(ref __instance.icons, num); } } } [HarmonyPatch] public static class UIStationWindowPatch { public static RectTransform contentTrs; public static RectTransform scrollTrs; [HarmonyTranspiler] [HarmonyPatch(typeof(UIStationWindow), "OnMinDeliverVesselValueChange")] [HarmonyPatch(typeof(UIStationWindow), "OnMinDeliverDroneValueChange")] public static IEnumerable Replace10With1Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_R4 && Mathf.Approximately((float)instr.operand, 10f)), (string)null) }).SetOperandAndAdvance((object)1f); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(UIStationWindow), "OnStationIdChange")] public static IEnumerable RemoveDivisionBy10(IEnumerable instructions) { //IL_0003: 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_0036: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(StationComponent), "deliveryDrones"), (string)null) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_R4 && Mathf.Approximately((float)instr.operand, 0.1f)), (string)null) }).SetAndAdvance(OpCodes.Nop, (object)null) .Advance(2) .SetAndAdvance(OpCodes.Nop, (object)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(StationComponent), "deliveryShips"), (string)null) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_R4 && Mathf.Approximately((float)instr.operand, 0.1f)), (string)null) }).SetAndAdvance(OpCodes.Nop, (object)null) .Advance(2) .SetAndAdvance(OpCodes.Nop, (object)null); return val.InstructionEnumeration(); } [HarmonyPrefix] [HarmonyPatch(typeof(UIStationWindow), "OnStationIdChange")] [HarmonyPriority(0)] public static void OnStationIdChangePre(UIStationWindow __instance, ref string __state) { if (__instance.stationId != 0 && __instance.factory != null && __instance.transport?.stationPool != null) { StationComponent val = __instance.transport.stationPool[__instance.stationId]; ItemProto val2 = ((ProtoSet)(object)LDB.items).Select((int)__instance.factory.entityPool[val.entityId].protoId); if ((((Proto)val2).ID == ((Proto)GigaStationsPlugin.pls).ID || ((Proto)val2).ID == ((Proto)GigaStationsPlugin.ils).ID || ((Proto)val2).ID == ((Proto)GigaStationsPlugin.collector).ID) && ((ManualBehaviour)__instance).active) { string text = __instance.factory.ReadExtraInfoOnEntity(val.entityId); string text2 = ((!string.IsNullOrEmpty(text)) ? text : ((!val.isStellar) ? ("Planetary Giga Station #" + val.id) : ((!val.isCollector) ? ("Interstellar Giga Station #" + val.gid) : ("Orbital Giga Collector #" + val.gid)))); __state = text2; } } } [HarmonyPostfix] [HarmonyPatch(typeof(UIStationWindow), "OnStationIdChange")] public static void OnStationIdChangePost(UIStationWindow __instance, string __state) { //IL_00dd: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0158: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0361: 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_032b: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) if (__instance.stationId == 0 || __instance.factory == null || __instance.transport?.stationPool == null) { return; } StationComponent val = __instance.transport.stationPool[__instance.stationId]; ItemProto val2 = ((ProtoSet)(object)LDB.items).Select((int)__instance.factory.entityPool[val.entityId].protoId); int num = ((val.isCollector || val.isVeinCollector) ? val.collectionIds.Length : val.storage.Length); int num2 = (val.isStellar ? 376 : 316); if (val.isCollector) { num2 = 136; } else if (val.isVeinCollector) { num2 = 289; } ((RectTransform)((Component)__instance.storageUIs[0]).transform).anchoredPosition = new Vector2(0f, 0f); int num3 = (val.isVeinCollector ? (-190) : (-90)); scrollTrs.anchoredPosition = new Vector2(scrollTrs.anchoredPosition.x, (float)num3); __instance.panelDownTrans.anchoredPosition = new Vector2(__instance.panelDownTrans.anchoredPosition.x, __instance.panelDownTrans.anchoredPosition.y - 10f); if (((Proto)val2).ID != ((Proto)GigaStationsPlugin.pls).ID && ((Proto)val2).ID != ((Proto)GigaStationsPlugin.ils).ID && ((Proto)val2).ID != ((Proto)GigaStationsPlugin.collector).ID) { UIStationStorage[] storageUIs = __instance.storageUIs; foreach (UIStationStorage val3 in storageUIs) { val3.popupBoxRect.anchoredPosition = new Vector2(5f, 0f); } scrollTrs.sizeDelta = new Vector2(scrollTrs.sizeDelta.x, (float)(76 * num)); contentTrs.sizeDelta = new Vector2(contentTrs.sizeDelta.x, (float)(76 * num)); int num4 = num2 + 76 * num; __instance.windowTrans.sizeDelta = new Vector2(600f, (float)num4); return; } __instance.nameInput.text = __state; if (!((ManualBehaviour)__instance).active) { return; } int num5 = num; int num6 = 600; if (GigaStationsPlugin.gridXCount > 1) { int num7 = 526 * (GigaStationsPlugin.gridXCount - 1); num6 += num7; num5 = num / GigaStationsPlugin.gridXCount; UIStationStorage[] storageUIs2 = __instance.storageUIs; foreach (UIStationStorage val4 in storageUIs2) { val4.popupBoxRect.anchoredPosition = new Vector2(-200f, 0f); } bool logisticShipWarpDrive = GameMain.history.logisticShipWarpDrive; __instance.powerGroupRect.sizeDelta = new Vector2(((!val.isStellar) ? 440f : (logisticShipWarpDrive ? 320f : 380f)) + (float)num7, 40f); } else { UIStationStorage[] storageUIs3 = __instance.storageUIs; foreach (UIStationStorage val5 in storageUIs3) { val5.popupBoxRect.anchoredPosition = new Vector2(5f, 0f); } } int num8 = ((num5 > GigaStationsPlugin.gridYCount) ? GigaStationsPlugin.gridYCount : num5); int num9 = num2 + 76 * num8; __instance.windowTrans.sizeDelta = new Vector2((float)num6, (float)num9); int num10 = ((num5 < GigaStationsPlugin.gridYCount) ? num5 : GigaStationsPlugin.gridYCount); scrollTrs.sizeDelta = new Vector2(scrollTrs.sizeDelta.x, (float)(76 * num10)); contentTrs.sizeDelta = new Vector2(contentTrs.sizeDelta.x, (float)(76 * num5)); for (int l = 0; l < __instance.storageUIs.Length; l++) { if (l < num) { __instance.storageUIs[l].station = val; __instance.storageUIs[l].index = l; ((ManualBehaviour)__instance.storageUIs[l])._Open(); } else { __instance.storageUIs[l].station = null; __instance.storageUIs[l].index = 0; ((ManualBehaviour)__instance.storageUIs[l])._Close(); } __instance.storageUIs[l].ClosePopMenu(); } } [HarmonyTranspiler] [HarmonyPatch(typeof(UIStationWindow), "RefreshTrans")] public static IEnumerable RefreshTransChanger(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(StationComponent), "collectionIds"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldlen, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_I4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_2, (object)null, (string)null) }); val.Advance(1); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloc_2, (object)null), new CodeInstruction(OpCodes.Ldarg_1, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Func)delegate(int count, StationComponent station, UIStationWindow stationUI) { ItemProto val2 = ((ProtoSet)(object)LDB.items).Select((int)stationUI.factory.entityPool[station.entityId].protoId); if (((Proto)val2).ID != ((Proto)GigaStationsPlugin.pls).ID && ((Proto)val2).ID != ((Proto)GigaStationsPlugin.ils).ID && ((Proto)val2).ID != ((Proto)GigaStationsPlugin.collector).ID) { return count; } int num = count; if (GigaStationsPlugin.gridXCount > 1) { num = count / GigaStationsPlugin.gridXCount; } return (num > GigaStationsPlugin.gridYCount) ? GigaStationsPlugin.gridYCount : num; }) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Stloc_2, (object)null) }); return val.InstructionEnumeration(); } [HarmonyPostfix] [HarmonyPatch(typeof(UIStationWindow), "RefreshTrans")] public static void OnRefreshTrans(UIStationWindow __instance, StationComponent station) { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) ItemProto val = ((ProtoSet)(object)LDB.items).Select((int)__instance.factory.entityPool[station.entityId].protoId); if ((((Proto)val).ID == ((Proto)GigaStationsPlugin.pls).ID || ((Proto)val).ID == ((Proto)GigaStationsPlugin.ils).ID || ((Proto)val).ID == ((Proto)GigaStationsPlugin.collector).ID) && ((ManualBehaviour)__instance).active) { int num = ((station.isCollector || station.isVeinCollector) ? station.collectionIds.Length : station.storage.Length); int num2 = num; int num3 = 600; if (GigaStationsPlugin.gridXCount > 1) { int num4 = 526 * (GigaStationsPlugin.gridXCount - 1); num3 += num4; num2 = num / GigaStationsPlugin.gridXCount; } __instance.windowTrans.sizeDelta = new Vector2((float)num3, __instance.windowTrans.sizeDelta.y); int num5 = ((num2 < GigaStationsPlugin.gridYCount) ? num2 : GigaStationsPlugin.gridYCount); scrollTrs.sizeDelta = new Vector2(scrollTrs.sizeDelta.x, (float)(76 * num5)); contentTrs.sizeDelta = new Vector2(contentTrs.sizeDelta.x, (float)(76 * num2)); } } [HarmonyPostfix] [HarmonyPatch(typeof(UIStationWindow), "_OnUpdate")] public static void OnStationUpdate(UIStationWindow __instance) { //IL_0037: 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) if (__instance.stationId != 0 && __instance.factory != null) { StationComponent val = __instance.transport.stationPool[__instance.stationId]; float num = __instance.powerGroupRect.sizeDelta.x - 140f; float num2 = (float)val.energy / (float)val.energyMax; float num3 = (((double)num2 > 0.7) ? (-30) : 30); ((Graphic)__instance.energyText).rectTransform.anchoredPosition = new Vector2(Mathf.Round(num * num2 + num3), 0f); } } [HarmonyPrefix] [HarmonyPatch(typeof(UIStationWindow), "OnWarperIconClick")] public static bool OnWarperIconClickPrefix(UIStationWindow __instance, ref int obj) { if (__instance.stationId == 0 || __instance.factory == null) { ((ManualBehaviour)__instance)._Close(); return false; } StationComponent val = __instance.transport.stationPool[__instance.stationId]; ItemProto val2 = ((ProtoSet)(object)LDB.items).Select((int)__instance.factory.entityPool[val.entityId].protoId); if (((Proto)val2).ID != ((Proto)GigaStationsPlugin.pls).ID && ((Proto)val2).ID != ((Proto)GigaStationsPlugin.ils).ID && ((Proto)val2).ID != ((Proto)GigaStationsPlugin.collector).ID) { return true; } if (__instance.stationId == 0 || __instance.factory == null) { return false; } if (val.id != __instance.stationId) { return false; } if (!val.isStellar) { return false; } if (__instance.player.inhandItemId > 0 && __instance.player.inhandItemCount == 0) { __instance.player.SetHandItems(0, 0, 0); } else if (__instance.player.inhandItemId > 0 && __instance.player.inhandItemCount > 0) { int num = 1210; ItemProto val3 = ((ProtoSet)(object)LDB.items).Select(num); if (__instance.player.inhandItemId != num) { UIRealtimeTip.Popup(Localization.Translate("只能放入") + ((Proto)val3).name, true, 0); return false; } int ilsMaxWarps = GigaStationsPlugin.ilsMaxWarps; int warperCount = val.warperCount; int num2 = ilsMaxWarps - warperCount; if (num2 < 0) { num2 = 0; } int num3 = ((__instance.player.inhandItemCount >= num2) ? num2 : __instance.player.inhandItemCount); if (num3 <= 0) { UIRealtimeTip.Popup(Localization.Translate("栏位已满"), true, 0); return false; } val.warperCount += num3; __instance.player.AddHandItemCount_Unsafe(-num3); if (__instance.player.inhandItemCount <= 0) { __instance.player.SetHandItemId_Unsafe(0); __instance.player.SetHandItemCount_Unsafe(0); } } else if (__instance.player.inhandItemId == 0 && __instance.player.inhandItemCount == 0) { int warperCount2 = val.warperCount; int num4 = warperCount2; if (num4 <= 0) { return false; } if (VFInput.shift || VFInput.control) { int num5 = default(int); num4 = __instance.player.package.AddItemStacked(1210, num4, 0, ref num5); if (warperCount2 != num4) { UIRealtimeTip.Popup(Localization.Translate("无法添加物品"), true, 0); } UIItemup.Up(1210, num4); } else { __instance.player.SetHandItemId_Unsafe(1210); __instance.player.SetHandItemCount_Unsafe(num4); } val.warperCount -= num4; if (val.warperCount < 0) { Assert.CannotBeReached(); val.warperCount = 0; } } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(UIStationWindow), "_OnCreate")] public static bool _OnCreatePrefix(UIStationWindow __instance) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown __instance.minDeliverDroneSlider.maxValue = 100f; __instance.minDeliverVesselSlider.maxValue = 100f; GameObject val = GigaStationsPlugin.resource.bundle.LoadAsset("assets/gigastations/ui/station-scroll.prefab"); GameObject val2 = Object.Instantiate(val, ((Component)__instance).transform, false); scrollTrs = (RectTransform)val2.transform; scrollTrs.anchorMin = Vector2.up; scrollTrs.anchorMax = Vector2.one; scrollTrs.pivot = new Vector2(0.5f, 1f); scrollTrs.offsetMin = new Vector2(40f, 400f); scrollTrs.offsetMax = new Vector2(-40f, -90f); GameObject gameObject = ((Component)val2.transform.Find("Viewport/pane")).gameObject; contentTrs = (RectTransform)gameObject.transform; __instance.storageUIs = (UIStationStorage[])(object)new UIStationStorage[12]; for (int i = 0; i < __instance.storageUIs.Length; i++) { __instance.storageUIs[i] = Object.Instantiate(__instance.storageUIPrefab, (Transform)(object)contentTrs); __instance.storageUIs[i].stationWindow = __instance; ((ManualBehaviour)__instance.storageUIs[i])._Create(); } ((ManualBehaviour)__instance.veinCollectorPanel)._Create(); for (int j = 0; j < __instance.groupBtns.Length; j++) { __instance.groupBtns[j].data = j; } ((ManualBehaviour)__instance.uiRoutePanel)._Create(); return false; } } } namespace GigaStations.InstallCheck { [BepInPlugin("org.limoka.plugin.GigaStationsInstallCheck", "Giga Stations Installation Checker", "2.4.0")] public class InstallationChecker : BaseUnityPlugin { public const string MODNAME = "Giga Stations Installation Checker"; public const string MODGUID = "org.limoka.plugin.GigaStationsInstallCheck"; public const string LDBTOOLGUID = "me.xiaoye97.plugin.Dyson.LDBTool"; public static bool preloaderInstalled; public static bool ldbToolInstalled; public static bool installationIsValid; private void Awake() { Type type = AccessTools.TypeByName("UIControlPanelStationEntry"); FieldInfo field = type.GetField("extraStorageItems", BindingFlags.Instance | BindingFlags.NonPublic); preloaderInstalled = field != null; if (Chainloader.PluginInfos.ContainsKey("me.xiaoye97.plugin.Dyson.LDBTool")) { ldbToolInstalled = true; } installationIsValid = preloaderInstalled && ldbToolInstalled; Harmony.CreateAndPatchAll(typeof(UIMainMenuPatch), (string)null); if (installationIsValid) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Check successful. Installation is correct!"); } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Check failed. Mod is installed incorrectly!"); } } } public static class UIMainMenuPatch { [HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")] [HarmonyPostfix] public static void OnMainMenuOpen() { if (!InstallationChecker.installationIsValid) { string text = "Mod installation is incorrect because:\n"; if (!InstallationChecker.preloaderInstalled) { text += " - Preloader patch has not been detected\n"; } if (!InstallationChecker.ldbToolInstalled) { text += " - Plugin \"LDB Tool\" is missing\n"; } text += "Please check your installation, make sure you followed installation instructions correctly.\nIf you are using a mod manager make sure that all dependencies have been downloaded!\nIf nothing helps you can message me via Discord: limoka8"; UIMessageBox.Show("Giga Stations mod installation is incorrect!", text, "Ok", 3); } } } }