Decompiled source of AerialMiningLogisticsStation v0.9.43
DSPLogisticsHub.dll
Decompiled a day 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CommonAPI; using CommonAPI.Systems; using HarmonyLib; using Microsoft.CodeAnalysis; using PowerNetworkStructures; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.UI; using xiaoye97; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("LogisticsHub")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("Deep-Space Logistics Hub")] [assembly: AssemblyTitle("DSPLogisticsHub")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.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 LogisticsHub { internal static class C { public const string Guid = "com.psd.logisticshub"; public const string Name = "空中采矿机物流运输站"; public const string Version = "0.9.43"; public const int ModelId = 673; public const int ItemId = 8100; public const int RecipeId = 320; public const int BuildIndex = 608; public const int BuildBarMaxPage = 9; public const int GridIndex = 2801; public const int GridType = 2; public const int GridRows = 8; public const int GridCols = 14; public const float BaseRadius = 8.15f; public const float BuildHalf = 7.9f; public const float BaseTop = 4.05f; public const float Height = 4.05f; public const float BodyY = 50f; public const float BodyScale = 1.18f; public const float TotalHeight = 91.3f; public const float PickCenterY = 70.06f; public const float PickHeight = 47.199997f; public const float PickHalf = 33.747997f; public const float SelectDistance = 90f; public const int PortCount = 12; public const float PortPoseRadius = 8.6f; public const float PortPoseY = 0.2f; public const bool EnableSurfaceMining = true; public const float MineRadius = 40f; public const float MinePeriod = 1f; public const int AdvMinerItemId = 2301; public const int MineBaseVeins = 12; public const int MinePerCycle = 16; public static readonly float[] RingY = new float[2] { 79.028f, 70.768f }; public static readonly float[] RingR = new float[2] { 29.499998f, 29.499998f }; public static readonly float[] RingTube = new float[2] { 3.7759998f, 0.354f }; public static readonly int[] RingBerths = new int[2] { 25, 25 }; public static readonly float[] ShipY = new float[2] { 86.108f, 72.656f }; public const float RingDeckY = 28.9f; public const float RingOuterR = 28.2f; public const float BeamRBot = 0.36f; public const float BeamRMid = 0.44f; public const float BeamY0 = 6.4f; public const float BeamY1 = 54.05f; public const float ReceiverR = 2.05f; public const int BeamRingCount = 5; public const float BeamRingGap = 7.6f; public const float BeamRingSpeed = 13f; public const float BeamRingR = 0.86f; public const float BeamRingTube = 0.075f; public const bool EnableDrill = true; public const float GeoPeriod = 2f; public const float GeoMinStrength = 0.25f; public const float GeoMaxStrength = 3f; public const float GeoMineBoostMax = 3f; public const float GeoPowerPerSec = 2000000f; public const float GeoTechPerLevel = 0.15f; public const float GeoTechMulMax = 4f; public const float GeoSelfPowerMin = 1.05f; public const bool EnableGeoGenerator = true; public const float GeoGenPower = 6000000f; public const long GeoGenPerTick = 100000L; public const float GeoGridConnect = 30f; public const float GeoGridCover = 0f; public const bool EnableOceanMining = true; public const int MaxShips = 50; public const int MaxDrones = 200; public const int MaxItemKinds = 20; public const int ManualSlots = 10; public const int AutoSlotStart = 10; public const float SlotPitch = 54f; public const float SlotScale = 0.7f; public const float MineColW = 440f; public const float MineColGap = 16f; public const int MaxItemCount = 500000; public const int AutoCapBase = 20000; public const int AutoCapPerLevel = 30000; public const int AutoCapMax = 500000; public const long MaxEnergyAcc = 30000000000L; public const long WorkEnergyPerTick = 2000000L; public const long IdleEnergyPerTick = 100000L; public const float ShipDockY = 79.028f; public const float DroneDockY = 57.906f; public const float DroneDeckY = 57.434f; public const float DroneDeckR = 12.2f; public const int DroneBays = 16; public const int SignalCount = 4; public const float SignalR = 3.8f; public const float SignalY0 = 4.3f; public const float SignalY1 = 51.6f; public const float SignalWidthScale = 0.34f; public const float SignalSpeed = 9f; public const float CargoScale = 0.26f; public const float CargoPerBand = 2f; public const int TurretCount = 22; public const float TurretTurnSpeed = 55f; public const float TurretSweepSpeed = 9f; public const float TurretHullBoost = 1.06f; public const float TurretDarkBoost = 1.85f; public const float TurretWeaponBoost = 2.1f; public const float TurretHullGlow = 0.62f; public const float TurretDarkGlow = 0.44f; public const float TurretWeaponGlow = 0.44f; public const float TurretWarnGlow = 2.6f; public const float TurretMetallicScale = 0f; public const float TurretSmoothScale = 0.55f; public const float TurretAlbedoScale = 1.1f; public const bool TurretCombat = true; public const float TurretRange = 140f; public const int TurretDamage = 320; public const float TurretFireInterval = 0.18f; public const float TurretRangeSpace = 6500f; public const int TurretDamageSpace = 1800; public const float TurretFireIntervalSpace = 1.1f; public const float TurretGiveUpSeconds = 8f; public const float TurretGiveUpHold = 6f; public const long LaserShotEnergy = 15000000L; public const long PlasmaShotEnergy = 20000000L; public const int FuelSlot = 9; public const int FuelSlotMax = 100; public const float FusionPowerMw = 100f; public const long FallbackRodHeat = 600000000L; public const float WeaponMulMax = 100f; public const string PlasmaModelName = "turret-plasma"; public const float PlasmaScale = 0.26f; public const float PlasmaLift = 0.156f; public const float PlasmaPivotY = 5.865f; public const float PlasmaPivotZ = -0.85f; public const float PlasmaMuzzleY = 0.75f; public const float PlasmaMuzzleZ = -4.784f; public const int PlasmaTopCount = 18; public const float PlasmaAirHeight = 95f; public const float TurretMuzzleY = 1.07f; public const float TurretMuzzleZ = 3.3f; public static readonly Vector3[] TurretMuzzles = (Vector3[])(object)new Vector3[3] { new Vector3(0f, 1.07f, 3.3f), new Vector3(-0.92f, 0.51f, 3.112f), new Vector3(0.92f, 0.51f, 3.112f) }; public const float ShieldRadius = 43f; public const float ShieldBaseY = 50f; public const int ShieldSeg = 48; public const int ShieldRings = 16; public const int ShieldLatLines = 9; public const float ShieldPulse = 0.55f; public static int TechId = 1997; public const int TechIdMin = 1900; public const int TechIdMax = 1999; public const int MineralTechId = 3606; public const float MineTechSpeedPer = 0.1f; public const float MineTechCostPer = 0.06f; public const float MineTechCostMin = 0.05f; public const string LTechName = "LogisticsHub.Tech.Name"; public const string LTechDesc = "LogisticsHub.Tech.Desc"; public const string LTechConclusion = "LogisticsHub.Tech.Conclusion"; public const string LItemName = "LogisticsHub.Item.Name"; public const string LItemDesc = "LogisticsHub.Item.Desc"; public const string LRecipeName = "LogisticsHub.Recipe.Name"; public const string LRecipeDesc = "LogisticsHub.Recipe.Desc"; public const string RecipeItemName1 = "星际物流运输站"; public const int RecipeItemCount1 = 2; public const string RecipeItemName2 = "处理器"; public const int RecipeItemCount2 = 20; public const string RecipeItemName3 = "钛合金"; public const int RecipeItemCount3 = 40; public const string RecipeItemName4 = "空间翘曲器"; public const int RecipeItemCount4 = 2; public const int RecipeTimeSpend = 600; public static Vector3 ScaleBody(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (v.y <= 25f) { return v; } return new Vector3(v.x * 1.18f, 50f + (v.y - 50f) * 1.18f, v.z * 1.18f); } public static float ShipYOn(int ring) { return ShipY[ring]; } } internal static class MiningTech { private static float _next; private static bool _logged; private static bool _errLogged; public static int Level { get; private set; } public static float SpeedMul { get; private set; } = 1f; public static float CostMul { get; private set; } = 1f; public static float EnergyWeaponMul { get; private set; } = 1f; public static float GeoMul { get { float num = 1f + 0.15f * (float)Level; if (!(num > 4f)) { return num; } return 4f; } } public static int WeaponPct => Mathf.RoundToInt((EnergyWeaponMul - 1f) * 100f); public static int AutoCap { get { long num = 20000 + 30000L * (long)Level; if (num <= 500000) { return (int)num; } return 500000; } } public static bool Unlocked { get; private set; } public static int AutoSlotCap(int extra) { long num = (long)AutoCap + (long)((extra > 0) ? extra : 0); if (num <= 500000) { return (int)num; } return 500000; } public static void Refresh(float now) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (_logged && now < _next) { return; } _next = now + 2f; int num = 0; bool flag = false; bool flag2 = false; float num2 = 1f; float num3 = 1f; float num4 = 1f; int num5 = 0; int num6 = 0; int num7 = 0; int num8 = 0; int num9 = 0; try { GameHistoryData history = GameMain.history; if (history != null) { num7 = ((ProtoSet<TechProto>)(object)LDB.techs).Select(3606)?.Level ?? 0; TechState val = history.TechState(3606); num5 = val.curLevel; num6 = val.maxLevel; flag2 = val.unlocked; num8 = num5 - num7; if (flag2 && num8 < 1) { num8 = 1; } if (num8 < 0) { num8 = 0; } num2 = history.miningSpeedScale; num3 = history.miningCostRate; num4 = history.energyDamageScale; num9 = Mathf.RoundToInt((num2 - 1f) / 0.1f); if (num9 < 0) { num9 = 0; } num = num8; if (num9 - num > 1 || num - num9 > 1) { num = num9; } flag = true; } } catch (Exception ex) { if (!_errLogged) { _errLogged = true; Plugin.Log.LogError((object)("采矿科技读取失败(本次按未解锁处理,等级会一直显示未研究): " + ex)); } } if (!flag) { num2 = 1f + 0.1f * (float)num; num3 = Mathf.Pow(0.94f, (float)num); } if (num2 < 0.01f) { num2 = 1f; } if (num3 < 0f) { num3 = 0f; } if (num4 < 1f) { num4 = 1f; } if (num4 > 100f) { num4 = 100f; } bool flag3 = !_logged; bool num10 = num != Level || flag3; bool flag4 = Mathf.Abs(num4 - EnergyWeaponMul) > 0.0005f || flag3; Level = num; Unlocked = flag2 || num > 0; SpeedMul = num2; CostMul = num3; EnergyWeaponMul = num4; _logged = true; if (num10) { Plugin.Log.LogInfo((object)("采矿科技: 矿物利用 Lv" + num + " → 速度 ×" + num2.ToString("0.00") + " 耗矿 ×" + num3.ToString("0.000") + "(" + (num3 * 100f).ToString("0.#") + "%) 地热 ×" + GeoMul.ToString("0.00") + " 自动格容量 " + AutoCap + "\u3000[诊断 id=" + 3606 + " curLevel=" + num5 + " maxLevel=" + num6 + " protoLevel=" + num7 + " unlocked=" + flag2 + " lvTech=" + num8 + " lvBySpeed=" + num9 + " spd=" + num2.ToString("0.000") + "]")); } if (flag4) { Plugin.Log.LogInfo((object)("能量武器: ×" + num4.ToString("0.00") + "(原版「能量武器伤害」升级,每级 +10%)" + ((Mathf.Abs(Plugin.DamageMul - 1f) > 0.001f) ? (" × 配置 " + Plugin.DamageMul.ToString("0.00")) : "") + " → 激光单发 " + Mathf.RoundToInt(320f * num4 * Plugin.DamageMul) + " · 电浆单发 " + Mathf.RoundToInt(1800f * num4 * Plugin.DamageMul) + "\u3000[history.energyDamageScale=" + num4.ToString("0.000") + "]")); } } } [HarmonyPatch(typeof(LDBTool), "Bind")] [HarmonyPriority(700)] internal static class Patch_LdbToolNoBind { private static bool Prefix() { return Plugin.UseLdbToolIds; } } [HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")] [HarmonyAfter(new string[] { "me.xiaoye97.plugin.Dyson.LDBTool" })] internal static class Patch_PostProtoPreload { private static void Prefix() { try { Protos.PreloadAll(); } catch (Exception ex) { Plugin.Log.LogError((object)("PreloadAll 异常: " + ex)); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class Patch_SkillSystemCtor { private static void Prefix() { try { Protos.PreloadAll(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("SkillSystem 兜底预加载异常: " + ex.Message)); } } } [HarmonyPatch(typeof(ModelProto), "Preload")] internal static class Patch_ModelPreload { private static void Postfix(ModelProto __instance) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (__instance == null || ((Proto)__instance).ID != 673) { return; } try { PrefabDesc val = (__instance.prefabDesc = StationPrefab.GetDesc()); if ((Object)(object)val?.mesh != (Object)null) { __instance.meshBounds = val.mesh.bounds; } Material val2 = ((val?.materials != null && val.materials.Length != 0) ? val.materials[0] : null); Plugin.Log.LogInfo((object)("prefabDesc 挂载完成: mesh顶点=" + (((Object)(object)val?.mesh != (Object)null) ? val.mesh.vertexCount : 0) + " 接口=" + ((val?.portPoses != null) ? val.portPoses.Length : 0) + " 泊位=" + (val?.stationMaxShipCount ?? 0) + " shader=" + (((Object)(object)val2 != (Object)null && (Object)(object)val2.shader != (Object)null) ? ((Object)val2.shader).name : "none"))); } catch (Exception ex) { Plugin.Log.LogError((object)("挂载 prefabDesc 失败: " + ex)); } finally { try { Patch_ModelArray.Ensure(); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Ensure modelArray 失败: " + ex2.Message)); } } } } [HarmonyPatch(typeof(ModelProtoSet), "OnAfterDeserialize")] internal static class Patch_ModelArray { [HarmonyPriority(200)] private static void Postfix() { Ensure(); } public static void Ensure() { try { ModelProtoSet models = LDB.models; if (((ProtoSet<ModelProto>)(object)models)?.dataArray == null) { return; } ModelProto val = null; ModelProto[] dataArray = ((ProtoSet<ModelProto>)(object)models).dataArray; for (int i = 0; i < dataArray.Length; i++) { if (dataArray[i] != null && ((Proto)dataArray[i]).ID == 673) { val = dataArray[i]; break; } } if (val == null) { return; } ModelProto[] array = models.modelArray; if (array == null || array.Length <= 673) { ModelProto[] array2 = (ModelProto[])(object)new ModelProto[Math.Max(674, ((array != null) ? array.Length : 0) + 64)]; if (array != null) { Array.Copy(array, array2, array.Length); } models.modelArray = array2; array = array2; } if (array[673] == null) { array[673] = val; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("修正 modelArray 失败: " + ex.Message)); } } } [HarmonyPatch(typeof(ItemProto), "Preload")] internal static class Patch_ItemPreload { private static void Prefix(ItemProto __instance) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (__instance == null || ((Proto)__instance).ID != 8100) { return; } Patch_ModelArray.Ensure(); ModelProto val = ((ProtoSet<ModelProto>)(object)LDB.models).Select(673); if (val != null && val.prefabDesc == null) { val.prefabDesc = StationPrefab.GetDesc(); if ((Object)(object)val.prefabDesc?.mesh != (Object)null) { val.meshBounds = val.prefabDesc.mesh.bounds; } } } } [HarmonyPatch(typeof(StationComponent), "Init")] internal static class Patch_StationInit { private static void Postfix(StationComponent __instance, PrefabDesc _desc) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ff: Unknown result type (might be due to invalid IL or missing references) try { if (_desc == null || !_desc.isStellarStation || _desc.stationMaxShipCount != 50) { return; } int num = Mathf.Min(50, __instance.shipDiskPos.Length); int num2 = 0; Vector3 val = default(Vector3); for (int i = 0; i < C.RingR.Length; i++) { if (num2 >= num) { break; } int num3 = Mathf.Min(C.RingBerths[i], num - num2); float num4 = C.ShipYOn(i) - 79.028f; float num5 = C.RingR[i]; int num6 = 0; while (num6 < num3) { float num7 = 360f / (float)C.RingBerths[i] * (float)num6 + ((i % 2 == 0) ? 0f : (180f / (float)C.RingBerths[i])); float num8 = num7 * ((float)Math.PI / 180f); ((Vector3)(ref val))..ctor(Mathf.Cos(num8) * num5, num4, Mathf.Sin(num8) * num5); __instance.shipDiskPos[num2] = __instance.shipDockPos + __instance.shipDockRot * val; __instance.shipDiskRot[num2] = __instance.shipDockRot * Quaternion.Euler(0f, num7, 0f); num6++; num2++; } } if (__instance.id == 1 || __instance.id % 20 == 0) { Plugin.Log.LogInfo((object)("物流站泊位已铺开: id=" + __instance.id + " 泊位=" + num2 + " 环=" + C.RingR.Length)); } } catch (Exception ex) { Plugin.Log.LogError((object)("重排泊位失败: " + ex)); } } } [HarmonyPatch(typeof(UIBuildMenu), "StaticLoad")] internal static class Patch_BuildMenuDiag { internal static readonly FieldInfo ProtosField = AccessTools.Field(typeof(UIBuildMenu), "protos"); internal static readonly FieldInfo StaticLoadedField = AccessTools.Field(typeof(UIBuildMenu), "staticLoaded"); private static bool _quiet; private static void Postfix() { try { ItemProto val = Protos.FindItem(); if (val == null) { Plugin.Log.LogError((object)("建造栏: 找不到 ItemProto " + 8100 + "(LDBTool 未加入?)")); return; } ItemProto[,] array = ((ProtosField != null) ? (ProtosField.GetValue(null) as ItemProto[,]) : null); if (array == null) { Plugin.Log.LogWarning((object)"建造栏: 读不到 UIBuildMenu.protos 字段"); } else { if (_quiet && Placed(array) >= 0) { return; } int length = array.GetLength(0); int length2 = array.GetLength(1); int num = val.BuildIndex / 100; int num2 = val.BuildIndex % 100; bool flag = GameMain.history != null && GameMain.history.ItemUnlocked(8100); Plugin.Log.LogInfo((object)"=== 建造栏诊断 ==="); Plugin.Log.LogInfo((object)("item: id=" + ((Proto)val).ID + " name=" + ((Proto)val).name + " buildIndex=" + val.BuildIndex + " gridIndex=" + val.GridIndex + " unlockKey=" + val.UnlockKey + " canBuild=" + val.CanBuild + " isEntity=" + val.IsEntity + " icon=" + ((Object)(object)val.iconSprite != (Object)null) + " prefabDesc=" + ((val.prefabDesc != null && (Object)(object)val.prefabDesc.mesh != (Object)null) ? "ok" : "MISSING"))); Plugin.Log.LogInfo((object)("history.ItemUnlocked(" + 8100 + ") = " + flag)); if (Placed(array) >= 0) { Plugin.Log.LogInfo((object)("建造栏: 已在表中(页" + num + " 格" + num2 + ")")); _quiet = true; return; } bool flag2 = false; if (num >= 1 && num < length && num2 >= 1 && num2 < length2 && array[num, num2] == null) { array[num, num2] = val; flag2 = true; } if (!flag2 && num >= 1 && num < length) { for (int i = 1; i <= 12; i++) { if (flag2) { break; } if (array[num, i] == null) { array[num, i] = val; flag2 = true; Plugin.Log.LogWarning((object)("建造栏: [" + num + "," + num2 + "] 被占,改放 [" + num + "," + i + "]")); } } } if (!flag2) { for (int j = 1; j < length; j++) { if (flag2) { break; } for (int k = 1; k <= 12; k++) { if (flag2) { break; } if (array[j, k] == null) { array[j, k] = val; flag2 = true; Plugin.Log.LogWarning((object)("建造栏: 页" + num + " 已满,改放 [" + j + "," + k + "]")); } } } } Plugin.Log.LogInfo((object)("建造栏注册: 目标[" + num + "," + num2 + "] → " + (flag2 ? "OK" : "失败"))); for (int l = 1; l < length && l <= 10; l++) { int num3 = 0; StringBuilder stringBuilder = new StringBuilder(13); for (int m = 1; m <= 12; m++) { ItemProto val2 = array[l, m]; if (val2 == null) { stringBuilder.Append('.'); continue; } num3++; stringBuilder.Append((((Proto)val2).ID == 8100) ? '#' : 'o'); } Plugin.Log.LogInfo((object)(" 页" + l + ": 占" + num3 + " " + stringBuilder)); } _quiet = flag2; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("建造栏诊断异常: " + ex.Message)); } } internal static int Placed(ItemProto[,] protos) { for (int i = 0; i < protos.GetLength(0); i++) { for (int j = 0; j < protos.GetLength(1); j++) { ItemProto val = protos[i, j]; if (val != null && ((Proto)val).ID == 8100) { return i * 100 + j; } } } return -1; } } [HarmonyPatch(typeof(UIBuildMenu), "_OnOpen")] internal static class Patch_BuildMenuOpen { private static void Prefix() { try { if (Patch_BuildMenuDiag.StaticLoadedField != null) { Patch_BuildMenuDiag.StaticLoadedField.SetValue(null, false); } UIBuildMenu.StaticLoad(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("重跑 StaticLoad 失败: " + ex.Message)); } } } [HarmonyPatch(typeof(UIReplicatorWindow), "RefreshRecipeIcons")] internal static class Patch_RecipeUnlock { private static void Prefix() { Protos.UnlockRecipe(); } } [HarmonyPatch(typeof(UIItemPicker), "RefreshIcons")] internal static class Patch_ItemPickerUnlock { private static void Prefix() { Protos.UnlockRecipe(); } } [HarmonyPatch(typeof(UIEntityBriefInfo), "_OnCreate")] internal static class Patch_EntityBriefIcons { private const int Extra = 8; private static void Postfix(UIEntityBriefInfo __instance) { try { UIIconCountInc[] icons = __instance.icons; if (icons == null || icons.Length == 0) { return; } int num = 28; if (icons.Length < num) { UIIconCountInc[] array = (UIIconCountInc[])(object)new UIIconCountInc[num]; Array.Copy(icons, array, icons.Length); UIIconCountInc val = icons[0]; Transform parent = ((Component)val).transform.parent; for (int i = icons.Length; i < num; i++) { UIIconCountInc val2 = Object.Instantiate<UIIconCountInc>(val, parent); CommonUtils.SetTransformIdentity((Component)(object)val2); val2.visible = false; array[i] = val2; } __instance.icons = array; Plugin.Log.LogInfo((object)("物品简报图标位: " + icons.Length + " → " + num + "(卡槽 " + 20 + " + 装备 " + 8 + ")")); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("扩充物品简报图标位失败: " + ex.Message)); } } } [HarmonyPatch(typeof(UIStationWindow), "RefreshTrans")] internal static class Patch_StationWindowSize { internal const int VanillaSlots = 6; private static int _loggedN = -1; private static bool _vFixed; private static FieldInfo _tabField; internal static void ResetVertical() { _vFixed = false; } internal static void FixHeight(UIStationWindow sw, StationComponent station) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: 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_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) if (station == null || station.storage == null || (Object)(object)sw == (Object)null) { return; } int num = station.storage.Length; if (num <= 6 || !StationPanel.IsOurs(sw.factory, station)) { return; } RectTransform windowTrans = sw.windowTrans; if ((Object)(object)windowTrans == (Object)null) { return; } float num2 = 76f * (float)num - 540f; float num3 = VanillaHeight(sw, station) - num2; if (num3 < 240f) { num3 = windowTrans.sizeDelta.y - num2; } windowTrans.sizeDelta = new Vector2(windowTrans.sizeDelta.x, num3); float num4 = 1080f; Transform parent = ((Transform)windowTrans).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val != (Object)null) { Rect rect = val.rect; if (((Rect)(ref rect)).height > 1f) { rect = val.rect; num4 = ((Rect)(ref rect)).height; } } float num5 = windowTrans.sizeDelta.y; if (num5 > num4 - 20f) { num5 = num4 - 20f; windowTrans.sizeDelta = new Vector2(windowTrans.sizeDelta.x, num5); } if (!_vFixed) { _vFixed = true; float y = windowTrans.anchoredPosition.y; float num6 = y + num4 * 0.5f - num5; float num7 = (0f - num4) * 0.5f + 20f; if (num6 < num7) { float num8 = num7 - num6; float num9 = num4 * 0.5f - 16f; float num10 = Mathf.Min(y + num8, num9); if (num10 > y) { windowTrans.anchoredPosition = new Vector2(windowTrans.anchoredPosition.x, num10); } } } if (_loggedN != num) { _loggedN = num; Plugin.Log.LogInfo((object)("站体窗口: storage=" + num + " 格 → 铺 " + 10 + " 行 × " + 54f.ToString("0") + "px(-" + num2.ToString("0") + "px)→ " + windowTrans.sizeDelta.x.ToString("0") + "×" + windowTrans.sizeDelta.y.ToString("0") + " pos=" + windowTrans.anchoredPosition.x.ToString("0") + "," + windowTrans.anchoredPosition.y.ToString("0") + ";第 " + 11 + " 格起为自动矿,只在右侧清单里显示")); } } private static void Postfix(UIStationWindow __instance, StationComponent station) { try { FixHeight(__instance, station); } catch (Exception ex) { Plugin.Log.LogWarning((object)("夹正原版窗口高度失败: " + ex.Message)); } } private static int TabIndex(UIStationWindow sw) { try { if (_tabField == null) { _tabField = AccessTools.Field(typeof(UIStationWindow), "tabIndex"); } return (_tabField != null) ? ((int)_tabField.GetValue(sw)) : 0; } catch { return 0; } } private static bool PilerTech() { try { if (GameMain.history == null || !GameMain.history.TechUnlocked(3803)) { return false; } TechProto val = ((ProtoSet<TechProto>)(object)LDB.techs).Select(3803); return val != null && val.UnlockValues != null && val.UnlockValues.Length != 0 && (int)val.UnlockValues[0] >= 1; } catch { return false; } } private static float VanillaHeight(UIStationWindow sw, StationComponent sc) { int num = ((sc.storage != null) ? sc.storage.Length : 0); bool flag = PilerTech(); if (sc.isCollector) { return 100f + 76f * (float)num + 36f; } if (sc.isVeinCollector) { return (flag ? 268f : 248f) + 76f * (float)num + 36f; } if (sc.isStellar) { if (TabIndex(sw) == 1) { return 360f + 76f * (float)num + 36f + 94f; } return (flag ? 360f : 340f) + 76f * (float)num + 36f; } return (flag ? 300f : 280f) + 76f * (float)num + 36f; } } [HarmonyPatch(typeof(UIStationWindow), "_OnCreate")] internal static class Patch_StationSlots { private static void Postfix(UIStationWindow __instance) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) try { if (StationPanel.SlotsField == null || (Object)(object)__instance.storageUIPrefab == (Object)null || !(StationPanel.SlotsField.GetValue(__instance) is UIStationStorage[] array) || array.Length >= 10) { return; } Transform parent = ((Component)__instance.storageUIPrefab).transform.parent; if ((Object)(object)parent == (Object)null) { return; } UIStationStorage[] array2 = (UIStationStorage[])(object)new UIStationStorage[10]; Array.Copy(array, array2, array.Length); for (int i = array.Length; i < array2.Length; i++) { UIStationStorage val = Object.Instantiate<UIStationStorage>(__instance.storageUIPrefab, parent); if (!((Object)(object)val == (Object)null)) { Transform transform = ((Component)val).transform; RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val2 != (Object)null) { val2.anchoredPosition = new Vector2(40f, -90f - 76f * (float)i); } ((Object)val).name = "storage-ui-" + i; val.stationWindow = __instance; ((ManualBehaviour)val)._Create(); array2[i] = val; } } StationPanel.SlotsField.SetValue(__instance, array2); Plugin.Log.LogInfo((object)("站体窗口卡槽: " + array.Length + " → " + array2.Length + " 个(补造 " + (array2.Length - array.Length) + " 个克隆件,交互仍走原版 UIStationStorage)")); } catch (Exception ex) { Plugin.Log.LogWarning((object)("补造卡槽失败(保持原版 6 格): " + ex)); } } } [HarmonyPatch(typeof(StationComponent), "Import")] internal static class Patch_StationStorageGrow { private static bool _logged; private static void Postfix(StationComponent __instance) { //IL_00a0: 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) try { StationStore[] storage = __instance.storage; if (storage != null && storage.Length < 20) { StationStore[] array = (StationStore[])(object)new StationStore[20]; Array.Copy(storage, array, storage.Length); int num = 500000 + ((GameMain.history != null) ? GameMain.history.remoteStationExtraStorage : 0); int num2 = MiningTech.AutoSlotCap((GameMain.history != null) ? GameMain.history.remoteStationExtraStorage : 0); for (int i = storage.Length; i < array.Length; i++) { array[i].itemId = 0; array[i].count = 0; array[i].max = ((i >= 10) ? num2 : num); array[i].localLogic = (ELogisticStorage)0; array[i].remoteLogic = (ELogisticStorage)0; } __instance.storage = array; if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)("老存档卡槽扩容: " + storage.Length + " → " + 20 + "(1~" + 10 + " 手动 / " + 11 + "~" + 20 + " 自动矿)")); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("卡槽扩容失败(保持原长度): " + ex.Message)); } } } [HarmonyPatch(typeof(StationComponent), "UpdateNeeds")] internal static class Patch_UpdateNeeds { private static bool Prefix(StationComponent __instance) { try { StationStore[] storage = __instance.storage; if (storage == null || storage.Length <= 6) { return true; } lock (storage) { int num = Mathf.Min(5, Mathf.Min(10, storage.Length)); for (int i = 0; i < num; i++) { __instance.needs[i] = ((storage[i].itemId > 0 && storage[i].count < storage[i].max) ? storage[i].itemId : 0); } for (int j = num; j < 5; j++) { __instance.needs[j] = 0; } __instance.needs[5] = ((__instance.isStellar && __instance.warperCount < __instance.warperMaxCount) ? 1210 : 0); } return false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("UpdateNeeds 改写失败,回退原逻辑: " + ex.Message)); return true; } } } internal static class StationSlotScan { internal static int Demand(StationComponent sc, int from, int itemId, int need, bool remote) { //IL_0049: 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_004f: Invalid comparison between Unknown and I4 StationStore[] array = sc?.storage; if (array == null) { return -1; } int num = Mathf.Min(10, array.Length); for (int i = from; i < num; i++) { if (array[i].itemId == itemId && (int)(remote ? array[i].remoteLogic : array[i].localLogic) == 2 && array[i].max - array[i].count >= need) { return i; } } return -1; } internal static int Supply(StationComponent sc, int from, int itemId, int least, bool remote) { //IL_0049: 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_004f: Invalid comparison between Unknown and I4 StationStore[] array = sc?.storage; if (array == null) { return -1; } int num = Mathf.Min(10, array.Length); for (int i = from; i < num; i++) { if (array[i].itemId == itemId && (int)(remote ? array[i].remoteLogic : array[i].localLogic) == 1 && array[i].count >= least) { return i; } } return -1; } } [HarmonyPatch(typeof(StationComponent), "AddItem", new Type[] { typeof(int), typeof(int), typeof(int) })] internal static class Patch_StationAddItem { private static void Postfix(StationComponent __instance, int itemId, int count, int inc, ref int __result) { if (__result > 0 || itemId <= 0 || count <= 0) { return; } StationStore[] storage = __instance.storage; if (storage == null) { return; } int num = Mathf.Min(10, storage.Length); lock (storage) { for (int i = 6; i < num; i++) { if (storage[i].itemId == itemId) { storage[i].count += count; storage[i].inc += inc; __result = count; break; } } } } } [HarmonyPatch(typeof(StationComponent), "HasLocalDemand")] internal static class Patch_HasLocalDemand { private static void Postfix(StationComponent __instance, int itemId, int countAtLeast, ref int __result) { if (__result < 0) { __result = StationSlotScan.Demand(__instance, 6, itemId, countAtLeast, remote: false); } } } [HarmonyPatch(typeof(StationComponent), "HasLocalSupply")] internal static class Patch_HasLocalSupply { private static void Postfix(StationComponent __instance, int itemId, int countAtLeast, ref int __result) { if (__result < 0) { __result = StationSlotScan.Supply(__instance, 6, itemId, countAtLeast, remote: false); } } } [HarmonyPatch(typeof(StationComponent), "HasRemoteDemand")] internal static class Patch_HasRemoteDemand { private static void Postfix(StationComponent __instance, int itemId, int countAtLeast, ref int __result) { if (__result < 0) { __result = StationSlotScan.Demand(__instance, 6, itemId, countAtLeast, remote: true); } } } [HarmonyPatch(typeof(StationComponent), "HasRemoteSupply")] internal static class Patch_HasRemoteSupply { private static void Postfix(StationComponent __instance, int itemId, int countAtLeast, ref int __result) { if (__result < 0) { __result = StationSlotScan.Supply(__instance, 6, itemId, countAtLeast, remote: true); } } } [HarmonyPatch(typeof(ProtoSet<ItemProto>), "Select")] internal static class Patch_ItemSelectFallback { private static bool _logged; private static void Postfix(int id, ref ItemProto __result) { if (__result != null || id != 8100) { return; } try { ItemProto val = Protos.FindItem(); if (val != null) { __result = val; if (!_logged) { _logged = true; Plugin.Log.LogWarning((object)("LDB.items.Select(" + id + ") 查不到(dataIndices 丢条目),已用 FindItem 兜底;原版站体窗口会因此直接关窗")); } } } catch { } } } [HarmonyPatch(typeof(UIStationWindow), "OnStationIdChange")] internal static class Patch_StationPanelHint { private static void Postfix(UIStationWindow __instance) { try { if (!((Object)(object)__instance == (Object)null) && ((ManualBehaviour)__instance).active) { StationPanel.Reflow(__instance); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("站体窗口排布失败: " + ex.Message)); } } } [HarmonyPatch(typeof(UIStationWindow), "_OnUpdate")] internal static class Patch_StationPanelTick { private static void Postfix(UIStationWindow __instance) { StationPanel.Tick(__instance); } } [HarmonyPatch(typeof(UIGame), "OpenStationWindow")] internal static class Patch_OpenStationDiag { private static void Postfix() { //IL_00e1: 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_0104: 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) try { UIGame val = (((Object)(object)UIRoot.instance != (Object)null) ? UIRoot.instance.uiGame : null); UIStationWindow val2 = (((Object)(object)val != (Object)null) ? val.stationWindow : null); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"开站窗口: stationWindow 为空(UIRoot 未就绪)"); return; } Plugin.Log.LogInfo((object)("开站窗口: active=" + ((ManualBehaviour)val2).active + " inited=" + ((ManualBehaviour)val2).inited + " stationId=" + val2.stationId + " 卡槽=" + StationPanel.SlotCount(val2) + " 窗口=" + (((Object)(object)val2.windowTrans != (Object)null) ? (val2.windowTrans.sizeDelta.x.ToString("0") + "×" + val2.windowTrans.sizeDelta.y.ToString("0")) : "?"))); } catch (Exception ex) { Plugin.Log.LogWarning((object)("开站窗口日志失败: " + ex.Message)); } } } [HarmonyPatch(typeof(UIStationWindow), "_OnOpen")] internal static class Patch_StationOnOpenDiag { private static int _enterId; private static void Prefix(UIStationWindow __instance) { try { _enterId = (((Object)(object)__instance != (Object)null) ? __instance.stationId : (-1)); PlanetFactory val = ((GameMain.localPlanet != null) ? GameMain.localPlanet.factory : null); PlanetFactory val2 = ((GameMain.mainPlayer != null) ? GameMain.mainPlayer.factory : null); Plugin.Log.LogInfo((object)("站体窗口 _OnOpen 进入: stationId=" + _enterId + " active=" + ((Object)(object)__instance != (Object)null && ((ManualBehaviour)__instance).active) + " factory=" + ((Object)(object)__instance != (Object)null && __instance.factory != null) + " localPlanet=" + ((GameMain.localPlanet != null) ? GameMain.localPlanet.id.ToString() : "null") + " planetFactory=" + ((val != null) ? val.planet.id.ToString() : "null") + " playerFactory=" + ((val2 != null) ? val2.planet.id.ToString() : "null") + " 同一个=" + (val != null && val == val2))); } catch { } } private static void Postfix(UIStationWindow __instance) { try { Plugin.Log.LogInfo((object)("站体窗口 _OnOpen 完成: 进入时 stationId=" + _enterId + " → 现在 active=" + ((ManualBehaviour)__instance).active + " inited=" + ((ManualBehaviour)__instance).inited + " stationId=" + __instance.stationId + " factory=" + (__instance.factory != null) + " 卡槽=" + StationPanel.SlotCount(__instance))); } catch { } } } [HarmonyPatch(typeof(UIStationWindow), "OnStationIdChange")] internal static class Patch_StationIdDiag { private static float _next; private static void Prefix(UIStationWindow __instance) { try { if ((Object)(object)__instance == (Object)null) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup < _next) { return; } _next = realtimeSinceStartup + 0.5f; PlanetTransport transport = __instance.transport; int stationId = __instance.stationId; int num = ((transport != null && transport.stationPool != null) ? transport.stationPool.Length : (-1)); StationComponent val = ((stationId > 0 && stationId < num) ? transport.stationPool[stationId] : null); string text = ""; int num2 = -1; int num3 = -1; bool flag = false; if (val != null && __instance.factory != null && __instance.factory.entityPool != null) { EntityData[] entityPool = __instance.factory.entityPool; if (val.entityId > 0 && val.entityId < entityPool.Length) { num2 = entityPool[val.entityId].protoId; num3 = entityPool[val.entityId].modelIndex; flag = ((ProtoSet<ItemProto>)(object)LDB.items).Select(num2) != null; } else { text = text + " entityId越界(" + val.entityId + "/" + entityPool.Length + ")"; } } Plugin.Log.LogInfo((object)("[诊断] OnStationIdChange: active=" + ((ManualBehaviour)__instance).active + " inited=" + ((ManualBehaviour)__instance).inited + " stationId=" + stationId + " poolLen=" + num + " factory=" + (__instance.factory != null) + " transport=" + (transport != null) + " sc=" + (val != null) + ((val != null) ? (" sc.id=" + val.id + " entity=" + val.entityId + " stellar=" + val.isStellar + " pcId=" + val.pcId + " storage=" + ((val.storage != null) ? val.storage.Length : (-1))) : "") + " protoId=" + num2 + " modelIndex=" + num3 + " itemOk=" + flag + text + " 卡槽=" + StationPanel.SlotDescribe(__instance))); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[诊断] OnStationIdChange 前缀失败: " + ex.Message)); } } } [HarmonyPatch(typeof(GameData), "Import")] internal static class Patch_GameDataImport { private static void Postfix(GameData __instance) { if (__instance != null && !DSPGame.IsMenuDemo) { Protos.EnsureTechState(__instance.history); } } } [HarmonyPatch(typeof(GameData), "SetForNewGame")] internal static class Patch_GameDataSetForNewGame { private static void Postfix(GameData __instance) { if (__instance != null && !DSPGame.IsMenuDemo) { Protos.EnsureTechState(__instance.history); } } } [HarmonyPatch(typeof(GameHistoryData), "Import")] internal static class Patch_HistoryImport { private static void Postfix(GameHistoryData __instance) { GameData data = GameMain.data; if (data != null && __instance == data.history) { Protos.EnsureTechState(__instance); } } } [HarmonyPatch(typeof(UITechNode), "SetTechProto")] internal static class Patch_TechNodePreload { private static void Prefix(TechProto __0) { try { Protos.EnsureTechArrays(__0); } catch (Exception ex) { Plugin.Log.LogWarning((object)("科技节点兜底失败: " + ex.Message)); } } } [HarmonyPatch(typeof(UIStationWindow), "_OnClose")] internal static class Patch_StationCloseDiag { private static void Prefix(UIStationWindow __instance) { try { if ((Object)(object)__instance == (Object)null || !((ManualBehaviour)__instance).active) { return; } StringBuilder stringBuilder = new StringBuilder(512); stringBuilder.Append("[诊断] 站体窗口被关闭: stationId=").Append(__instance.stationId).Append(" factory=") .Append(__instance.factory != null) .Append('\n'); string[] array = (Environment.StackTrace ?? "").Split(new char[1] { '\n' }); for (int i = 0; i < array.Length && i < 10; i++) { string text = array[i].Trim(); if (text.Length != 0) { stringBuilder.Append(" ").Append(text).Append('\n'); } } Plugin.Log.LogWarning((object)stringBuilder.ToString()); } catch { } } } [HarmonyPatch(typeof(UIGame), "_OnUpdate")] internal static class Patch_StationWindowWatchdog { private static readonly FieldInfo InspectField = AccessTools.Field(typeof(UIGame), "inspectStationId"); private static int _lastInspect = -1; private static int _tries; private static void Postfix(UIGame __instance) { try { if ((Object)(object)__instance == (Object)null || InspectField == null) { return; } int num = (int)InspectField.GetValue(__instance); if (num != _lastInspect) { _lastInspect = num; _tries = 0; } if (num <= 0) { return; } UIStationWindow stationWindow = __instance.stationWindow; if ((Object)(object)stationWindow == (Object)null || ((ManualBehaviour)stationWindow).active || !((ManualBehaviour)stationWindow).inited) { return; } PlanetFactory val = ((GameMain.mainPlayer != null) ? GameMain.mainPlayer.factory : null); if (val != null && val.transport != null && val.transport.stationPool != null && num < val.transport.stationPool.Length) { StationComponent val2 = val.transport.stationPool[num]; if (val2 != null && val2.id == num && StationPanel.IsOurs(val, val2) && _tries < 3) { _tries++; Plugin.Log.LogWarning((object)("站体窗口被原版关掉了,重开第 " + _tries + " 次: stationId=" + num)); stationWindow.stationId = num; ((ManualBehaviour)stationWindow)._Open(); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[诊断] 站体窗口兜底重开失败: " + ex.Message)); } } } [HarmonyPatch(typeof(UIStationStorage), "OnItemIconMouseDown")] internal static class Patch_FuelSlotAnyRod { private static bool Prefix(UIStationStorage __instance, BaseEventData evt) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || __instance.station == null || (Object)(object)__instance.stationWindow == (Object)null) { return true; } int index = __instance.index; if (index != 9) { return true; } PointerEventData val = (PointerEventData)(object)((evt is PointerEventData) ? evt : null); if (val == null || (int)val.button != 0) { return true; } Player mainPlayer = GameMain.mainPlayer; if (mainPlayer == null || mainPlayer.inhandItemId <= 0 || mainPlayer.inhandItemCount <= 0) { return true; } if (!StationNuclear.IsRod(mainPlayer.inhandItemId)) { return true; } StationComponent station = __instance.station; if (station.storage == null || index >= station.storage.Length) { return true; } int itemId = station.storage[index].itemId; if (itemId == mainPlayer.inhandItemId) { return true; } PlanetTransport transport = __instance.stationWindow.transport; if (transport == null) { return true; } transport.SetStationStorage(station.id, index, mainPlayer.inhandItemId, 100, (ELogisticStorage)2, (ELogisticStorage)(station.isStellar ? 2 : 0), mainPlayer); Plugin.Log.LogInfo((object)("核电燃料格: 站 id=" + station.id + " 手动换棒 " + ((itemId > 0) ? StationNuclear.ShortName(itemId) : "空") + " → " + StationNuclear.ShortName(mainPlayer.inhandItemId))); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("核电燃料格: 换棒补丁异常 — " + ex.Message)); return true; } } } [HarmonyPatch(typeof(GameData), "SkipStandardModeGuide")] internal static class Patch_GuideSkipGuard { internal static Action _pending; internal static GameData _owner; internal static float _expireAt; internal static bool Ready(GameData g) { if (g != null && g.mainPlayer != null && g.localPlanet != null) { return g.localPlanet.factory != null; } return false; } internal static void Defer(GameData g, Action vanillaCall, string what) { _pending = vanillaCall; _owner = g; _expireAt = Time.unscaledTime + 30f; Plugin.Log.LogWarning((object)("开局引导: localPlanet/factory 尚未就绪," + what + "的调用已推迟到星球加载完成后自动执行(防 BulletTime 快速加载抢跑 NRE)")); } [HarmonyPrefix] [HarmonyPriority(600)] private static bool Prefix(GameData __instance) { try { if (Ready(__instance)) { return true; } Defer(__instance, delegate { __instance.SkipStandardModeGuide(); }, "跳过序章"); return false; } catch (Exception ex) { Plugin.Log.LogError((object)("开局引导守卫异常: " + ex)); return true; } } } [HarmonyPatch(typeof(GameMain), "FixedUpdate")] internal static class Patch_GuideRetry { private static void Postfix() { if (Patch_GuideSkipGuard._pending == null) { return; } Action pending = Patch_GuideSkipGuard._pending; GameData data = GameMain.data; if (data == null || data != Patch_GuideSkipGuard._owner) { Patch_GuideSkipGuard._pending = null; } else if (GameMain.gameTick > 1 || Time.unscaledTime > Patch_GuideSkipGuard._expireAt) { Patch_GuideSkipGuard._pending = null; Plugin.Log.LogError((object)("开局引导: 星球迟迟未就绪,放弃补发开局引导(gameTick=" + GameMain.gameTick + ")。如复现请反馈日志。")); } else if (Patch_GuideSkipGuard.Ready(data)) { Patch_GuideSkipGuard._pending = null; Plugin.Log.LogInfo((object)"开局引导: 星球已就绪,补发开局引导调用"); try { pending(); } catch (Exception ex) { Plugin.Log.LogError((object)("开局引导补发失败: " + ex)); } } } } [HarmonyPatch(typeof(GameData), "StartStandardModeGuide")] internal static class Patch_GuideStartGuard { private static bool Prefix(GameData __instance) { try { if (Patch_GuideSkipGuard.Ready(__instance)) { return true; } Patch_GuideSkipGuard.Defer(__instance, delegate { __instance.StartStandardModeGuide(); }, "开始序章"); return false; } catch (Exception ex) { Plugin.Log.LogError((object)("开局引导守卫异常: " + ex)); return true; } } } [BepInPlugin("com.psd.logisticshub", "空中采矿机物流运输站", "0.9.43")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [CommonAPISubmoduleDependency(new string[] { "ProtoRegistry" })] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; public static Plugin Instance; public static bool UseLdbToolIds; public static bool AttackRelay; public static float DamageMul = 1f; private static Harmony _harmony; private static bool _iconApplied; private void Awake() { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"空中采矿机物流运输站 v0.9.43 启动中…"); try { UseLdbToolIds = ((BaseUnityPlugin)this).Config.Bind<bool>("LDBTool", "UseLDBToolCustomID", false, "允许 LDBTool 用 config/LDBTool/LDBTool.CustomID.cfg 覆盖本 mod 的 proto ID。\n默认关闭:开着的话,配置里残留的旧科技 ID(如 3996)会把科技节点顶到升级页,并导致科技树 NullReferenceException。").Value; } catch (Exception ex) { Log.LogWarning((object)("读取配置失败: " + ex.Message)); } try { AttackRelay = ((BaseUnityPlugin)this).Config.Bind<bool>("Turret", "AttackRelay", false, "塔顶电浆炮是否主动攻击黑雾「中继站」(原版里的上层空域目标)。\n默认关闭:与原版磁化电浆炮一致 —— 打中继站会快速拉高母巢威胁,可能引来整巢报复。\n开启后,中继站进入塔顶射程(原版电浆炮口径)就会被锁定。").Value; } catch (Exception ex2) { Log.LogWarning((object)("读取炮塔配置失败: " + ex2.Message)); } try { DamageMul = ((BaseUnityPlugin)this).Config.Bind<float>("Turret", "DamageMul", 1f, "炮塔伤害总倍率(基座激光 + 塔顶电浆都乘这一条),默认 1.0。\n0.9.45 的基础值:基座单发 320 / 间隔 0.18s,塔顶电浆单发 1800 / 间隔 1.10s,再乘原版「能量武器伤害」升级倍率(每级 +10%)。\n这里填 2.0 就是在这之上再翻倍。只影响伤害,**不影响**电浆弹每发能耗(固定 20 MJ,见 C.PlasmaShotEnergy)。\n取值会被夹在 0.1 ~ 20 之间。").Value; if (DamageMul < 0.1f) { DamageMul = 0.1f; } if (DamageMul > 20f) { DamageMul = 20f; } } catch (Exception ex3) { DamageMul = 1f; Log.LogWarning((object)("读取炮塔伤害倍率失败(按 1.0 处理): " + ex3.Message)); } try { _harmony = new Harmony("com.psd.logisticshub"); int num = 0; int num2 = 0; Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Length != 0) { try { _harmony.CreateClassProcessor(type).Patch(); num++; } catch (Exception ex4) { num2++; Log.LogWarning((object)("补丁 " + type.Name + " 跳过(目标方法不存在?): " + ex4.Message)); } } } int num3 = 0; foreach (MethodBase patchedMethod in _harmony.GetPatchedMethods()) { _ = patchedMethod; num3++; } Log.LogInfo((object)("Harmony patch 完成: " + num + " 个补丁类 / " + num3 + " 个目标" + ((num2 > 0) ? ("(跳过 " + num2 + " 个)") : ""))); } catch (Exception ex5) { Log.LogError((object)("Harmony patch 失败: " + ex5)); } try { Protos.EnsureStrings(); } catch (Exception ex6) { Log.LogError((object)("字符串注册失败: " + ex6)); } try { LDBTool.PreAddDataAction = (Action)Delegate.Combine(LDBTool.PreAddDataAction, new Action(Protos.RegisterAll)); LDBTool.PostAddDataAction = (Action)Delegate.Combine(LDBTool.PostAddDataAction, new Action(Protos.PreloadAll)); } catch (Exception ex7) { Log.LogError((object)("proto 注册失败: " + ex7)); } try { StationTurrets.Ensure(); } catch (Exception ex8) { Log.LogError((object)("炮塔/护盾宿主创建失败: " + ex8)); } } private void Update() { if (!_iconApplied && ((ProtoSet<ItemProto>)(object)LDB.items)?.dataArray != null && ((ProtoSet<ItemProto>)(object)LDB.items).dataArray.Length != 0) { _iconApplied = true; Protos.EnsureIcon(); } if (!Protos.Registered && GameMain.data != null) { Protos.RegisterAll(); } if (!Protos.IsPreloaded && GameMain.data != null) { Protos.PreloadAll(); } } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class Protos { private static bool _preloaded; private static bool _stringsDone; private static readonly FieldRef<ItemProto, Sprite> _iconRef = AccessTools.FieldRefAccess<ItemProto, Sprite>("_iconSprite"); private static readonly FieldRef<TechProto, Sprite> _techIconRef = AccessTools.FieldRefAccess<TechProto, Sprite>("_iconSprite"); public static bool Registered { get; private set; } public static TechProto Tech { get; private set; } public static bool IsPreloaded => _preloaded; public static void EnsureStrings() { if (_stringsDone) { return; } _stringsDone = true; try { RegisterStrings(); } catch (Exception ex) { Plugin.Log.LogError((object)("字符串注册失败: " + ex)); } } public static void RegisterAll() { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_014e: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_0185: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) if (!Registered) { EnsureStrings(); LDBTool.PreAddProto((Proto)new ModelProto { ID = 673, Name = 8100.ToString(), SID = "", sid = "", OverrideName = "", ObjectType = (EObjectType)0, RendererType = 0, RotSymmetry = 12, HpMax = 200000, HpUpgrade = 0, HpRecover = 0, RuinType = (ERuinType)0, RuinId = 0, RuinCount = 0, RuinLifeTime = 0, PrefabPath = "" }); ItemProto val = new ItemProto { ID = 8100, Name = "LogisticsHub.Item.Name", SID = "", Type = (EItemType)5, SubID = 0, StackSize = 10, Grade = 0, Upgrades = new int[0], IsEntity = true, CanBuild = true, BuildInGas = false, ModelIndex = 673, ModelCount = 1, HpMax = 12000, IconPath = "", Description = "LogisticsHub.Item.Desc", GridIndex = 2801, BuildIndex = 608, BuildMode = 1, UnlockKey = 0, PreTechOverride = 0, DescFields = new int[0] }; ApplyIcon(val); LDBTool.PreAddProto((Proto)val); RecipeProto val2 = new RecipeProto(); ((Proto)val2).ID = 320; ((Proto)val2).Name = "LogisticsHub.Recipe.Name"; ((Proto)val2).SID = ""; val2.Type = (ERecipeType)4; val2.TimeSpend = 600; val2.Items = new int[4] { 2206, 2206, 2206, 2206 }; val2.ItemCounts = new int[4] { 2, 20, 40, 2 }; val2.Results = new int[1] { 8100 }; val2.ResultCounts = new int[1] { 1 }; val2.GridIndex = 2801; val2.Handcraft = true; val2.Explicit = true; val2.Description = "LogisticsHub.Recipe.Desc"; val2.IconPath = ""; val2.IconTag = ""; val2.NonProductive = false; LDBTool.PreAddProto((Proto)(object)val2); RegisterTech(); Registered = true; Plugin.Log.LogInfo((object)("proto 注册完成: model=" + 673 + " item=" + 8100 + " recipe=" + 320 + " buildIndex=" + 608)); } } private static void RegisterTech() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) try { PickFreeTechId(); int num = FindGasGiantTechId(); TechProto val = ((num > 0) ? ((ProtoSet<TechProto>)(object)LDB.techs).Select(num) : null); Vector2 position = (Vector2)((val != null) ? FindTechSpot(val.Position) : new Vector2(0f, 0f)); TechProto val2 = new TechProto(); ((Proto)val2).ID = C.TechId; ((Proto)val2).Name = "LogisticsHub.Tech.Name"; ((Proto)val2).SID = ""; val2.Desc = "LogisticsHub.Tech.Desc"; val2.Conclusion = "LogisticsHub.Tech.Conclusion"; val2.Published = true; val2.IsHiddenTech = false; val2.IsObsolete = false; val2.IsLabTech = false; val2.Level = 0; val2.MaxLevel = 0; val2.LevelCoef1 = 0; val2.LevelCoef2 = 0; val2.PreItem = new int[0]; val2.PreTechs = ((num <= 0) ? new int[0] : new int[1] { num }); val2.PreTechsImplicit = new int[0]; val2.PreTechsMax = false; val2.Items = new int[3] { 6001, 6002, 6003 }; val2.ItemPoints = new int[3] { 2400, 2400, 2400 }; val2.HashNeeded = 3600L; val2.UnlockRecipes = new int[1] { 320 }; val2.UnlockFunctions = new int[0]; val2.UnlockValues = new double[0]; val2.AddItems = new int[0]; val2.AddItemCounts = new int[0]; val2.PropertyOverrideItems = new int[0]; val2.PropertyItemCounts = new int[0]; val2.Position = position; val2.IconPath = ""; val2.IconTag = ""; TechProto val3 = (Tech = val2); LDBTool.PreAddProto((Proto)(object)val3); EnforceTechId(val3); Plugin.Log.LogInfo((object)("科技注册: id=" + ((Proto)val3).ID + "(页 " + ((((Proto)val3).ID >= 2000) ? 1 : 0) + ") 前置=" + num + ((val != null) ? ("(" + ((Proto)val).Name + ")") : "(未找到气态行星开采,退回独立科技)") + " 位置=(" + position.x + "," + position.y + ")" + ((val != null) ? (" 前置位置=(" + val.Position.x + "," + val.Position.y + ")") : "") + " 图标=" + (("".Length > 0) ? "" : "(本站自绘,Preload 后写入)"))); } catch (Exception ex) { Plugin.Log.LogError((object)("科技注册失败: " + ex)); } } private static void EnforceTechId(TechProto tech) { if (tech != null && ((Proto)tech).ID != C.TechId) { int iD = ((Proto)tech).ID; ((Proto)tech).ID = C.TechId; Plugin.Log.LogWarning((object)("科技 ID 被 LDBTool 配置改成 " + iD + "(≥2000 会落到升级页,且后续按 " + C.TechId + " 找不到它),已强制改回 " + C.TechId)); RewriteLdbToolCustomId(((Proto)tech).Name, C.TechId); } } private static void RewriteLdbToolCustomId(string name, int want) { try { if (!(AccessTools.Field(typeof(LDBTool), "IDDict")?.GetValue(null) is IEnumerable enumerable) || string.IsNullOrEmpty(name)) { Plugin.Log.LogWarning((object)"改 LDBTool 配置: 找不到 IDDict,配置里可能还留着旧 ID"); return; } foreach (object item in enumerable) { if (item is IDictionary dictionary && dictionary.Contains(name) && dictionary[name] is ConfigEntry<int> val) { val.Value = want; Plugin.Log.LogInfo((object)("已把 LDBTool 配置项 " + name + " 改回 " + want + "(下次启动就不会再覆盖了)")); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("改 LDBTool 配置失败(不影响本次运行): " + ex.Message)); } } public static void EnsureTechState(GameHistoryData h = null) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) try { if (h == null) { h = GameMain.history; } TechProto val = Tech ?? FindTech(); if (h?.techStates == null || val == null) { return; } int iD = ((Proto)val).ID; if (iD > 0 && iD < 12000 && !h.techStates.ContainsKey(iD)) { if (iD != 3996 && h.techStates.ContainsKey(3996) && h.techStates[3996].unlocked) { h.techStates[iD] = new TechState(true, val.MaxLevel, val.MaxLevel, 0L, 0L, 0) { unlockTick = GameMain.gameTick }; Plugin.Log.LogInfo((object)("科技状态迁移: 旧 ID " + 3996 + " 已解锁 → 新 ID " + iD)); } else { h.techStates[iD] = new TechState(false, val.Level, val.MaxLevel, 0L, val.GetHashNeeded(val.Level), 0); Plugin.Log.LogInfo((object)("科技状态补建: id=" + iD + " 需要 hash=" + val.GetHashNeeded(val.Level))); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("补建科技状态失败: " + ex.Message)); } } public static void EnsureTechArrays(TechProto proto) { if (proto == null || (proto.preTechArray != null && proto.postTechArray != null && proto.unlockRecipeArray != null && proto.itemArray != null)) { return; } try { Plugin.Log.LogWarning((object)("科技 " + ((Proto)proto).ID + " 的派生数组缺失(Preload2 没跑过),补一次")); proto.Preload(); proto.Preload2(); } catch (Exception ex) { Plugin.Log.LogError((object)("补跑 TechProto.Preload2 失败: " + ex)); } } private static void PickFreeTechId() { if (C.TechId < 2000 && C.TechId >= 1000 && !TechExists(C.TechId)) { return; } for (int num = 1999; num >= 1900; num--) { if (!TechExists(num)) { Plugin.Log.LogWarning((object)("科技 ID " + C.TechId + " 已被占用,改用 " + num)); C.TechId = num; return; } } Plugin.Log.LogError((object)("科技 ID 区间 " + 1900 + "~" + 1999 + " 全被占用,本站科技可能与别的 mod 冲突")); } private static bool TechExists(int id) { TechProtoSet techs = LDB.techs; if (((ProtoSet<TechProto>)(object)techs)?.dataArray == null) { return false; } for (int i = 0; i < ((ProtoSet<TechProto>)(object)techs).dataArray.Length; i++) { if (((ProtoSet<TechProto>)(object)techs).dataArray[i] != null && ((Proto)((ProtoSet<TechProto>)(object)techs).dataArray[i]).ID == id) { return true; } } return false; } private static int FindGasGiantTechId() { TechProtoSet techs = LDB.techs; if (((ProtoSet<TechProto>)(object)techs)?.dataArray == null) { return 0; } for (int i = 0; i < ((ProtoSet<TechProto>)(object)techs).dataArray.Length; i++) { TechProto val = ((ProtoSet<TechProto>)(object)techs).dataArray[i]; if (val != null && ((Proto)val).ID != C.TechId) { string text = ((Proto)val).name ?? ""; string text2 = ((Proto)val).Name ?? ""; if (text.Contains("气态行星") || text2.Contains("Gas Giant") || text.Contains("Gas Giant") || text2.Contains("Gas Giants")) { return ((Proto)val).ID; } } } return 0; } private static Vector2 FindTechSpot(Vector2 origin) { //IL_000c: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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_0030: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00c6: Unknown result type (might be due to invalid IL or missing references) TechProtoSet techs = LDB.techs; Vector2 val = default(Vector2); Vector2 val2 = default(Vector2); for (int i = 1; i <= 8; i++) { ((Vector2)(ref val))..ctor(origin.x + 4f * (float)i, origin.y); if (!TechOccupied((ProtoSet<TechProto>)(object)techs, val, null)) { return val; } ((Vector2)(ref val2))..ctor(origin.x - 4f * (float)i, origin.y); if (!TechOccupied((ProtoSet<TechProto>)(object)techs, val2, null)) { return val2; } } Vector2 val3 = default(Vector2); Vector2 val4 = default(Vector2); for (int j = 1; j <= 4; j++) { ((Vector2)(ref val3))..ctor(origin.x + 4f, origin.y - 4f * (float)j); if (!TechOccupied((ProtoSet<TechProto>)(object)techs, val3, null)) { return val3; } ((Vector2)(ref val4))..ctor(origin.x + 4f, origin.y + 4f * (float)j); if (!TechOccupied((ProtoSet<TechProto>)(object)techs, val4, null)) { return val4; } } return new Vector2(origin.x, origin.y); } private static bool TechOccupied(ProtoSet<TechProto> set, Vector2 p, TechProto skip) { //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) if (set?.dataArray == null) { return false; } TechProto[] dataArray = set.dataArray; foreach (TechProto val in dataArray) { if (val != null && val != skip && val != Tech && Vector2.Distance(val.Position, p) < 3.5f) { return true; } } return false; } public static TechProto FindTech() { if (Tech != null && InTechTable(Tech)) { return Tech; } return FindInSet<TechProto>((ProtoSet<TechProto>)(object)LDB.techs, C.TechId, (Func<TechProto, bool>)((TechProto t) => ((Proto)t).ID == C.TechId)); } private static bool InTechTable(TechProto t) { TechProto[] array = ((ProtoSet<TechProto>)(object)LDB.techs)?.dataArray; if (array == null) { return false; } for (int i = 0; i < array.Length; i++) { if (array[i] == t) { return true; } } return false; } private static void PreloadTech(TechProto tech) { //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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) if (tech == null) { Plugin.Log.LogError((object)("科技预加载: 表里找不到本 mod 的科技(ID " + C.TechId + ")")); return; } try { EnforceTechId(tech); RepairIndices<TechProto>((ProtoSet<TechProto>)(object)LDB.techs, "科技"); int num = 0; TechProto[] dataArray = ((ProtoSet<TechProto>)(object)LDB.techs).dataArray; for (int i = 0; i < dataArray.Length; i++) { if (dataArray[i] != null && ((Proto)dataArray[i]).ID == ((Proto)tech).ID) { num++; } } if (num > 1) { int iD = ((Proto)tech).ID; int num2 = PickAltTechId(tech); if (num2 > 0) { ((Proto)tech).ID = num2; C.TechId = num2; RepairIndices<TechProto>((ProtoSet<TechProto>)(object)LDB.techs, "科技"); Plugin.Log.LogWarning((object)("科技 ID 冲突: " + iD + " 在表里出现了 " + num + " 次(别的 mod 也占了),本 mod 改用 " + num2)); } else { Plugin.Log.LogError((object)("科技 ID 冲突: " + iD + " 在表里出现了 " + num + " 次(别的 mod 也占了),没有空号可换,节点可能显示异常")); } } if (tech.PreTechs == null || tech.PreTechs.Length == 0) { int num3 = FindGasGiantTechId(); TechProto val = ((num3 > 0) ? ((ProtoSet<TechProto>)(object)LDB.techs).Select(num3) : null); if (num3 > 0) { tech.PreTechs = new int[1] { num3 }; tech.Position = ((val != null) ? FindTechSpot(val.Position) : tech.Position); if (val != null) { if (string.IsNullOrEmpty(tech.IconPath)) { tech.IconPath = val.IconPath; } if (string.IsNullOrEmpty(tech.IconTag)) { tech.IconTag = val.IconTag; } } Plugin.Log.LogInfo((object)("科技前置补齐: 挂到 " + num3 + "(" + ((val != null) ? ((Proto)val).Name : "?") + ")位置=(" + tech.Position.x + "," + tech.Position.y + ")")); } else { Plugin.Log.LogWarning((object)"科技前置补齐: 仍然找不到「气态行星开采」,本科技保持独立"); } } ResolveTechLayout(tech); RebuildTechs(); ApplyTechIcon(tech); EnsureTechState(); Plugin.Log.LogInfo((object)("科技预加载完成: " + ((Proto)tech).ID + "「" + ((Proto)tech).name + "」 页=" + tech.page + " 位置=(" + tech.Position.x + "," + tech.Position.y + ") 前置=" + Len(tech.preTechArray) + " 后置=" + Len(tech.postTechArray) + " 解锁配方=" + Len(tech.unlockRecipeArray) + " 研究材料=" + Len(tech.itemArray) + " 图标=" + (((Object)(object)tech.iconSprite != (Object)null) ? "ok" : "空") + " 树线=" + DescribeTreeLine(tech))); } catch (Exception ex) { Plugin.Log.LogError((object)("科技预加载失败: " + ex)); } } private static void ResolveTechLayout(TechProto tech) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (tech == null || ((ProtoSet<TechProto>)(object)LDB.techs)?.dataArray == null) { return; } try { TechProto val = ((tech.PreTechs != null && tech.PreTechs.Length != 0) ? ((ProtoSet<TechProto>)(object)LDB.techs).Select(tech.PreTechs[0]) : null); bool flag = TechOccupied((ProtoSet<TechProto>)(object)LDB.techs, tech.Position, tech); bool flag2 = false; if (val != null) { float num = Vector2.Distance(val.Position, tech.Position); flag2 = Mathf.Abs(num - 4f) > 0.5f && Mathf.Abs(num - 5.66f) > 0.6f; } if (flag || flag2) { Vector2 position = tech.Position; Vector2 origin = val?.Position ?? tech.Position; tech.Position = FindTechSpot(origin); Plugin.Log.LogWarning((object)("科技布局: " + ((Proto)tech).ID + " (" + position.x + "," + position.y + ") " + (flag ? "与其它 mod 的节点重叠" : ("离前置太远(前置被挪到 (" + origin.x + "," + origin.y + "))")) + " → 改到 (" + tech.Position.x + "," + tech.Position.y + ")")); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("科技布局检查失败(保持原坐标): " + ex.Message)); } } private static int PickAltTechId(TechProto self) { TechProtoSet techs = LDB.techs; if (((ProtoSet<TechProto>)(object)techs)?.dataArray == null) { return 0; } for (int num = 1999; num >= 1900; num--) { bool flag = false; TechProto[] dataArray = ((ProtoSet<TechProto>)(object)techs).dataArray; foreach (TechProto val in dataArray) { if (val != null && val != self && ((Proto)val).ID == num) { flag = true; break; } } if (!flag) { return num; } } return 0; } private static void RebuildTechs() { TechProtoSet techs = LDB.techs; if (((ProtoSet<TechProto>)(object)techs)?.dataArray == null) { return; } try { ((ProtoSet<TechProto>)(object)techs).OnAfterDeserialize(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("科技表 OnAfterDeserialize 失败: " + ex.Message)); } RepairIndices<TechProto>((ProtoSet<TechProto>)(object)techs, "科技"); TechProto[] dataArray = ((ProtoSet<TechProto>)(object)techs).dataArray; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; foreach (TechProto val in dataArray) { if (val == null) { continue; } try { val.Preload(); num++; } catch (Exception ex2) { num3++; if (num3 <= 3) { Plugin.Log.LogWarning((object)("科技 " + ((Proto)val).ID + ".Preload 失败: " + ex2.Message)); } } } foreach (TechProto val2 in dataArray) { if (val2 == null) { continue; } try { val2.Preload2(); num2++; } catch (Exception ex3) { num4++; if (num4 <= 3) { Plugin.Log.LogWarning((object)("科技 " + ((Proto)val2).ID + ".Preload2 失败: " + ex3.Message)); } } } Plugin.Log.LogInfo((object)("科技整表预加载: Preload " + num + " 个 / Preload2 " + num2 + " 个(表长 " + dataArray.Length + ",失败 " + num3 + "/" + num4 + ")")); } private static void ApplyTechIcon(TechProto tech) { if (tech == null || _techIconRef == null) { return; } try { EnsureIcon(); ItemProto val = FindItem(); Sprite val2 = ((val != null) ? val.iconSprite : null); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"科技图标: 建筑图标还是空的,节点会退回默认图标"); } else { _techIconRef.Invoke(tech) = val2; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("科技图标设置失败: " + ex.Message)); } } private static string DescribeTreeLine(TechProto tech) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (tech?.preTechArray == null || tech.preTechArray.Length == 0) { return "无前置(独立节点,本来就没有线)"; } string text = ""; for (int i = 0; i < tech.preTechArray.Length; i++) { TechProto val = tech.preTechArray[i]; if (val == null) { continue; } TechProto[] array = (TechProto[])(((object)val.postTechArray) ?? ((object)new TechProto[0])); bool flag = false; for (int j = 0; j < array.Length; j++) { if (array[j] != null && ((Proto)array[j]).ID == ((Proto)tech).ID) { flag = true; break; } } if (text.Length > 0) { text += " / "; } text = text + ((Proto)val).ID + ":后置=" + array.Length + (flag ? "✓" : "✗") + " 格距=" + Vector2.Distance(val.Position, tech.Position).ToString("0.#"); } return text; } public static void PreloadAll() { if (_preloaded) { return; } ItemProtoSet items = LDB.items; ModelProtoSet models = LDB.models; RecipeProtoSet recipes = LDB.recipes; if (((ProtoSet<ItemProto>)(object)items)?.dataArray == null || ((ProtoSet<ModelProto>)(object)models)?.dataArray == null || ((ProtoSet<RecipeProto>)(object)recipes)?.dataArray == null) { return; } ModelProto val = FindModel(); if (val == null) { return; } _preloaded = true; Plugin.Log.LogInfo((object)"开始预加载 mod proto…"); RepairIndices<ItemProto>((ProtoSet<ItemProto>)(object)items, "物品"); RepairIndices<RecipeProto>((ProtoSet<RecipeProto>)(object)recipes, "配方"); RepairIndices<ModelProto>((ProtoSet<ModelProto>)(object)models, "模型"); FixGridCell(FindItem(), FindRecipe()); Patch_ModelArray.Ensure(); try { val.Preload(); } catch (Exception ex) { Plugin.Log.LogError((object)("ModelProto.Preload 失败: " + ex)); } Patch_ModelArray.Ensure(); RecipeProto val2 = FindRecipe(); ResolveRecipeItems(val2); ItemProto val3 = FindItem(); if (val3 != null) { ApplyIcon(val3); try { val3.Preload(IndexOf(((ProtoSet<ItemProto>)(object)items).dataArray, val3)); Plugin.Log.LogInfo((object)("ItemProto 预加载完成: index=" + val3.index + " buildIndex=" + val3.BuildIndex + " gridIndex=" + val3.GridIndex + " canBuild=" + val3.CanBuild + " prefabDesc=" + ((val3.prefabDesc != null) ? "ok" : "null"))); } catch (Exception ex2) { Plugin.Log.LogError((object)("ItemProto.Preload 失败: " + ex2)); } } if (val2 != null) { try { val2.Preload(IndexOf(((ProtoSet<RecipeProto>)(object)recipes).dataArray, val2)); } catch (Exception ex3) { Plugin.Log.LogError((object)("RecipeProto.Preload 失败: " + ex3)); } if (val3 != null) { val3.BuildIndex = ResolveBuildIndex(val3); } Plugin.Log.LogInfo((object)("配方/物品落位: 建造栏=" + val3?.BuildIndex + " 制造窗口格子=" + (val2?.GridIndex ?? 0) + " 图标=" + (((Object)(object)((val2 != null) ? val2.iconSprite : null) != (Object)null) ? "ok" : "MISSING"))); } PreloadTech(FindTech()); Plugin.Log.LogInfo((object)"mod proto 预加载完成"); } private static void RepairIndices<T>(ProtoSet<T> set, string tag) where T : Proto { if (set?.dataArray == null) { return; } try { FieldInfo fieldInfo = AccessTools.Field(typeof(ProtoSet<T>), "dataIndices"); if (fieldInfo == null) { Plugin.Log.LogWarning((object)("修索引: 找不到 dataIndices 字段(" + tag + ")")); return; } Dictionary<int, int> dictionary = fieldInfo.GetValue(set) as Dictionary<int, int>; if (dictionary == null) { dictionary = new Dictionary<int, int>(); fieldInfo.SetValue(set, dictionary); } T[] dataArray = set.dataArray; List<int> list = new List<int>(); foreach (KeyValuePair<int, int> item in dictionary) { int value = item.Value; if (value < 0 || value >= dataArray.Length || dataArray[value] == null || ((Proto)dataArray[value]).ID != item.Key) { list.Add(item.Key); } } for (int i = 0; i < list.Count; i++) { dictionary.Remove(list[i]); } int count = list.Count; int num = 0; for (int j = 0; j < dataArray.Length; j++) { if (dataArray[j] != null) { int iD = ((Proto)dataArray[j]).ID; if (!dictionary.TryGetValue(iD, out var value2) || value2 != j) { dictionary[iD] = j; num++; } } } Plugin.Log.LogInfo((object)("修索引[" + tag + "]: 表长=" + dataArray.Length + " 原有错位=" + count + " 重写/新增=" + num)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("修索引[" + tag + "] 失败: " + ex.Message)); } } private static void FixGridCell(ItemProto item, RecipeProto recipe) { try { if (((ProtoSet<ItemProto>)(object)LDB.items)?.dataArray == null || ((ProtoSet<RecipeProto>)(object)LDB.recipes)?.dataArray == null) { return; } bool[,] array = new bool[8, 14]; Mark<ItemProto>(((ProtoSet<ItemProto>)(object)LDB.items).dataArray, array, (Proto)(object)item); Mark<RecipeProto>(((ProtoSet<RecipeProto>)(object)LDB.recipes).dataArray, array, (Proto)(object)recipe); int num = -1; int num2 = -1; int num3 = 0; int num4 = 7; while (num4 >= 0 && num < 0) { for (int i = 0; i < 14; i++) { if (!array[num4, i]) { num3++; if (num < 0) { num = num4; num2 = i; } } } num4--; } if (num < 0) { Plugin.Log.LogError((object)"制造窗口格子全满,无处安放"); return; } int gridIndex = 2000 + (num + 1) * 100 + (num2 + 1); if (item != null) { item.GridIndex = gridIndex; } if (recipe != null) { recipe.GridIndex = gridIndex; } StringBuilder stringBuilder = new StringBuilder(); for (int j = 0; j < 8; j++) { stringBuilder.Append("\n 行" + (j + 1) + ": "); for (int k = 0; k < 14; k++) { stringBuilder.Append(array[j, k] ? 'o' : '.'); } } Plugin.Log.LogInfo((object)("制造窗口格子: 落在 行" + (num + 1) + " 列" + (num2 + 1) + " → GridIndex=" + gridIndex + "(该页空格 " + num3 + " 个)" + stringBuilder)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("挑格子失败: " + ex.Message)); } } private static void Mark<T>(T[] data, bool[,] used, Proto self) where T : Proto { foreach (T val in data) { if (val == null || (object)val == self) { continue; } int num = GridIndexOf((Proto)(object)val); if (num < 1101) { continue; } int num2 = num / 1000; if (num2 == 2) { int num3 = (num - num2 * 1000) / 100 - 1; int num4 = num % 100 - 1; if (num3 >= 0 && num3 < 8 && num4 >= 0 && num4 < 14) { used[num3, num4] = true; } } } } private static int GridIndexOf(Proto p) { return ((ItemProto)(((p is ItemProto) ? p : null)?)).GridIndex ?? ((RecipeProto)(((p is RecipeProto) ? p : null)?)).GridIndex ?? 0; } private static int ResolveBuildIndex(ItemProto self) { //IL_0106: 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) try { ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray; Dictionary<int, int> dictionary = new Dictionary<int, int>(); foreach (ItemProto val in dataArray) { if (val != null && ((Proto)val).ID != ((Proto)self).ID && val.BuildIndex > 0) { int num = val.BuildIndex / 100; int num2 = val.BuildIndex % 100; if (num >= 1 && num <= 9 && num2 >= 1 && num2 <= 12) { dictionary.TryGetValue(num, out var value); dictionary[num] = value + 1; } } } int num3 = -1; int num4 = 0; foreach (KeyValuePair<int, int> item in dictionary) { if (item.Value > num4) { num4 = item.Value; num3 = item.Key; } } Dictionary<int, int> dictionary2 = new Dictionary<int, int>(); foreach (ItemProto val2 in dataArray) { if (val2 != null && ((Proto)val2).ID != ((Proto)self).ID && val2.BuildIndex > 0 && val2.Type == self.Type) { int num5 = val2.BuildIndex / 100; int num6 = val2.BuildIndex % 100; if (num5 >= 1 && num5 <= 9 && num6 >= 1 && num6 <= 12) { dictionary2.TryGetValue(num5, out var value2); dictionary2[num5] = value2 + 1; } } } int num7 = -1; int num8 = 0; foreach (KeyValuePair<int, int> item2 in dictionary2) { if (item2.Value > num8) { num8 = item2.Value; num7 = item2.Key; } } if (num7 > 0) { num3 = num7; } foreach (ItemProto val3 in dataArray) { if (val3 != null && ((Proto)val3).ID != ((Proto)self).ID && val3.BuildIndex > 0 && !(((Proto)val3).name != "星际物流运输站")) { int num9 = val3.BuildIndex / 100; int num10 = val3.BuildIndex % 100; if (num9 >= 1 && num9 <= 9 && num10 >= 1 && num10 <= 12) { num3 = num9; Plugin.Log.LogInfo((object)("建造栏锚点: 「" + ((Proto)val3).name + "」在页" + num9 + " 格" + num10)); break; } } } if (num3 <= 0) { return 608; } bool[] array = new bool[13]; foreach (ItemProto val4 in dataArray) { if (val4 != null && ((Proto)val4).ID != ((Proto)self).ID && val4.BuildIndex > 0 && val4.BuildIndex / 100 == num3) { int num11 = val4.BuildIndex % 100; if (num11 >= 1 && num11 <= 12) { array[num11] = true; } } } for (int m = 1; m <= 12; m++) { if (!array[m]) { Plugin.Log.LogInfo((object)("建造栏落位: 页" + num3 + " 格" + m + "(该页原版已占 " + num4 + " 个,同类建筑最多的一页)")); return num3 * 100 + m; } } Plugin.Log.LogWarning((object)("建造栏: 页" + num3 + " 已满,保留 BuildIndex=" + self.BuildIndex)); return self.BuildIndex; } catch (Exception ex) { Plugin.Log.LogWarning((object)("挑建造栏槽位失败: " + ex.Message)); return self.BuildIndex; } } public static void UnlockRecipe() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) try { GameHistoryData history = GameMain.history; if (history?.recipeUnlocked != null && !history.recipeUnlocked.Contains(320) && history.techStates != null && history.techStates.ContainsKey(C.TechId) && history.techStates[C.TechId].unlocked) { history.recipeUnlocked.Add(320); Plugin.Log.LogInfo((object)("已解锁配方 " + 320 + "(科技 " + C.TechId + " 已完成)")); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("解锁配方失败: " + ex.Message)); } } private static int Len<T>(T[] arr) { if (arr != null) { return arr.Length; } return -1; } private static int IndexOf<T>(T[] arr, T value) where T : class { for (int i = 0; i < arr.Length; i++) { if (arr[i] == value) { return i; } } return -1; } public static ModelProto FindModel() { return FindInSet<ModelProto>((ProtoSet<ModelProto>)(object)LDB.models, 673, (Func<ModelProto, bool>)((ModelProto m) => ((Proto)m).ID == 673)); } public static ItemProto FindItem() { return FindInSet<ItemProto>((ProtoSet<ItemProto>)(object)LDB.items, 8100, (Func<ItemProto, bool>)((ItemProto i) => ((Proto)i).ID == 8100)); } private static RecipeProto FindRecipe() { return FindInSet<RecipeProto>((ProtoSet<RecipeProto>)(object)LDB.recipes, 320, (Func<RecipeProto, bool>)((RecipeProto r) => ((Proto)r).ID == 320)); } private static T FindInSet<T>(ProtoSet<T> set, int id, Func<T, bool> match) where T : Proto { if ((Object)(object)set == (Object)null || set.dataArray == null) { return default(T); } T[] dataArray = set.dataArray; for (int i = 0; i < dataArray.Length; i++) { if (dataArray[i] != null && match(dataArray[i])) { return dataArray[i]; } } try { T val = set.Select(id); if (val != null && ((Proto)val).ID == id) { return val; } } catch { } return default(T); } private static void ResolveRecipeItems(RecipeProto recipe) { if (recipe != null && ((ProtoSet<ItemProto>)(object)LDB.items)?.dataArray != null) { int num = FindItemIdByName("星际物流运输站", "星际物流站", "Interstellar Logistics Station"); int num2 = FindItemIdByName("处理器", "Processor"); int num3 = FindItemIdByName("钛合金", "Titanium Alloy"); int num4 = FindItemIdByName("空间翘曲器", "Space Warper"); if (num > 0) { recipe.Items[0] = num; } if (num2 > 0) { recipe.Items[1] = num2; } if (num3 > 0) { recipe.Items[2] = num3; } if (num4 > 0) { recipe.Items[3] = num4; } Plugin.Log.LogInfo((object)("配方原料: " + recipe.Items[0] + "×" + recipe.ItemCounts[0] + " / " + recipe.Items[1] + "×" + recipe.ItemCounts[1] + " / " + recipe.Items[2] + "×" + recipe.ItemCounts[2] + " / " + recipe.Items[3] + "×" + recipe.ItemCounts[3])); } } private static int FindItemIdByName(params string[] names) { ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray; for (int i = 0; i < names.Length; i++) { if (string.IsNullOrEmpty(names[i])) { continue; } for (int j = 0; j < dataArray.Length; j++) { if (dataArray[j] != null && (((Proto)dataArray[j]).name == names[i] || ((Proto)dataArray[j]).Name == names[i])) { return ((Proto)dataArray[j]).ID; } } } Plugin.Log.LogWarning((object)("找不到物品名: " + string.Join(" / ", names) + "(配方原料保留占位)")); return 0; } public static void EnsureIcon() { ApplyIcon(FindItem()); } private static void ApplyIcon(ItemProto item) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_0186: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be