Decompiled source of CheatEnabler v2.3.26
CheatEnabler.dll
Decompiled 3 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; 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.Configuration; using BepInEx.Logging; using CheatEnabler.Functions; using CheatEnabler.Patches; using CommonAPI.Systems; using HarmonyLib; using Microsoft.CodeAnalysis; using UXAssist.Common; using UXAssist.Functions; using UXAssist.UI; using UnityEngine; using UnityEngine.Bindings; using UnityEngine.Events; using UnityEngine.UI; [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("CheatEnabler")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("DSP MOD - CheatEnabler")] [assembly: AssemblyFileVersion("2.3.26.0")] [assembly: AssemblyInformationalVersion("2.3.26+722c32fdd665f5da64c5c76dfe2010c256ece832")] [assembly: AssemblyProduct("CheatEnabler")] [assembly: AssemblyTitle("CheatEnabler")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.3.26.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 CheatEnabler { [BepInPlugin("org.soardev.cheatenabler", "CheatEnabler", "2.3.26")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CheatEnabler : BaseUnityPlugin { public static readonly ManualLogSource Logger = Logger.CreateLogSource("CheatEnabler"); private Type[] _patches; private void Awake() { GamePatch.DevShortcutsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DevShortcuts", false, "Enable DevMode shortcuts"); GamePatch.AbnormalDisablerEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableAbnormalChecks", false, "disable all abnormal checks"); GamePatch.UnlockTechEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UnlockTech", false, "Unlock clicked tech by holding key-modifilers(Shift/Alt/Ctrl)"); FactoryPatch.ImmediateEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "ImmediateBuild", false, "Build immediately"); FactoryPatch.ArchitectModeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "Architect", false, "Architect Mode"); FactoryPatch.NoConditionEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BuildWithoutCondition", false, "Build without condition"); FactoryPatch.NoCollisionEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "NoCollision", false, "No collision"); FactoryPatch.BeltSignalGeneratorEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BeltSignalGenerator", false, "Belt signal generator"); FactoryPatch.BeltSignalNumberAltFormat = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BeltSignalNumberFormat", false, "Belt signal number format alternative format (AAAA=generation speed in minutes, B=proliferate points, C=stack count):\n AAAABC by default\n BCAAAA as alternative"); FactoryPatch.BeltSignalCountGenEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BeltSignalCountGenerations", true, "Belt signal count generations as production in statistics"); FactoryPatch.BeltSignalCountRemEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BeltSignalCountRemovals", true, "Belt signal count removals as comsumption in statistics"); FactoryPatch.BeltSignalCountRecipeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BeltSignalCountRecipe", false, "Belt signal count all raws and intermediates in statistics"); FactoryPatch.RemovePowerSpaceLimitEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "RemovePowerDistanceLimit", false, "Remove distance limit for wind turbines and geothermals"); FactoryPatch.BoostWindPowerEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BoostWindPower", false, "Boost wind power"); FactoryPatch.BoostSolarPowerEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BoostSolarPower", false, "Boost solar power"); FactoryPatch.BoostFuelPowerEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BoostFuelPower", false, "Boost fuel power"); FactoryPatch.BoostGeothermalPowerEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "BoostGeothermalPower", false, "Boost geothermal power"); FactoryPatch.WindTurbinesPowerGlobalCoverageEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "PowerGlobalCoverage", false, "Global power coverage"); FactoryPatch.GreaterPowerUsageInLogisticsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "GreaterPowerUsageInLogistics", false, "Increase maximum power usage in Logistic Stations and Advanced Mining Machines"); FactoryPatch.ControlPanelRemoteLogisticsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Build", "ControlPanelRemoteLogistics", false, "Retrieve/Place items from/to remote planets on logistics control panel"); ResourcePatch.InfiniteResourceEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Planet", "AlwaysInfiniteResource", false, "always infinite natural resource"); ResourcePatch.FastMiningEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Planet", "FastMining", false, "super-fast mining speed"); PlanetPatch.WaterPumpAnywhereEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Planet", "WaterPumpAnywhere", false, "Can pump water anywhere (while water type is not None)"); PlanetPatch.TerraformAnywayEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Planet", "TerraformAnyway", false, "Can do terraform without enough soil piless"); PlayerPatch.InstantTeleportEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "InstantTeleport", false, "Enable instant teleport (like that in Sandbox mode)"); PlayerPatch.WarpWithoutSpaceWarpersEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "WarpWithoutWarper", false, "Enable warp without warper"); DysonSpherePatch.SkipBulletEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("DysonSphere", "SkipBullet", false, "Skip bullet"); DysonSpherePatch.SkipAbsorbEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("DysonSphere", "SkipAbsorb", false, "Skip absorption"); DysonSpherePatch.QuickAbsorbEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("DysonSphere", "QuickAbsorb", false, "Quick absorb"); DysonSpherePatch.EjectAnywayEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("DysonSphere", "EjectAnyway", false, "Eject anyway"); DysonSpherePatch.OverclockEjectorEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("DysonSphere", "OverclockEjector", false, "Overclock ejector"); DysonSpherePatch.OverclockSiloEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("DysonSphere", "OverclockSilo", false, "Overclock silo"); CombatPatch.MechaInvincibleEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Battle", "MechaInvincible", false, "Mecha and Drones/Fleets invincible"); CombatPatch.BuildingsInvincibleEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Battle", "BuildingsInvincible", false, "Buildings invincible"); UIConfigWindow.Init(); _patches = Util.GetTypesFiltered(Assembly.GetExecutingAssembly(), (Func<Type, bool>)((Type t) => string.Equals(t.Namespace, "CheatEnabler.Patches", StringComparison.Ordinal) || string.Equals(t.Namespace, "CheatEnabler.Functions", StringComparison.Ordinal))); Type[] patches = _patches; if (patches != null) { CollectionExtensions.Do<Type>((IEnumerable<Type>)patches, (Action<Type>)delegate(Type type) { type.GetMethod("Init")?.Invoke(null, null); }); } } private void Start() { Type[] patches = _patches; if (patches != null) { CollectionExtensions.Do<Type>((IEnumerable<Type>)patches, (Action<Type>)delegate(Type type) { type.GetMethod("Start")?.Invoke(null, null); }); } } private void OnDestroy() { Type[] patches = _patches; if (patches != null) { CollectionExtensions.Do<Type>((IEnumerable<Type>)patches, (Action<Type>)delegate(Type type) { type.GetMethod("Uninit")?.Invoke(null, null); }); } } private void Update() { if (!VFInput.inputing) { FactoryPatch.OnUpdate(); } } } public static class UIConfigWindow { [CompilerGenerated] private static class <>O { public static Action<MyConfigWindow, RectTransform> <0>__CreateUI; public static Action <1>__UpdateUI; public static UnityAction <2>__RemoveAllMetadataConsumptions; public static UnityAction <3>__RemoveCurrentMetadataConsumptions; public static UnityAction <4>__ClearMetadataBanAchievements; public static UnityAction <5>__CompleteShellsInstantly; public static UnityAction <6>__TeleportToOuterSpace; public static UnityAction <7>__TeleportToSelectedAstronomical; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__4_0; public static UnityAction <>9__4_2; public static UnityAction <>9__4_3; public static UnityAction <>9__4_4; public static UnityAction <>9__4_5; internal void <CreateUI>b__4_0() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameMain.data.account = AccountData.me; } internal void <CreateUI>b__4_2() { PlanetFunctions.BuryAllVeins(bury: true); } internal void <CreateUI>b__4_3() { PlanetFunctions.BuryAllVeins(bury: false); } internal void <CreateUI>b__4_4() { Player mainPlayer = GameMain.mainPlayer; if (mainPlayer != null) { BuildTool_Reform reformTool = mainPlayer.controller.actionBuild.reformTool; if (GameMain.localPlanet?.factory != null) { GameMain.localPlanet.factory.PlanetReformAll(reformTool.brushType, reformTool.brushColor, reformTool.buryVeins); } } } internal void <CreateUI>b__4_5() { if (GameMain.localPlanet?.factory != null) { GameMain.localPlanet.factory.PlanetReformRevert(); } } } private static RectTransform _windowTrans; private static UIButton _resignGameBtn; private static UIButton _clearBanBtn; public static void Init() { I18N.Add("Factory", "Factory", "工厂"); I18N.Add("Planet", "Planet", "行星"); I18N.Add("Mecha/Combat", "Mecha/Combat", "机甲/战斗"); I18N.Add("Enable Dev Shortcuts", "Enable Dev Shortcuts", "开发模式快捷键"); I18N.Add("Disable Abnormal Checks", "Disable Abnormal Checks", "关闭数据异常检查"); I18N.Add("Hotkey", "Hotkey", "快捷键"); I18N.Add("Unlock Tech with Key-Modifiers", "Unlock Tech with Key-Modifiers", "使用组合键点击解锁科技"); I18N.Add("Dev Shortcuts", "Dev Shortcuts", "开发模式快捷键"); I18N.Add("Dev Shortcuts Tips", "Caution: Some function may trigger abnormal check!\nNumpad 1: Gets all items and extends bag.\nNumpad 2: Boosts walk speed, gathering speed and mecha energy restoration.\nNumpad 3: Fills planet with foundations and bury all veins.\nNumpad 4: +1 construction drone.\nNumpad 5: Upgrades drone engine tech to full.\nNumpad 6: Unlocks researching tech.\nNumpad 7: Unlocks Drive Engine 1.\nNumpad 8: Unlocks Drive Engine 2 and maximize energy.\nNumpad 9: Unlocks ability to warp.\nNumpad 0: No costs for Logistic Storages' output.\nLCtrl + T: Unlocks all techs (not upgrades).\nLCtrl + Q: Adds 10000 to every metadata.\nLCtrl + W: Enters Sandbox Mode.\nLCtrl + Shift + W: Leaves Sandbox Mode.\nNumpad *: Proliferates items on hand.\nNumpad /: Removes proliferations from items on hand.\nPageDown: Remembers Pose of game camera.\nPageUp: Locks game camera using remembered Pose.", "警告:某些功能可能触发异常检查!\n小键盘1:获得所有物品并扩展背包\n小键盘2:加快行走速度及采集速度,加快能量恢复速度\n小键盘3:将地基铺设整个星球并掩埋所有矿物\n小键盘4:建设机器人 +1\n小键盘5:建设机器人满级\n小键盘6:解锁当前科技\n小键盘7:解锁驱动技术I\n小键盘8:解锁驱动技术II 最大化能量\n小键盘9:机甲曲速解锁\n小键盘0:物流站通过传送带出物品无消耗\n左Ctrl + T:解锁所有非升级科技\n左Ctrl + Q:增加各项元数据10000点\n左Ctrl + W:进入沙盒模式\n左Ctrl + Shift + W:离开沙盒模式\n小键盘乘号 *:给手上物品喷涂增产剂\n小键盘除号 /:清除手上物品的增产剂\nPageDown:记录摄像机当前的Pose\nPageUp:用记录的Pose锁定摄像机"); I18N.Add("Unlock Tech with Key-Modifiers Tips", "Click tech on tree while holding:\n Shift: Tech level + 1\n Ctrl: Tech level + 10\n Ctrl + Shift: Tech level + 100\n Alt: Tech level to MAX\n\nNote: all direct prerequisites will be unlocked as well.", "按住以下组合键点击科技树:\n Shift:科技等级+1\n Ctrl:科技等级+10\n Ctrl+Shift:科技等级+100\n Alt:科技等级升到最大\n\n注意:所有直接前置科技也会被解锁"); I18N.Add("Remove all metadata consumption records", "Remove all metadata consumption records", "移除所有元数据消耗记录"); I18N.Add("Remove metadata consumption record in current game", "Remove metadata consumption record in current game", "移除当前存档的元数据消耗记录"); I18N.Add("Clear metadata flag which bans achievements", "Clear metadata flag which bans achievements in current game", "解除当前存档因使用元数据导致的成就限制"); I18N.Add("Assign gamesave to current account", "Assign gamesave to current account", "将游戏存档绑定给当前账号"); I18N.Add("Finish build immediately", "Finish build immediately", "建造秒完成"); I18N.Add("Architect mode", "Architect mode", "建筑师模式"); I18N.Add("Build without condition", "Build without condition check", "无条件建造"); I18N.Add("No collision", "No collision", "无碰撞"); I18N.Add("Belt signal generator", "Belt signal generator", "传送带信号物品生成"); I18N.Add("Belt signal alt format", "Belt signal alt format", "传送带信号替换格式"); I18N.Add("Belt signal alt format tips", "Belt signal number format alternative format:\n AAAABC by default\n BCAAAA as alternative\nAAAA=generation speed in minutes, B=proliferate points, C=stack count", "传送带信号物品生成数量格式:\n 默认为AAAABC\n 勾选替换为BCAAAA\nAAAA=生成速度,B=增产点数,C=堆叠数量"); I18N.Add("Count generations as production in statistics", "Count generations as production in statistics", "统计信息里将生成计算为产物"); I18N.Add("Count removals as consumption in statistics", "Count removals as consumption in statistics", "统计信息里将移除计算为消耗"); I18N.Add("Count all raws and intermediates in statistics", "Count all raw materials in statistics", "统计信息里计算所有原料和中间产物"); I18N.Add("Remove power space limit", "Remove space limit for winds and geothermals", "移除风力发电和地热发电的间距限制"); I18N.Add("Boost wind power", "Boost wind power(x100,000)", "提升风力发电(x100,000)"); I18N.Add("Boost solar power", "Boost solar power(x100,000)", "提升太阳能发电(x100,000)"); I18N.Add("Boost fuel power", "Boost fuel power(x50,000)", "提升燃料发电(x50,000)"); I18N.Add("Boost fuel power 2", "(x20,000 for deuteron, x10,000 for antimatter)", "(氘核燃料棒x20,000,反物质燃料棒x10,000)"); I18N.Add("Wind Turbines do global power coverage", "Wind Turbines do global power coverage", "风力涡轮机供电覆盖全球"); I18N.Add("Boost geothermal power", "Boost geothermal power(x50,000)", "提升地热发电(x50,000)"); I18N.Add("Increase maximum power usage in Logistic Stations and Advanced Mining Machines", "Increase maximum power usage in Logistic Stations and Advanced Mining Machines", "提升物流塔和大型采矿机的最大功耗"); I18N.Add("Retrieve/Place items from/to remote planets on logistics control panel", "Retrieve/Place items from/to remote planets on logistics control panel", "在物流总控面板上可以从非本地行星取放物品"); I18N.Add("Infinite Natural Resources", "Infinite natural resources", "自然资源采集不消耗"); I18N.Add("Fast Mining", "Fast mining", "高速采集"); I18N.Add("Pump Anywhere", "Pump anywhere", "平地抽水"); I18N.Add("Skip bullet period", "Skip bullet period", "跳过子弹阶段"); I18N.Add("Skip absorption period", "Skip absorption period", "跳过吸收阶段"); I18N.Add("Quick absorb", "Quick absorb", "快速吸收"); I18N.Add("Eject anyway", "Eject anyway", "全球弹射"); I18N.Add("Overclock Ejectors", "Overclock Ejectors (10x)", "高速弹射器(10倍射速)"); I18N.Add("Overclock Silos", "Overclock Silos (10x)", "高速发射井(10倍射速)"); I18N.Add("Complete Dyson Sphere shells instantly", "Complete Dyson Sphere shells instantly", "立即完成戴森壳建造"); I18N.Add("Terraform without enough soil piles", "Terraform without enough soil piles", "沙土不够时依然可以整改地形"); I18N.Add("Instant teleport (like that in Sandbox mode)", "Instant teleport (like that in Sandbox mode)", "快速传送(和沙盒模式一样)"); I18N.Add("Mecha and Drones/Fleets invicible", "Mecha and Drones/Fleets invicible", "机甲和战斗无人机无敌"); I18N.Add("Buildings invicible", "Buildings invincible", "建筑无敌"); I18N.Add("Enable warp without space warpers", "Enable warp without space warpers", "无需空间翘曲器即可曲速飞行"); I18N.Add("Teleport to outer space", "Teleport to outer space", "传送到外太空"); I18N.Add("Teleport to selected astronomical", "Teleport to selected astronomical", "传送到选中的天体"); I18N.Apply(); MyConfigWindow.OnUICreated = (Action<MyConfigWindow, RectTransform>)Delegate.Combine(MyConfigWindow.OnUICreated, new Action<MyConfigWindow, RectTransform>(CreateUI)); MyConfigWindow.OnUpdateUI = (Action)Delegate.Combine(MyConfigWindow.OnUpdateUI, new Action(UpdateUI)); } private static void CreateUI(MyConfigWindow wnd, RectTransform trans) { //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Expected O, but got Unknown //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Expected O, but got Unknown //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0658: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Expected O, but got Unknown //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_069b: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Expected O, but got Unknown //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Expected O, but got Unknown //IL_085f: Unknown result type (might be due to invalid IL or missing references) //IL_0864: Unknown result type (might be due to invalid IL or missing references) //IL_086a: Expected O, but got Unknown //IL_089e: Unknown result type (might be due to invalid IL or missing references) //IL_08a3: Unknown result type (might be due to invalid IL or missing references) //IL_08a9: Expected O, but got Unknown _windowTrans = trans; float num = 0f; float num2 = 10f; ((MyWindowWithTabs)wnd).AddSplitter(trans, 10f); ((MyWindowWithTabs)wnd).AddTabGroup(trans, "Cheat Enabler", "tab-group-cheatenabler"); RectTransform val = ((MyWindowWithTabs)wnd).AddTab(_windowTrans, "General"); MyCheckBox val2 = ((MyWindow)wnd).AddCheckBox(num, num2, val, GamePatch.DevShortcutsEnabled, "Enable Dev Shortcuts", 15); num += val2.Width + 5f; num2 += 6f; ((MyWindow)wnd).AddTipsButton2(num, num2, val, "Dev Shortcuts", "Dev Shortcuts Tips", "dev-shortcuts-tips", "tips-button"); num = 0f; num2 += 30f; ((MyWindow)wnd).AddCheckBox(num, num2, val, GamePatch.AbnormalDisablerEnabled, "Disable Abnormal Checks", 15); num2 += 36f; val2 = ((MyWindow)wnd).AddCheckBox(num, num2, val, GamePatch.UnlockTechEnabled, "Unlock Tech with Key-Modifiers", 15); num += val2.Width + 5f; num2 += 6f; ((MyWindow)wnd).AddTipsButton2(num, num2, val, "Unlock Tech with Key-Modifiers", "Unlock Tech with Key-Modifiers Tips", "unlock-tech-tips", "tips-button"); num = 0f; num2 += 66f; float num3 = num; float num4 = num2; object obj = <>O.<2>__RemoveAllMetadataConsumptions; if (obj == null) { UnityAction val3 = PlayerFunctions.RemoveAllMetadataConsumptions; <>O.<2>__RemoveAllMetadataConsumptions = val3; obj = (object)val3; } ((MyWindow)wnd).AddButton(num3, num4, 400f, val, "Remove all metadata consumption records", 16, "button-remove-all-metadata-consumption", (UnityAction)obj); num2 += 36f; float num5 = num; float num6 = num2; object obj2 = <>O.<3>__RemoveCurrentMetadataConsumptions; if (obj2 == null) { UnityAction val4 = PlayerFunctions.RemoveCurrentMetadataConsumptions; <>O.<3>__RemoveCurrentMetadataConsumptions = val4; obj2 = (object)val4; } ((MyWindow)wnd).AddButton(num5, num6, 400f, val, "Remove metadata consumption record in current game", 16, "button-remove-current-metadata-consumption", (UnityAction)obj2); num2 += 36f; float num7 = num; float num8 = num2; object obj3 = <>O.<4>__ClearMetadataBanAchievements; if (obj3 == null) { UnityAction val5 = PlayerFunctions.ClearMetadataBanAchievements; <>O.<4>__ClearMetadataBanAchievements = val5; obj3 = (object)val5; } _clearBanBtn = ((MyWindow)wnd).AddButton(num7, num8, 400f, val, "Clear metadata flag which bans achievements", 16, "button-clear-ban-list", (UnityAction)obj3); num = 300f; num2 = 10f; float num9 = num; float num10 = num2; object obj4 = <>c.<>9__4_0; if (obj4 == null) { UnityAction val6 = delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameMain.data.account = AccountData.me; }; <>c.<>9__4_0 = val6; obj4 = (object)val6; } _resignGameBtn = ((MyWindow)wnd).AddButton(num9, num10, 300f, val, "Assign gamesave to current account", 16, "resign-game-btn", (UnityAction)obj4); RectTransform val7 = ((MyWindowWithTabs)wnd).AddTab(_windowTrans, "Factory"); num = 0f; num2 = 10f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.ImmediateEnabled, "Finish build immediately", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.ArchitectModeEnabled, "Architect mode", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.NoConditionEnabled, "Build without condition", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.NoCollisionEnabled, "No collision", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.BeltSignalGeneratorEnabled, "Belt signal generator", 15); num += 26f; num2 += 26f; MyCheckBox cb1 = ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.BeltSignalCountGenEnabled, "Count generations as production in statistics", 13); num2 += 26f; MyCheckBox cb2 = ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.BeltSignalCountRemEnabled, "Count removals as consumption in statistics", 13); num2 += 26f; MyCheckBox cb3 = ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.BeltSignalCountRecipeEnabled, "Count all raws and intermediates in statistics", 13); num2 += 26f; MyCheckBox cb4 = ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.BeltSignalNumberAltFormat, "Belt signal alt format", 13); num += cb4.Width + 5f; num2 += 6f; UIButton tip1 = ((MyWindow)wnd).AddTipsButton2(num, num2, val7, "Belt signal alt format", "Belt signal alt format tips", "belt-signal-alt-format-tips", "tips-button"); num = 0f; num2 += 30f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.GreaterPowerUsageInLogisticsEnabled, "Increase maximum power usage in Logistic Stations and Advanced Mining Machines", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.ControlPanelRemoteLogisticsEnabled, "Retrieve/Place items from/to remote planets on logistics control panel", 15); FactoryPatch.BeltSignalGeneratorEnabled.SettingChanged += delegate { OnBeltSignalChanged(); }; OnBeltSignalChanged(); num = 350f; num2 = 10f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.RemovePowerSpaceLimitEnabled, "Remove power space limit", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.WindTurbinesPowerGlobalCoverageEnabled, "Wind Turbines do global power coverage", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.BoostWindPowerEnabled, "Boost wind power", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.BoostSolarPowerEnabled, "Boost solar power", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.BoostGeothermalPowerEnabled, "Boost geothermal power", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val7, FactoryPatch.BoostFuelPowerEnabled, "Boost fuel power", 15); num2 += 26f; ((MyWindow)wnd).AddText2(num + 32f, num2, val7, "Boost fuel power 2", 13, "label"); RectTransform val8 = ((MyWindowWithTabs)wnd).AddTab(_windowTrans, "Planet"); num = 0f; num2 = 10f; ((MyWindow)wnd).AddCheckBox(num, num2, val8, ResourcePatch.InfiniteResourceEnabled, "Infinite Natural Resources", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val8, ResourcePatch.FastMiningEnabled, "Fast Mining", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val8, PlanetPatch.WaterPumpAnywhereEnabled, "Pump Anywhere", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val8, PlanetPatch.TerraformAnywayEnabled, "Terraform without enough soil piles", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val8, PlayerPatch.InstantTeleportEnabled, "Instant teleport (like that in Sandbox mode)", 15); num = 400f; num2 = 10f; float num11 = num; float num12 = num2; object obj5 = <>c.<>9__4_2; if (obj5 == null) { UnityAction val9 = delegate { PlanetFunctions.BuryAllVeins(bury: true); }; <>c.<>9__4_2 = val9; obj5 = (object)val9; } ((MyWindow)wnd).AddButton(num11, num12, 200f, val8, "矿物掩埋标题", 16, "button-bury-all", (UnityAction)obj5); num2 += 36f; float num13 = num; float num14 = num2; object obj6 = <>c.<>9__4_3; if (obj6 == null) { UnityAction val10 = delegate { PlanetFunctions.BuryAllVeins(bury: false); }; <>c.<>9__4_3 = val10; obj6 = (object)val10; } ((MyWindow)wnd).AddButton(num13, num14, 200f, val8, "矿物还原标题", 16, "button-bury-restore-all", (UnityAction)obj6); num2 += 36f; float num15 = num; float num16 = num2; object obj7 = <>c.<>9__4_4; if (obj7 == null) { UnityAction val11 = delegate { Player mainPlayer = GameMain.mainPlayer; if (mainPlayer != null) { BuildTool_Reform reformTool = mainPlayer.controller.actionBuild.reformTool; if (GameMain.localPlanet?.factory != null) { GameMain.localPlanet.factory.PlanetReformAll(reformTool.brushType, reformTool.brushColor, reformTool.buryVeins); } } }; <>c.<>9__4_4 = val11; obj7 = (object)val11; } ((MyWindow)wnd).AddButton(num15, num16, 200f, val8, "铺满地基提示", 16, "button-reform-all", (UnityAction)obj7); num2 += 36f; float num17 = num; float num18 = num2; object obj8 = <>c.<>9__4_5; if (obj8 == null) { UnityAction val12 = delegate { if (GameMain.localPlanet?.factory != null) { GameMain.localPlanet.factory.PlanetReformRevert(); } }; <>c.<>9__4_5 = val12; obj8 = (object)val12; } ((MyWindow)wnd).AddButton(num17, num18, 200f, val8, "还原地形提示", 16, "button-reform-revert-all", (UnityAction)obj8); RectTransform val13 = ((MyWindowWithTabs)wnd).AddTab(_windowTrans, "Dyson Sphere"); num = 0f; num2 = 10f; ((MyWindow)wnd).AddCheckBox(num, num2, val13, DysonSpherePatch.SkipBulletEnabled, "Skip bullet period", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val13, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val13, DysonSpherePatch.QuickAbsorbEnabled, "Quick absorb", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val13, DysonSpherePatch.EjectAnywayEnabled, "Eject anyway", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val13, DysonSpherePatch.OverclockEjectorEnabled, "Overclock Ejectors", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val13, DysonSpherePatch.OverclockSiloEnabled, "Overclock Silos", 15); num = 300f; num2 = 10f; float num19 = num; float num20 = num2; object obj9 = <>O.<5>__CompleteShellsInstantly; if (obj9 == null) { UnityAction val14 = DysonSphereFunctions.CompleteShellsInstantly; <>O.<5>__CompleteShellsInstantly = val14; obj9 = (object)val14; } ((MyWindow)wnd).AddButton(num19, num20, 300f, val13, "Complete Dyson Sphere shells instantly", 16, "button-complete-dyson-sphere-shells-instantly", (UnityAction)obj9); RectTransform val15 = ((MyWindowWithTabs)wnd).AddTab(_windowTrans, "Mecha/Combat"); num = 0f; num2 = 10f; ((MyWindow)wnd).AddCheckBox(num, num2, val15, CombatPatch.MechaInvincibleEnabled, "Mecha and Drones/Fleets invicible", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val15, CombatPatch.BuildingsInvincibleEnabled, "Buildings invicible", 15); num2 += 36f; ((MyWindow)wnd).AddCheckBox(num, num2, val15, PlayerPatch.WarpWithoutSpaceWarpersEnabled, "Enable warp without space warpers", 15); num = 400f; num2 = 10f; float num21 = num; float num22 = num2; object obj10 = <>O.<6>__TeleportToOuterSpace; if (obj10 == null) { UnityAction val16 = PlayerFunctions.TeleportToOuterSpace; <>O.<6>__TeleportToOuterSpace = val16; obj10 = (object)val16; } ((MyWindow)wnd).AddButton(num21, num22, 200f, val15, "Teleport to outer space", 16, "button-teleport-to-outer-space", (UnityAction)obj10); num2 += 36f; float num23 = num; float num24 = num2; object obj11 = <>O.<7>__TeleportToSelectedAstronomical; if (obj11 == null) { UnityAction val17 = PlayerFunctions.TeleportToSelectedAstronomical; <>O.<7>__TeleportToSelectedAstronomical = val17; obj11 = (object)val17; } ((MyWindow)wnd).AddButton(num23, num24, 200f, val15, "Teleport to selected astronomical", 16, "button-teleport-to-selected-astronomical", (UnityAction)obj11); void OnBeltSignalChanged() { bool value = FactoryPatch.BeltSignalGeneratorEnabled.Value; ((Component)cb1).gameObject.SetActive(value); ((Component)cb2).gameObject.SetActive(value); ((Component)cb3).gameObject.SetActive(value); ((Component)cb4).gameObject.SetActive(value); ((Component)tip1).gameObject.SetActive(value); } } private static void UpdateUI() { UpdateButtons(); } private static void UpdateButtons() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) GameData data = GameMain.data; if (data == null) { return; } bool flag = data.account != AccountData.me; if (((Component)_resignGameBtn).gameObject.activeSelf != flag) { ((Component)_resignGameBtn).gameObject.SetActive(flag); } GameHistoryData history = data.history; if (history != null) { bool hasUsedPropertyBanAchievement = history.hasUsedPropertyBanAchievement; if (((Component)_clearBanBtn).gameObject.activeSelf != hasUsedPropertyBanAchievement) { ((Component)_clearBanBtn).gameObject.SetActive(hasUsedPropertyBanAchievement); } } } } public static class PluginInfo { public const string PLUGIN_GUID = "org.soardev.cheatenabler"; public const string PLUGIN_NAME = "CheatEnabler"; public const string PLUGIN_VERSION = "2.3.26"; } } namespace CheatEnabler.Patches { public static class CombatPatch { private class MechaInvincible : PatchImpl<MechaInvincible> { [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable<CodeInstruction> Player_get_invincible_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.Start().RemoveInstructions(val.Length).Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldc_I4_1, (object)null), new CodeInstruction(OpCodes.Ret, (object)null) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(SkillSystem), "DamageGroundObjectByLocalCaster")] [HarmonyPatch(typeof(SkillSystem), "DamageGroundObjectByRemoteCaster")] [HarmonyPatch(typeof(SkillSystem), "DamageObject")] private static IEnumerable<CodeInstruction> SkillSystem_DamageObject_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase __originalMethod) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdarg(ci, (int?)null)), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(SkillTargetLocal), "type"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Bne_Un || ci.opcode == OpCodes.Bne_Un_S), (string)null) }); val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown m.Advance(4).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Starg_S, (object)((__originalMethod.Name == "DamageObject") ? 1 : 2)) }); }, (Action<string>)null); return val.InstructionEnumeration(); } } private class BuildingsInvincible : PatchImpl<BuildingsInvincible> { [HarmonyTranspiler] [HarmonyPatch(typeof(SkillSystem), "DamageGroundObjectByLocalCaster")] [HarmonyPatch(typeof(SkillSystem), "DamageGroundObjectByRemoteCaster")] private static IEnumerable<CodeInstruction> SkillSystem_DamageObject_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdarg(ci, (int?)null)), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(SkillTargetLocal), "type"), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Brtrue || ci.opcode == OpCodes.Brtrue_S), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null) }).Advance(3).Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Starg_S, (object)2) }); return val.InstructionEnumeration(); } } public static ConfigEntry<bool> MechaInvincibleEnabled; public static ConfigEntry<bool> BuildingsInvincibleEnabled; public static void Init() { MechaInvincibleEnabled.SettingChanged += delegate { PatchImpl<MechaInvincible>.Enable(MechaInvincibleEnabled.Value); }; BuildingsInvincibleEnabled.SettingChanged += delegate { PatchImpl<BuildingsInvincible>.Enable(BuildingsInvincibleEnabled.Value); }; } public static void Start() { PatchImpl<MechaInvincible>.Enable(MechaInvincibleEnabled.Value); PatchImpl<BuildingsInvincible>.Enable(BuildingsInvincibleEnabled.Value); } public static void Uninit() { PatchImpl<BuildingsInvincible>.Enable(false); PatchImpl<MechaInvincible>.Enable(false); } } public class DysonSpherePatch : PatchImpl<DysonSpherePatch> { private class SkipBulletPatch : PatchImpl<SkipBulletPatch> { private struct DysonSailCache { public DysonSail Sail; public int OrbitId; public void FromData(in VectorLF3 delta1, in VectorLF3 delta2, int orbitId) { Sail.px = (float)delta1.x; Sail.py = (float)delta1.y; Sail.pz = (float)delta1.z; Sail.vx = (float)delta2.x; Sail.vy = (float)delta2.y; Sail.vz = (float)delta2.z; Sail.gs = 1f; OrbitId = orbitId; } } private static long _sailLifeTime; private static DysonSailCache[][] _sailsCache; private static int[] _sailsCacheLen; private static int[] _sailsCacheCapacity; protected override void OnEnable() { UpdateSailLifeTime(); UpdateSailsCacheForThisGame(); GameLogic.OnGameBegin = (Action)Delegate.Combine(GameLogic.OnGameBegin, new Action(GameMain_Begin_Postfix)); } protected override void OnDisable() { GameLogic.OnGameBegin = (Action)Delegate.Remove(GameLogic.OnGameBegin, new Action(GameMain_Begin_Postfix)); } private static void UpdateSailLifeTime() { if (GameMain.history != null) { _sailLifeTime = (long)(GameMain.history.solarSailLife * 60f + 0.1f); } } private static void UpdateSailsCacheForThisGame() { if (GameMain.data?.galaxy != null) { int starCount = GameMain.data.galaxy.starCount; _sailsCache = new DysonSailCache[starCount][]; _sailsCacheLen = new int[starCount]; _sailsCacheCapacity = new int[starCount]; Array.Clear(_sailsCacheLen, 0, starCount); Array.Clear(_sailsCacheCapacity, 0, starCount); } } private static void SetSailsCacheCapacity(int index, int capacity) { DysonSailCache[] array = new DysonSailCache[capacity]; int num = _sailsCacheLen[index]; if (num > 0) { Array.Copy(_sailsCache[index], array, num); } _sailsCache[index] = array; _sailsCacheCapacity[index] = capacity; } private static void GameMain_Begin_Postfix() { UpdateSailsCacheForThisGame(); UpdateSailLifeTime(); } [HarmonyPostfix] [HarmonyPatch(typeof(GameHistoryData), "UnlockTechFunction")] private static void GameHistoryData_SetForNewGame_Postfix(int func) { if (func == 12) { UpdateSailLifeTime(); } } [HarmonyTranspiler] [HarmonyPatch(typeof(EjectorComponent), "InternalUpdate")] private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)10f, (string)null) }).Advance(2); int pos = val.Pos; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Pop, (object)null, (string)null) }).Advance(1); int pos2 = val.Pos; val.Start().Advance(pos).RemoveInstructions(pos2 - pos) .Insert((CodeInstruction[])(object)new CodeInstruction[6] { new CodeInstruction(OpCodes.Ldarg_2, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(EjectorComponent), "orbitId")), new CodeInstruction(OpCodes.Ldloc_S, (object)8), new CodeInstruction(OpCodes.Ldloc_S, (object)10), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SkipBulletPatch), "AddDysonSail", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } private static void AddDysonSail(DysonSwarm swarm, int orbitId, VectorLF3 uPos, VectorLF3 endVec) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) int index = swarm.starData.index; VectorLF3 delta = endVec - swarm.starData.uPosition; VectorLF3 delta2 = VectorLF3.Cross(endVec - uPos, VectorLF3.op_Implicit(swarm.orbits[orbitId].up)); VectorLF3 val = ((VectorLF3)(ref delta2)).normalized * Math.Sqrt(swarm.dysonSphere.gravity / swarm.orbits[orbitId].radius); lock (swarm) { DysonSailCache[] array = _sailsCache[index]; int num = _sailsCacheLen[index]; if (array == null) { SetSailsCacheCapacity(index, 256); array = _sailsCache[index]; } else { int num2 = _sailsCacheCapacity[index]; if (num >= num2) { SetSailsCacheCapacity(index, num2 * 2); array = _sailsCache[index]; } } _sailsCacheLen[index] = num + 1; ref DysonSailCache reference = ref array[num]; delta2 = val + RandomTable.SphericNormal(ref swarm.randSeed, 0.5); reference.FromData(in delta, in delta2, orbitId); } } [HarmonyPrefix] [HarmonyPatch(typeof(DysonSwarm), "GameTick")] public static void DysonSwarm_GameTick_Prefix(DysonSwarm __instance, long time) { //IL_01b2: Unknown result type (might be due to invalid IL or missing references) int index = __instance.starData.index; int num = _sailsCacheLen[index]; if (num == 0) { return; } _sailsCacheLen[index] = 0; DysonSailCache[] array = _sailsCache[index]; long num2 = time + _sailLifeTime; int num3 = num - 1; if (_instantAbsorb) { DysonSphere dysonSphere = __instance.dysonSphere; DysonSphereLayer[] layersSorted = dysonSphere.layersSorted; int layerCount = dysonSphere.layerCount; int[] productRegister = dysonSphere.productRegister; int[] consumeRegister = dysonSphere.consumeRegister; if (layerCount > 0) { int num4 = ((int)time >> 4) % layerCount; for (int num5 = layerCount - 1; num5 >= 0; num5--) { DysonSphereLayer obj = layersSorted[(num4 + num5) % layerCount]; DysonNode[] nodePool = obj.nodePool; int num6 = obj.nodeCursor - 1; if (num6 > 0) { int num7 = (int)time % num6; for (int num8 = num6; num8 > 0; num8--) { int num9 = (num7 + num8) % num6 + 1; DysonNode val = nodePool[num9]; if (val != null && val.id == num9 && val.sp >= val.spMax) { while (val.cpReqOrder > 0) { val.cpOrdered++; if (val.ConstructCp() == null) { break; } if (num3 == 0) { productRegister[11901] += num; consumeRegister[11901] += num; productRegister[11903] += num; return; } num3--; } } } } } } int num10 = num - 1 - num3; if (num10 > 0) { productRegister[11901] += num10; consumeRegister[11901] += num10; productRegister[11903] += num10; } } while (num3 >= 0) { __instance.AddSolarSail(array[num3].Sail, array[num3].OrbitId, num2); num3--; } } } private class SkipAbsorbPatch : PatchImpl<SkipAbsorbPatch> { protected override void OnEnable() { _instantAbsorb = QuickAbsorbEnabled.Value; } protected override void OnDisable() { _instantAbsorb = false; } [HarmonyTranspiler] [HarmonyPatch(typeof(DysonSwarm), "AbsorbSail")] private static IEnumerable<CodeInstruction> DysonSwarm_AbsorbSail_Transpiler2(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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 //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); Label label = generator.DefineLabel(); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(ExpiryOrder), "index"), (string)null) }).Advance(1).RemoveInstructions(val.Length - val.Pos) .Insert((CodeInstruction[])(object)new CodeInstruction[18] { new CodeInstruction(OpCodes.Ldarg_1, (object)null), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(DysonNode), "ConstructCp", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Brfalse_S, (object)label), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonSwarm), "dysonSphere")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(DysonSphere), "productRegister")), new CodeInstruction(OpCodes.Ldc_I4, (object)11903), new CodeInstruction(OpCodes.Ldelema, (object)typeof(int)), new CodeInstruction(OpCodes.Dup, (object)null), new CodeInstruction(OpCodes.Ldind_I4, (object)null), new CodeInstruction(OpCodes.Ldc_I4_1, (object)null), new CodeInstruction(OpCodes.Add, (object)null), new CodeInstruction(OpCodes.Stind_I4, (object)null), CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_0, (object)null), new Label[1] { label }), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(DysonSwarm), "RemoveSolarSail", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Ldc_I4_1, (object)null), new CodeInstruction(OpCodes.Ret, (object)null) }); return val.InstructionEnumeration(); } } private class QuickAbsorbPatch : PatchImpl<QuickAbsorbPatch> { protected override void OnEnable() { _instantAbsorb = SkipAbsorbEnabled.Value; } protected override void OnDisable() { _instantAbsorb = false; } [HarmonyTranspiler] [HarmonyPatch(typeof(DysonSphereLayer), "GameTick")] private static IEnumerable<CodeInstruction> DysonSphereLayer_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.Start().InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(QuickAbsorbPatch), "DoAbsorb", (Type[])null, (Type[])null)) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonSphereLayer), "dysonSphere"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonSphere), "swarm"), (string)null) }) .Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ret, (object)null) }); return val.InstructionEnumeration(); } private static void DoAbsorb(DysonSphereLayer layer, long gameTick) { int num = layer.nodeCursor - 1; if (num <= 0) { return; } DysonNode[] nodePool = layer.nodePool; DysonSwarm swarm = layer.dysonSphere.swarm; int num2 = ((int)gameTick >> 6) % num; for (int num3 = num - ((int)gameTick & 0x3F); num3 > 0; num3 -= 64) { int num4 = (num2 + num3) % num + 1; DysonNode val = nodePool[num4]; if (val != null && val.id == num4 && val.sp >= val.spMax) { for (int num5 = val.cpReqOrder; num5 > 0; num5--) { if (!swarm.AbsorbSail(val, gameTick)) { return; } } } } } } private class EjectAnywayPatch : PatchImpl<EjectAnywayPatch> { [HarmonyTranspiler] [HarmonyPatch(typeof(EjectorComponent), "InternalUpdate")] private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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 //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_R8 && Math.Abs((double)instr.operand - 0.08715574) < 1E-08), (string)null) }); int num = val.Pos - 3; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.And, (object)null, (string)null) }).Advance(1).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.And, (object)null, (string)null) }); int num2 = val.Pos - 2; val.Start().Advance(num).RemoveInstructions(num2 - num) .Insert((CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(EjectorComponent), "bulletCount")), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Cgt, (object)null), new CodeInstruction(OpCodes.Stloc_S, (object)13) }); return val.InstructionEnumeration(); } } private class OverclockEjector : PatchImpl<OverclockEjector> { [HarmonyTranspiler] [HarmonyPatch(typeof(EjectorComponent), "InternalUpdate")] private static IEnumerable<CodeInstruction> EjectAndSiloComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldc_I4_S, (object)10), new CodeInstruction(OpCodes.Mul, (object)null) }).Advance(1); int pos = val.Pos; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }).Advance(1); int pos2 = val.Pos; val.Start().Advance(pos).RemoveInstructions(pos2 - pos); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(UIEjectorWindow), "_OnUpdate")] private static IEnumerable<CodeInstruction> UIEjectAndSiloWindow__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Cargo), "accTableMilli"), (string)null) }).Advance(-1); object operand = val.Operand; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_S, operand, (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldc_R4, (object)10f), new CodeInstruction(OpCodes.Mul, (object)null) }).Advance(1); int pos = val.Pos; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_S, operand, (string)null) }).Advance(1); int pos2 = val.Pos; val.Start().Advance(pos).RemoveInstructions(pos2 - pos); return val.InstructionEnumeration(); } } private class OverclockSilo : PatchImpl<OverclockSilo> { [HarmonyTranspiler] [HarmonyPatch(typeof(SiloComponent), "InternalUpdate")] private static IEnumerable<CodeInstruction> EjectAndSiloComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldc_I4_S, (object)10), new CodeInstruction(OpCodes.Mul, (object)null) }).Advance(1); int pos = val.Pos; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }).Advance(1); int pos2 = val.Pos; val.Start().Advance(pos).RemoveInstructions(pos2 - pos); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(UISiloWindow), "_OnUpdate")] private static IEnumerable<CodeInstruction> UIEjectAndSiloWindow__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Cargo), "accTableMilli"), (string)null) }).Advance(-1); object operand = val.Operand; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_S, operand, (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldc_R4, (object)10f), new CodeInstruction(OpCodes.Mul, (object)null) }).Advance(1); int pos = val.Pos; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_S, operand, (string)null) }).Advance(1); int pos2 = val.Pos; val.Start().Advance(pos).RemoveInstructions(pos2 - pos); return val.InstructionEnumeration(); } } public static ConfigEntry<bool> SkipBulletEnabled; public static ConfigEntry<bool> SkipAbsorbEnabled; public static ConfigEntry<bool> QuickAbsorbEnabled; public static ConfigEntry<bool> EjectAnywayEnabled; public static ConfigEntry<bool> OverclockEjectorEnabled; public static ConfigEntry<bool> OverclockSiloEnabled; private static bool _instantAbsorb; public static void Init() { SkipBulletEnabled.SettingChanged += delegate { PatchImpl<SkipBulletPatch>.Enable(SkipBulletEnabled.Value); }; SkipAbsorbEnabled.SettingChanged += delegate { PatchImpl<SkipAbsorbPatch>.Enable(SkipAbsorbEnabled.Value); }; QuickAbsorbEnabled.SettingChanged += delegate { PatchImpl<QuickAbsorbPatch>.Enable(QuickAbsorbEnabled.Value); }; EjectAnywayEnabled.SettingChanged += delegate { PatchImpl<EjectAnywayPatch>.Enable(EjectAnywayEnabled.Value); }; OverclockEjectorEnabled.SettingChanged += delegate { PatchImpl<OverclockEjector>.Enable(OverclockEjectorEnabled.Value); }; OverclockSiloEnabled.SettingChanged += delegate { PatchImpl<OverclockSilo>.Enable(OverclockSiloEnabled.Value); }; } public static void Start() { PatchImpl<SkipBulletPatch>.Enable(SkipBulletEnabled.Value); PatchImpl<SkipAbsorbPatch>.Enable(SkipAbsorbEnabled.Value); PatchImpl<QuickAbsorbPatch>.Enable(QuickAbsorbEnabled.Value); PatchImpl<EjectAnywayPatch>.Enable(EjectAnywayEnabled.Value); PatchImpl<OverclockEjector>.Enable(OverclockEjectorEnabled.Value); PatchImpl<OverclockSilo>.Enable(OverclockSiloEnabled.Value); PatchImpl<DysonSpherePatch>.Enable(true); } public static void Uninit() { PatchImpl<DysonSpherePatch>.Enable(false); PatchImpl<SkipBulletPatch>.Enable(false); PatchImpl<SkipAbsorbPatch>.Enable(false); PatchImpl<QuickAbsorbPatch>.Enable(false); PatchImpl<EjectAnywayPatch>.Enable(false); PatchImpl<OverclockEjector>.Enable(false); PatchImpl<OverclockSilo>.Enable(false); } [HarmonyTranspiler] [HarmonyPatch(typeof(DysonNode), "OrderConstructCp")] private static IEnumerable<CodeInstruction> DysonNode_OrderConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(DysonSwarm), "AbsorbSail", (Type[])null, (Type[])null), (string)null) }).Advance(1).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Pop, (object)null)) .Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ret, (object)null) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(DysonSwarm), "AbsorbSail")] private static IEnumerable<CodeInstruction> DysonSwarm_AbsorbSail_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(ExpiryOrder), "time"), (string)null) }).Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[6] { new CodeInstruction(OpCodes.Ldarg_1, (object)null), new CodeInstruction(OpCodes.Ldarg_1, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonNode), "cpOrdered")), new CodeInstruction(OpCodes.Ldc_I4_1, (object)null), new CodeInstruction(OpCodes.Add, (object)null), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(DysonNode), "cpOrdered")) }); return val.InstructionEnumeration(); } } public class FactoryPatch : PatchImpl<FactoryPatch> { private class ImmediateBuild : PatchImpl<ImmediateBuild> { protected override void OnEnable() { Player mainPlayer = GameMain.mainPlayer; PlanetFactory val = ((mainPlayer != null) ? mainPlayer.factory : null); if (val != null) { ArrivePlanet(val); } } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Addon), "CreatePrebuilds")] [HarmonyPatch(typeof(BuildTool_BlueprintPaste), "CreatePrebuilds")] [HarmonyPatch(typeof(BuildTool_Click), "CreatePrebuilds")] [HarmonyPatch(typeof(BuildTool_Inserter), "CreatePrebuilds")] [HarmonyPatch(typeof(BuildTool_Path), "CreatePrebuilds")] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.End().MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ret, (object)null, (string)null) }); if (val.IsInvalid) { CheatEnabler.Logger.LogWarning((object)"Failed to patch CreatePrebuilds"); return val.InstructionEnumeration(); } val.Advance(-1); if (val.Opcode != OpCodes.Nop && (val.Opcode != OpCodes.Call || !CodeInstructionExtensions.OperandIs(val.Instruction, (MemberInfo)AccessTools.Method(typeof(GC), "Collect", (Type[])null, (Type[])null)))) { CheatEnabler.Logger.LogWarning((object)$"Failed to patch CreatePrebuilds: last instruction is not `Nop` or `Call GC.Collect()`: {val.Instruction}"); return val.InstructionEnumeration(); } List<Label> labels = val.Labels; val.Labels = new List<Label>(); val.Insert((CodeInstruction[])(object)new CodeInstruction[3] { CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_0, (object)null), (IEnumerable<Label>)labels), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(BuildTool), "factory")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(FactoryPatch), "ArrivePlanet", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetFunctions), "BuildOrbitalCollectors")] private static void UXAssist_PlanetFunctions_BuildOrbitalCollectors_Postfix() { Player mainPlayer = GameMain.mainPlayer; PlanetFactory val = ((mainPlayer != null) ? mainPlayer.factory : null); if (val != null) { ArrivePlanet(val); } } } private class ArchitectMode : PatchImpl<ArchitectMode> { private static bool[] _canBuildItems; protected override void OnEnable() { Player mainPlayer = GameMain.mainPlayer; PlanetFactory val = ((mainPlayer != null) ? mainPlayer.factory : null); if (val != null) { ArrivePlanet(val); } } [HarmonyPrefix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static bool TakeTailItemsPatch(StorageComponent __instance, int itemId) { if (__instance == null || __instance.id != GameMain.mainPlayer.package.id) { return true; } if (itemId <= 0) { return true; } if (_canBuildItems == null) { DoInit(); } if (itemId < 12000) { return !_canBuildItems[itemId]; } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(StorageComponent), "GetItemCount", new Type[] { typeof(int) })] public static void GetItemCountPatch(StorageComponent __instance, int itemId, ref int __result) { if (__result <= 99 && __instance != null && __instance.id == GameMain.mainPlayer.package.id && itemId > 0) { if (_canBuildItems == null) { DoInit(); } if (itemId < 12000 && _canBuildItems[itemId]) { __result = 100; } } } private static void DoInit() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 _canBuildItems = new bool[12000]; ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray; foreach (ItemProto val in dataArray) { if (((int)val.Type == 5 || val.CanBuild) && ((Proto)val).ID < 12000) { _canBuildItems[((Proto)val).ID] = true; } } } } private class NoConditionBuild : PatchImpl<NoConditionBuild> { protected override void OnEnable() { GameData data = GameMain.data; if (data != null) { WarningSystem warningSystem = data.warningSystem; if (warningSystem != null) { warningSystem.UpdateCriticalWarningText(); } } } protected override void OnDisable() { GameData data = GameMain.data; if (data != null) { WarningSystem warningSystem = data.warningSystem; if (warningSystem != null) { warningSystem.UpdateCriticalWarningText(); } } } [HarmonyTranspiler] [HarmonyPriority(0)] [HarmonyPatch(typeof(BuildTool_Addon), "CheckBuildConditions")] [HarmonyPatch(typeof(BuildTool_Inserter), "CheckBuildConditions")] private static IEnumerable<CodeInstruction> BuildTool_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions) { yield return new CodeInstruction(OpCodes.Ldc_I4_1, (object)null); yield return new CodeInstruction(OpCodes.Ret, (object)null); } [HarmonyTranspiler] [HarmonyPriority(800)] [HarmonyPatch(typeof(BuildTool_Path), "CheckBuildConditions")] private static IEnumerable<CodeInstruction> BuildTool_Path_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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 //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); Label label = generator.DefineLabel(); Label label2 = generator.DefineLabel(); val.Start().InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Br, (object)label) }); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(BuildTool), "buildPreviews"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(List<BuildPreview>), "Count"), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsStloc(ci, (LocalBuilder)null)), (string)null) }); val.Labels.Add(label); val.Advance(4).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Br, (object)label2) }); Label? label4 = default(Label?); Label? label3 = default(Label?); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdloc(ci, (LocalBuilder)null)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Branches(ci, ref label4)), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(BuildTool_Path), "waitForConfirm"), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Branches(ci, ref label3)), (string)null) }); object operand = val.Operand; val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldc_I4_1, (object)null), new Label[1] { label2 }), new CodeInstruction(OpCodes.Stloc_S, operand) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPriority(0)] [HarmonyPatch(typeof(BuildTool_BlueprintPaste), "CheckBuildConditions")] [HarmonyPatch(typeof(BuildTool_Click), "CheckBuildConditions")] private static IEnumerable<CodeInstruction> BuildTool_Click_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); Label label = generator.DefineLabel(); val.Start().InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(NoConditionBuild), "CheckForMiner", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Brfalse_S, (object)label), new CodeInstruction(OpCodes.Ldc_I4_1, (object)null), new CodeInstruction(OpCodes.Ret, (object)null) }); val.Labels.Add(label); return val.InstructionEnumeration(); } public static bool CheckForMiner(BuildTool tool) { foreach (BuildPreview buildPreview in tool.buildPreviews) { PrefabDesc val = buildPreview?.item?.prefabDesc; if (val != null && (val.veinMiner || val.oilMiner)) { return false; } } return true; } } public class BeltSignalGenerator : PatchImpl<BeltSignalGenerator> { private class BeltSignal { public int SignalId; public int SpeedLimit; public byte Stack; public byte Inc; public int Progress; public Tuple<int, float>[] Sources; public float[] SourceProgress; } private class ItemSource { public float Count; public Dictionary<int, float> From; public Dictionary<int, float> Extra; } private static Dictionary<int, BeltSignal>[] _signalBelts; private static Dictionary<long, int> _portalFrom; private static Dictionary<int, HashSet<long>> _portalTo; private static int _signalBeltsCapacity; private static bool _initialized; private static readonly Dictionary<int, ItemSource> ItemSources = new Dictionary<int, ItemSource>(); private static bool _itemSourcesInitialized; protected override void OnEnable() { InitSignalBelts(); GameLogic.OnGameBegin = (Action)Delegate.Combine(GameLogic.OnGameBegin, new Action(GameMain_Begin_Postfix)); } protected override void OnDisable() { GameLogic.OnGameBegin = (Action)Delegate.Remove(GameLogic.OnGameBegin, new Action(GameMain_Begin_Postfix)); _initialized = false; _signalBelts = null; _signalBeltsCapacity = 0; } public static void OnAltFormatChanged() { if (_signalBelts == null) { return; } PlanetFactory[] array = GameMain.data?.factories; if (array == null) { return; } int factoryCount = GameMain.data.factoryCount; bool value = BeltSignalNumberAltFormat.Value; for (int num = Math.Min(_signalBelts.Length, factoryCount) - 1; num >= 0; num--) { PlanetFactory val = array[num]; CargoTraffic val2 = val?.cargoTraffic; if (val2 != null) { SignData[] entitySignPool = val.entitySignPool; if (entitySignPool != null) { Dictionary<int, BeltSignal> dictionary = _signalBelts[num]; if (dictionary != null) { foreach (KeyValuePair<int, BeltSignal> item in dictionary) { int key = item.Key; ref BeltComponent reference = ref val2.beltPool[key]; if (reference.id != key) { continue; } ref SignData reference2 = ref entitySignPool[reference.entityId]; if (reference2.iconId0 >= 1000) { BeltSignal value2 = item.Value; int num2 = value2.Inc / value2.Stack; if (value) { reference2.count0 = value2.SpeedLimit + value2.Stack * 10000 + num2 * 100000; } else { reference2.count0 = value2.SpeedLimit * 100 + value2.Stack + num2 * 10; } } } } } } } } private static void InitSignalBelts() { if (!GameMain.isRunning) { return; } _signalBelts = new Dictionary<int, BeltSignal>[64]; _signalBeltsCapacity = 64; _portalFrom = new Dictionary<long, int>(); _portalTo = new Dictionary<int, HashSet<long>>(); PlanetFactory[] array = GameMain.data?.factories; if (array == null) { return; } PlanetFactory[] array2 = array; foreach (PlanetFactory val in array2) { SignData[] array3 = val?.entitySignPool; if (array3 == null) { continue; } CargoTraffic cargoTraffic = val.cargoTraffic; BeltComponent[] beltPool = cargoTraffic.beltPool; for (int num = cargoTraffic.beltCursor - 1; num > 0; num--) { if (beltPool[num].id != num) { continue; } ref SignData reference = ref array3[beltPool[num].entityId]; uint iconId = reference.iconId0; if (iconId == 0) { continue; } int num2 = Mathf.RoundToInt(reference.count0); if (iconId >= 1000) { if (iconId >= 20000) { continue; } } else { switch (iconId) { case 404u: SetSignalBelt(val.index, num, (int)iconId, 0); continue; case 600u: break; case 601u: case 602u: case 603u: case 604u: case 605u: case 606u: case 607u: case 608u: case 609u: if (num2 > 0) { SetSignalBeltPortalTo(val.index, num, num2); } continue; default: continue; } } if (num2 > 0) { SetSignalBelt(val.index, num, (int)iconId, num2); } } } _initialized = true; } private static Dictionary<int, BeltSignal> GetOrCreateSignalBelts(int index) { if (index < 0) { return null; } Dictionary<int, BeltSignal> dictionary; if (index >= _signalBeltsCapacity) { int num = _signalBeltsCapacity * 2; Dictionary<int, BeltSignal>[] array = new Dictionary<int, BeltSignal>[num]; Array.Copy(_signalBelts, array, _signalBeltsCapacity); _signalBelts = array; _signalBeltsCapacity = num; } else { dictionary = _signalBelts[index]; if (dictionary != null) { return dictionary; } } dictionary = new Dictionary<int, BeltSignal>(); _signalBelts[index] = dictionary; return dictionary; } private static Dictionary<int, BeltSignal> GetSignalBelts(int index) { if (index < 0 || index >= _signalBeltsCapacity) { return null; } return _signalBelts[index]; } private static void SetSignalBelt(int factory, int beltId, int signalId, int number) { int num; int num2; int num3; if (signalId >= 1000) { if (!BeltSignalNumberAltFormat.Value) { num = Mathf.Clamp(number % 10, 1, 4); num2 = number / 10 % 10 * num; num3 = number / 100; } else { num = Mathf.Clamp(number / 10000 % 10, 1, 4); num2 = number / 100000 % 10 * num; num3 = number % 10000; } } else { num = 0; num2 = 0; num3 = number; } if (num3 > 3600) { num3 = 3600; } Dictionary<int, BeltSignal> orCreateSignalBelts = GetOrCreateSignalBelts(factory); if (orCreateSignalBelts.TryGetValue(beltId, out var value)) { value.SpeedLimit = num3; value.Stack = (byte)num; value.Inc = (byte)num2; value.Progress = 0; if (value.SignalId != signalId) { value.SignalId = signalId; AddSourcesToBeltSignal(value, signalId); } return; } BeltSignal beltSignal = new BeltSignal { SignalId = signalId, SpeedLimit = num3, Stack = (byte)num, Inc = (byte)num2 }; if (signalId >= 1000) { AddSourcesToBeltSignal(beltSignal, signalId); } orCreateSignalBelts[beltId] = beltSignal; } private static void AddSourcesToBeltSignal(BeltSignal beltSignal, int itemId) { Dictionary<int, float> dictionary = new Dictionary<int, float>(); Dictionary<int, float> dictionary2 = new Dictionary<int, float>(); CalculateAllProductions(dictionary, dictionary2, itemId); foreach (KeyValuePair<int, float> item in dictionary2) { if (!dictionary.TryGetValue(itemId, out var value) || !(value >= item.Value)) { dictionary[itemId] = item.Value; } } dictionary.Remove(itemId); int num = dictionary.Count; if (num == 0) { beltSignal.Sources = null; beltSignal.SourceProgress = null; return; } Tuple<int, float>[] array = new Tuple<int, float>[num]; float[] sourceProgress = new float[num]; foreach (KeyValuePair<int, float> item2 in dictionary) { array[--num] = Tuple.Create(item2.Key, item2.Value); } beltSignal.Sources = array; beltSignal.SourceProgress = sourceProgress; } private static void SetSignalBeltPortalTo(int factory, int beltId, int number) { long num = ((long)factory << 32) | (uint)beltId; _portalFrom[num] = number; if (!_portalTo.TryGetValue(number, out var value)) { value = new HashSet<long>(); _portalTo[number] = value; } value.Add(num); } private static void RemoveSignalBelt(int factory, int beltId) { GetSignalBelts(factory)?.Remove(beltId); } private static void RemovePlanetSignalBelts(int factory) { GetSignalBelts(factory)?.Clear(); } private static void RemoveSignalBeltPortalEnd(int factory, int beltId) { long num = ((long)factory << 32) | (uint)beltId; if (_portalFrom.TryGetValue(num, out var value)) { _portalFrom.Remove(beltId); if (_portalTo.TryGetValue(value, out var value2)) { value2.Remove(num); } } } private static void GameMain_Begin_Postfix() { if (BeltSignalGeneratorEnabled.Value) { InitSignalBelts(); } InitItemSources(); } [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static void DigitalSystem_Constructor_Postfix(PlanetData _planet) { if (BeltSignalGeneratorEnabled.Value && GameMain.mainPlayer != null) { PlanetFactory val = _planet?.factory; if (val != null) { RemovePlanetSignalBelts(val.index); } } } [HarmonyPrefix] [HarmonyPatch(typeof(CargoTraffic), "RemoveBeltComponent")] public static void CargoTraffic_RemoveBeltComponent_Prefix(int id) { if (_initialized) { PlanetData localPlanet = GameMain.localPlanet; if (localPlanet != null) { RemoveSignalBeltPortalEnd(localPlanet.factoryIndex, id); RemoveSignalBelt(localPlanet.factoryIndex, id); } } } [HarmonyPostfix] [HarmonyPatch(typeof(CargoTraffic), "SetBeltSignalIcon")] public static void CargoTraffic_SetBeltSignalIcon_Postfix(CargoTraffic __instance, int signalId, int entityId) { if (!_initialized) { return; } PlanetData localPlanet = GameMain.localPlanet; if (localPlanet == null) { return; } PlanetFactory factory = __instance.factory; bool flag = false; int num; if (signalId >= 1000) { if (signalId < 20000) { goto IL_005d; } } else if (signalId >= 601) { if (signalId <= 609) { num = Mathf.RoundToInt(factory.entitySignPool[entityId].count0); int factoryIndex = localPlanet.factoryIndex; int beltId = factory.entityPool[entityId].beltId; if (num > 0) { SetSignalBeltPortalTo(factoryIndex, beltId, num); } RemoveSignalBelt(factoryIndex, beltId); return; } } else { if (signalId == 404) { num = 0; flag = true; goto IL_00c8; } if (signalId == 600) { goto IL_005d; } } num = 0; goto IL_00c8; IL_00c8: int factoryIndex2 = localPlanet.factoryIndex; int beltId2 = factory.entityPool[entityId].beltId; if (flag) { SetSignalBelt(factoryIndex2, beltId2, signalId, num); } else { RemoveSignalBelt(factoryIndex2, beltId2); } RemoveSignalBeltPortalEnd(factoryIndex2, beltId2); return; IL_005d: num = Mathf.RoundToInt(factory.entitySignPool[entityId].count0); if (num > 0) { flag = true; } goto IL_00c8; } [HarmonyPostfix] [HarmonyPatch(typeof(CargoTraffic), "SetBeltSignalNumber")] public static void CargoTraffic_SetBeltSignalNumber_Postfix(CargoTraffic __instance, float number, int entityId) { if (!_initialized) { return; } PlanetData localPlanet = GameMain.localPlanet; if (localPlanet == null) { return; } PlanetFactory factory = __instance.factory; SignData[] entitySignPool = factory.entitySignPool; uint iconId; if (entitySignPool[entityId].iconType == 0 || (iconId = entitySignPool[entityId].iconId0) == 0) { return; } if (iconId >= 1000) { if (iconId >= 20000) { return; } } else { switch (iconId) { default: return; case 601u: case 602u: case 603u: case 604u: case 605u: case 606u: case 607u: case 608u: case 609u: { int factoryIndex = localPlanet.factoryIndex; int beltId = factory.entityPool[entityId].beltId; RemoveSignalBeltPortalEnd(factoryIndex, beltId); SetSignalBeltPortalTo(factoryIndex, beltId, Mathf.RoundToInt(number)); return; } case 600u: break; } } int factoryIndex2 = localPlanet.factoryIndex; int beltId2 = factory.entityPool[entityId].beltId; int num = Mathf.RoundToInt(number); if (num == 0) { RemoveSignalBelt(factoryIndex2, beltId2); } else { SetSignalBelt(factoryIndex2, beltId2, (int)iconId, num); } } public static void ProcessBeltSignals() { //IL_01d2: Unknown result type (might be due to invalid IL or missing references) if (!_initialized) { return; } PlanetFactory[] array = GameMain.data?.factories; if (array == null) { return; } PerformanceMonitor.BeginSample((ECpuWorkEntry)10); PlanetFactory[] array2 = array; int progress = default(int); byte b5 = default(byte); byte b3 = default(byte); Cargo val2 = default(Cargo); int num6 = default(int); byte b = default(byte); byte b2 = default(byte); byte b4 = default(byte); foreach (PlanetFactory val in array2) { if (val == null) { continue; } Dictionary<int, BeltSignal> signalBelts = GetSignalBelts(val.index); if (signalBelts == null || signalBelts.Count == 0) { continue; } FactoryProductionStat obj = GameMain.statistics.production.factoryStatPool[val.index]; int[] productRegister = obj.productRegister; int[] consumeRegister = obj.consumeRegister; bool value = BeltSignalCountRecipeEnabled.Value; CargoTraffic cargoTraffic = val.cargoTraffic; foreach (KeyValuePair<int, BeltSignal> item3 in signalBelts) { BeltSignal value2 = item3.Value; int signalId = value2.SignalId; if (signalId >= 1000) { if (signalId >= 20000) { continue; } bool flag = value2.SpeedLimit > 0; if (flag) { value2.Progress += value2.SpeedLimit; progress = value2.Progress; if (progress < 3600) { continue; } if (progress > 18000) { value2.Progress = 14400; } } int key = item3.Key; ref BeltComponent reference = ref cargoTraffic.beltPool[key]; CargoPath cargoPath = cargoTraffic.GetCargoPath(reference.segPathId); if (cargoPath == null) { continue; } byte stack = value2.Stack; byte inc = value2.Inc; if (!cargoPath.TryInsertItem(reference.segIndex + reference.segPivotOffset, signalId, stack, inc)) { continue; } if (flag) { value2.Progress -= 3600; } if (BeltSignalCountGenEnabled.Value) { productRegister[signalId] += stack; } if (!value) { continue; } Tuple<int, float>[] sources = value2.Sources; if (sources == null) { continue; } float[] sourceProgress = value2.SourceProgress; float num = (int)stack; for (int num2 = sources.Length - 1; num2 >= 0; num2--) { float num3 = sourceProgress[num2] + sources[num2].Item2 * num; if (num3 > 0f) { int item = sources[num2].Item1; int num4 = Mathf.CeilToInt(num3); productRegister[item] += num4; consumeRegister[item] += num4; sourceProgress[num2] = num3 - (float)num4; } else { sourceProgress[num2] = num3; } } continue; } switch (signalId)