1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 12:53:34 +08:00
This commit is contained in:
2023-09-08 14:05:35 +08:00
parent 09dc6dbdcd
commit e88df0b7f4
4 changed files with 258 additions and 125 deletions

View File

@@ -12,7 +12,8 @@ public static class TerraformPatch
public static void Init()
{
_patch = Harmony.CreateAndPatchAll(typeof(TerraformPatch));
Enabled.SettingChanged += (_, _) => ValueChanged();
ValueChanged();
}
public static void Uninit()
@@ -22,6 +23,25 @@ public static class TerraformPatch
_patch = null;
}
private static void ValueChanged()
{
if (Enabled.Value)
{
if (_patch != null)
{
_patch.UnpatchSelf();
_patch = null;
}
_patch = Harmony.CreateAndPatchAll(typeof(TerraformPatch));
}
else if (_patch != null)
{
_patch.UnpatchSelf();
_patch = null;
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)