mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
initial release
This commit is contained in:
parent
81d3bca79b
commit
25fa179bd8
6 changed files with 216 additions and 0 deletions
44
TrackedControllerFix/HarmonyPatches.cs
Normal file
44
TrackedControllerFix/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using ABI_RC.Core.Base;
|
||||
using ABI_RC.Core.Player;
|
||||
using HarmonyLib;
|
||||
using Valve.VR;
|
||||
|
||||
namespace NAK.Melons.TrackedControllerFix.HarmonyPatches;
|
||||
|
||||
internal class PlayerSetupPatches
|
||||
{
|
||||
public static SteamVR_Behaviour_Pose vrLeftHandPose;
|
||||
public static SteamVR_Behaviour_Pose vrRightHandPose;
|
||||
|
||||
public static SteamVR_TrackedObject vrLeftHandTracker;
|
||||
public static SteamVR_TrackedObject vrRightHandTracker;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), "Start")]
|
||||
private static void Post_PlayerSetup_Start(ref PlayerSetup __instance)
|
||||
{
|
||||
// Add SteamVR_TrackedObject and get SteamVR_Behaviour_Pose
|
||||
vrLeftHandTracker = __instance.vrLeftHandTracker.AddComponent<SteamVR_TrackedObject>();
|
||||
vrRightHandTracker = __instance.vrRightHandTracker.AddComponent<SteamVR_TrackedObject>();
|
||||
vrLeftHandPose = __instance.vrLeftHandTracker.GetComponent<SteamVR_Behaviour_Pose>();
|
||||
vrRightHandPose = __instance.vrRightHandTracker.GetComponent<SteamVR_Behaviour_Pose>();
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), "SetupAvatarVr")]
|
||||
private static void Prefix_PlayerSetup_SetupAvatarVr()
|
||||
{
|
||||
// This is a super lazy way of doing this...
|
||||
// but this is the best way to support DesktopVRSwitch & not redo the controller inputs
|
||||
if (vrLeftHandTracker != null)
|
||||
{
|
||||
vrLeftHandTracker.SetDeviceIndex(vrLeftHandPose.GetDeviceIndex());
|
||||
vrLeftHandPose.enabled = false;
|
||||
}
|
||||
if (vrRightHandTracker != null)
|
||||
{
|
||||
vrRightHandTracker.SetDeviceIndex(vrRightHandPose.GetDeviceIndex());
|
||||
vrRightHandPose.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue