From e79b906f91f5c7b4788653c9b50abd48846e5191 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Mon, 25 Sep 2023 20:39:18 +0800 Subject: [PATCH] CheatEnabler v2.2.3 --- CheatEnabler/CheatEnabler.cs | 2 + CheatEnabler/CheatEnabler.csproj | 2 +- CheatEnabler/FactoryPatch.cs | 128 +++++++++++++++++++++++++++-- CheatEnabler/PlanetFunctions.cs | 106 +----------------------- CheatEnabler/README.md | 10 ++- CheatEnabler/UIConfigWindow.cs | 27 ++++-- CheatEnabler/package/manifest.json | 2 +- 7 files changed, 153 insertions(+), 124 deletions(-) diff --git a/CheatEnabler/CheatEnabler.cs b/CheatEnabler/CheatEnabler.cs index dbcd21a..0b83406 100644 --- a/CheatEnabler/CheatEnabler.cs +++ b/CheatEnabler/CheatEnabler.cs @@ -38,6 +38,8 @@ public class CheatEnabler : BaseUnityPlugin "Architect Mode"); FactoryPatch.UnlimitInteractiveEnabled = Config.Bind("Build", "UnlimitInteractive", false, "Unlimit interactive range"); + FactoryPatch.RemoveSomeConditionEnabled = Config.Bind("Build", "RemoveSomeBuildConditionCheck", false, + "Remove part of build condition checks that does not affect game logic"); FactoryPatch.NoConditionEnabled = Config.Bind("Build", "BuildWithoutCondition", false, "Build without condition"); FactoryPatch.NoCollisionEnabled = Config.Bind("Build", "NoCollision", false, diff --git a/CheatEnabler/CheatEnabler.csproj b/CheatEnabler/CheatEnabler.csproj index 6dd55d3..76ce7bd 100644 --- a/CheatEnabler/CheatEnabler.csproj +++ b/CheatEnabler/CheatEnabler.csproj @@ -5,7 +5,7 @@ net472 org.soardev.cheatenabler DSP MOD - CheatEnabler - 2.2.2 + 2.2.3 true latest CheatEnabler diff --git a/CheatEnabler/FactoryPatch.cs b/CheatEnabler/FactoryPatch.cs index 17e8476..db0b3d1 100644 --- a/CheatEnabler/FactoryPatch.cs +++ b/CheatEnabler/FactoryPatch.cs @@ -12,6 +12,7 @@ public static class FactoryPatch public static ConfigEntry ImmediateEnabled; public static ConfigEntry ArchitectModeEnabled; public static ConfigEntry UnlimitInteractiveEnabled; + public static ConfigEntry RemoveSomeConditionEnabled; public static ConfigEntry NoConditionEnabled; public static ConfigEntry NoCollisionEnabled; public static ConfigEntry BeltSignalGeneratorEnabled; @@ -25,6 +26,7 @@ public static class FactoryPatch public static ConfigEntry BoostGeothermalPowerEnabled; private static Harmony _factoryPatch; + private static Harmony _removeSomeConditionPatch; private static Harmony _noConditionPatch; public static void Init() @@ -33,6 +35,7 @@ public static class FactoryPatch ImmediateEnabled.SettingChanged += (_, _) => ImmediateValueChanged(); ArchitectModeEnabled.SettingChanged += (_, _) => ArchitectModeValueChanged(); UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractiveValueChanged(); + RemoveSomeConditionEnabled.SettingChanged += (_, _) => RemoveSomeConditionValueChanged(); NoConditionEnabled.SettingChanged += (_, _) => NoConditionValueChanged(); NoCollisionEnabled.SettingChanged += (_, _) => NoCollisionValueChanged(); BeltSignalGeneratorEnabled.SettingChanged += (_, _) => BeltSignalGeneratorValueChanged(); @@ -46,6 +49,7 @@ public static class FactoryPatch ImmediateValueChanged(); ArchitectModeValueChanged(); UnlimitInteractiveValueChanged(); + RemoveSomeConditionValueChanged(); NoConditionValueChanged(); NoCollisionValueChanged(); BeltSignalGeneratorValueChanged(); @@ -62,6 +66,8 @@ public static class FactoryPatch { _factoryPatch?.UnpatchSelf(); _factoryPatch = null; + _removeSomeConditionPatch?.UnpatchSelf(); + _removeSomeConditionPatch = null; _noConditionPatch?.UnpatchSelf(); _noConditionPatch = null; ImmediateBuild.Enable(false); @@ -91,6 +97,17 @@ public static class FactoryPatch UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value); } + private static void RemoveSomeConditionValueChanged() + { + if (RemoveSomeConditionEnabled.Value) + { + _removeSomeConditionPatch ??= Harmony.CreateAndPatchAll(typeof(RemoveSomeConditionBuild)); + return; + } + _removeSomeConditionPatch?.UnpatchSelf(); + _removeSomeConditionPatch = null; + } + private static void NoConditionValueChanged() { if (NoConditionEnabled.Value) @@ -382,7 +399,7 @@ public static class FactoryPatch if (matcher.Opcode != OpCodes.Nop && (matcher.Opcode != OpCodes.Call || !matcher.Instruction.OperandIs(AccessTools.Method(typeof(GC), nameof(GC.Collect))))) return matcher.InstructionEnumeration(); var labels = matcher.Labels; - matcher.Labels = null; + matcher.Labels = new List