mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
major cleanup
This commit is contained in:
parent
b33e15377f
commit
e5242f76c7
85 changed files with 584 additions and 571 deletions
58
GestureLock/HarmonyPatches.cs
Normal file
58
GestureLock/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Core.UI;
|
||||
using HarmonyLib;
|
||||
using Valve.VR;
|
||||
|
||||
namespace NAK.GestureLock.HarmonyPatches;
|
||||
|
||||
class Patches
|
||||
{
|
||||
private static bool isLocked;
|
||||
private static float oldGestureLeft;
|
||||
private static float oldGestureRight;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(InputModuleSteamVR), nameof(InputModuleSteamVR.UpdateInput))]
|
||||
private static void Postfix_InputModuleSteamVR_UpdateInput
|
||||
(
|
||||
ref CVRInputManager ____inputManager,
|
||||
ref VRTrackerManager ____trackerManager,
|
||||
ref SteamVR_Action_Boolean ___steamVrIndexGestureToggle
|
||||
)
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (___steamVrIndexGestureToggle.stateDown && !____trackerManager.trackerNames.Contains("knuckles"))
|
||||
{
|
||||
isLocked = !isLocked;
|
||||
oldGestureLeft = ____inputManager.gestureLeft;
|
||||
oldGestureRight = ____inputManager.gestureRight;
|
||||
CohtmlHud.Instance.ViewDropTextImmediate("", "Gesture Lock", "Gestures " + (isLocked ? "Locked" : "Unlocked"));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRInputManager), nameof(CVRInputManager.Update))]
|
||||
private static void Postfix_CVRInputManager_Update
|
||||
(
|
||||
ref float ___gestureLeft,
|
||||
ref float ___gestureRight
|
||||
)
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isLocked)
|
||||
{
|
||||
// Dont override raw, other systems like the camera gesture recognizer need it.
|
||||
___gestureLeft = oldGestureLeft;
|
||||
___gestureRight = oldGestureRight;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,70 +1,24 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Core.UI;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using Valve.VR;
|
||||
using MelonLoader;
|
||||
|
||||
//I legitimately threw this at ChatGPT to rewrite cause i couldn't be bothered.
|
||||
namespace NAK.GestureLock;
|
||||
|
||||
namespace NAK.GestureLock
|
||||
public class GestureLock : MelonMod
|
||||
{
|
||||
public class GestureLockMod : MelonMod
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
[HarmonyPatch]
|
||||
private class HarmonyPatches
|
||||
ApplyPatches(typeof(HarmonyPatches.Patches));
|
||||
}
|
||||
|
||||
void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
private static bool isLocked;
|
||||
private static float oldGestureLeft;
|
||||
private static float oldGestureRight;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(InputModuleSteamVR), "UpdateInput")]
|
||||
private static void Postfix_InputModuleSteamVR_UpdateInput
|
||||
(
|
||||
ref CVRInputManager ____inputManager,
|
||||
ref VRTrackerManager ____trackerManager,
|
||||
ref SteamVR_Action_Boolean ___steamVrIndexGestureToggle
|
||||
)
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (___steamVrIndexGestureToggle.stateDown && !____trackerManager.trackerNames.Contains("knuckles"))
|
||||
{
|
||||
isLocked = !isLocked;
|
||||
oldGestureLeft = ____inputManager.gestureLeft;
|
||||
oldGestureRight = ____inputManager.gestureRight;
|
||||
CohtmlHud.Instance.ViewDropTextImmediate("", "Gesture Lock", "Gestures " + (isLocked ? "Locked" : "Unlocked"));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRInputManager), "Update")]
|
||||
private static void Postfix_CVRInputManager_Update
|
||||
(
|
||||
ref float ___gestureLeft,
|
||||
ref float ___gestureRight,
|
||||
ref float ___gestureLeftRaw,
|
||||
ref float ___gestureRightRaw
|
||||
)
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isLocked)
|
||||
{
|
||||
// Dont override raw, other systems like the camera gesture recognizer need it.
|
||||
//gestureLeftRaw = gestureLeft;
|
||||
//gestureRightRaw = gestureRight;
|
||||
___gestureLeft = oldGestureLeft;
|
||||
___gestureRight = oldGestureRight;
|
||||
}
|
||||
}
|
||||
HarmonyInstance.PatchAll(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerInstance.Msg($"Failed while patching {type.Name}!");
|
||||
LoggerInstance.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,11 +10,11 @@ using System.Reflection;
|
|||
[assembly: AssemblyProduct(nameof(NAK.GestureLock))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.GestureLock.GestureLockMod),
|
||||
typeof(NAK.GestureLock.GestureLock),
|
||||
nameof(NAK.GestureLock),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/GestureLock"
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/GestureLock"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/GestureLock/releases/download/v2.0.0/GestureLock.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/GestureLock/",
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/GestureLock.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/GestureLock/",
|
||||
"changelog": "- Simplification & refactor.",
|
||||
"embedcolor": "804221"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue