mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 04:13:32 +08:00
WIP
This commit is contained in:
57
CheatEnabler/AbnormalDiabler.cs
Normal file
57
CheatEnabler/AbnormalDiabler.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace CheatEnabler;
|
||||
public static class AbnormalDisabler
|
||||
{
|
||||
public static ConfigEntry<bool> Enabled;
|
||||
private static Dictionary<int, AbnormalityDeterminator> _savedDeterminators;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyBeforeGameSave")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnAssemblerRecipePick")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnGameBegin")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnMechaForgeTaskComplete")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnUnlockTech")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnUseConsole")]
|
||||
private static bool DisableAbnormalLogic()
|
||||
{
|
||||
return !Enabled.Value;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "InitDeterminators")]
|
||||
private static void DisableAbnormalDeterminators(AbnormalityLogic __instance)
|
||||
{
|
||||
_savedDeterminators = __instance.determinators;
|
||||
Enabled.SettingChanged += (_, _) =>
|
||||
{
|
||||
if (Enabled.Value)
|
||||
{
|
||||
_savedDeterminators = __instance.determinators;
|
||||
__instance.determinators = new Dictionary<int, AbnormalityDeterminator>();
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnUnregEvent();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.determinators = _savedDeterminators;
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnRegEvent();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_savedDeterminators = __instance.determinators;
|
||||
if (!Enabled.Value) return;
|
||||
__instance.determinators = new Dictionary<int, AbnormalityDeterminator>();
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnUnregEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user