1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-11 13:13:35 +08:00
This commit is contained in:
2024-09-02 22:51:24 +08:00
parent 3a2821a2c1
commit 421cfd230e
6 changed files with 52 additions and 3 deletions

View File

@@ -8,16 +8,20 @@ namespace CheatEnabler;
public static class PlayerPatch
{
public static ConfigEntry<bool> InstantTeleportEnabled;
public static ConfigEntry<bool> WarpWithoutSpaceWarpersEnabled;
public static void Init()
{
InstantTeleportEnabled.SettingChanged += (_, _) => InstantTeleport.Enable(InstantTeleportEnabled.Value);
WarpWithoutSpaceWarpersEnabled.SettingChanged += (_, _) => WarpWithoutSpaceWarpers.Enable(WarpWithoutSpaceWarpersEnabled.Value);
InstantTeleport.Enable(InstantTeleportEnabled.Value);
WarpWithoutSpaceWarpers.Enable(WarpWithoutSpaceWarpersEnabled.Value);
}
public static void Uninit()
{
InstantTeleport.Enable(false);
WarpWithoutSpaceWarpers.Enable(false);
}
private static class InstantTeleport
@@ -57,4 +61,37 @@ public static class PlayerPatch
return matcher.InstructionEnumeration();
}
}
}
private static class WarpWithoutSpaceWarpers
{
private static Harmony _patch;
public static void Enable(bool on)
{
if (on)
{
_patch ??= Harmony.CreateAndPatchAll(typeof(WarpWithoutSpaceWarpers));
}
else
{
_patch?.UnpatchSelf();
_patch = null;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Mecha), nameof(Mecha.HasWarper))]
private static bool Mecha_HasWarper_Prefix(ref bool __result)
{
__result = true;
return false;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Mecha), nameof(Mecha.UseWarper))]
private static void Mecha_UseWarper_Postfix(ref bool __result)
{
__result = true;
}
}
}