mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 00:13:36 +08:00
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
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);
|
|
}
|
|
}
|
|
} |