mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 03:33:29 +08:00
WIP
This commit is contained in:
48
CheatEnabler/DevShortcuts.cs
Normal file
48
CheatEnabler/DevShortcuts.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user