NAK_CVR_Mods/PropUndoButton/Main.cs
2026-06-18 22:20:56 -05:00

35 lines
No EOL
1 KiB
C#

using ABI_RC.Systems.InputManagement.InputModules;
using System.Reflection;
using ABI_RC.Core.PropManagement;
using HarmonyLib;
using MelonLoader;
using UnityEngine;
namespace NAK.PropUndoButton;
public class PropUndoButton : MelonMod
{
public override void OnInitializeMelon()
{
HarmonyInstance.Patch( // desktop input patch so we don't run in menus/gui
typeof(CVRInputModule_Keyboard).GetMethod(nameof(CVRInputModule_Keyboard.Update_Binds)),
postfix: new HarmonyMethod(typeof(PropUndoButton).GetMethod(nameof(OnUpdateInput),
BindingFlags.NonPublic | BindingFlags.Static))
);
}
private static void OnUpdateInput()
{
if (Input.GetKey(KeyCode.LeftControl))
{
if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.Z))
{
PropUserActions.Redo();
}
else if (Input.GetKeyDown(KeyCode.Z))
{
PropUserActions.Undo();
}
}
}
}