1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 03:33:29 +08:00
This commit is contained in:
2023-09-06 21:22:11 +08:00
parent 18505caa3b
commit c974d70564
8 changed files with 621 additions and 121 deletions

View File

@@ -0,0 +1,48 @@
using BepInEx.Configuration;
using HarmonyLib;
namespace CheatEnabler;
public class DevShortcuts
{
public static ConfigEntry<bool> Enabled;
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerController), "Init")]
private static void PlayerController_Init_Postfix(PlayerController __instance)
{
var cnt = __instance.actions.Length;
var newActions = new PlayerAction[cnt + 1];
for (var i = 0; i < cnt; i++)
{
newActions[i] = __instance.actions[i];
}
var test = new PlayerAction_Test();
test.Init(__instance.player);
newActions[cnt] = test;
__instance.actions = newActions;
Enabled.SettingChanged += (_, _) =>
{
if (!Enabled.Value)
{
test.active = false;
}
};
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerAction_Test), "GameTick")]
private static void PlayerAction_Test_GameTick_Postfix(PlayerAction_Test __instance)
{
if (!Enabled.Value) return;
var lastActive = __instance.active;
__instance.Update();
if (lastActive != __instance.active)
{
UIRealtimeTip.PopupAhead(
(lastActive ? "Developer Mode Shortcuts Disabled" : "Developer Mode Shortcuts Enabled").Translate(),
false);
}
}
}