From 7e942d61cc73e4ea2b0dc116798bb1134ecdae3a Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Tue, 21 Feb 2023 04:23:55 -0600 Subject: [PATCH] funky patch for FBT --- DesktopVRSwitch/DesktopVRSwitch.cs | 6 +++++- DesktopVRSwitch/HarmonyPatches.cs | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/DesktopVRSwitch/DesktopVRSwitch.cs b/DesktopVRSwitch/DesktopVRSwitch.cs index 36ba8d9..529cd96 100644 --- a/DesktopVRSwitch/DesktopVRSwitch.cs +++ b/DesktopVRSwitch/DesktopVRSwitch.cs @@ -8,8 +8,9 @@ namespace NAK.Melons.DesktopVRSwitch; public class DesktopVRSwitch : MonoBehaviour { - //Debug Setting + //Debug Settings public bool _reloadLocalAvatar = true; + public bool _softVRSwitch = false; //Internal Stuff private bool _switchInProgress = false; @@ -91,6 +92,7 @@ public class DesktopVRSwitch : MonoBehaviour //one frame after switch attempt public void FailedVRModeSwitch(bool isVR) { + if (_softVRSwitch) return; //let tracked objects know a switch failed VRModeSwitchTracker.FailVRModeSwitch(isVR); } @@ -98,6 +100,7 @@ public class DesktopVRSwitch : MonoBehaviour //one frame before switch attempt public void PreVRModeSwitch(bool isVR) { + if (_softVRSwitch) return; //let tracked objects know we are attempting to switch VRModeSwitchTracker.PreVRModeSwitch(isVR); } @@ -105,6 +108,7 @@ public class DesktopVRSwitch : MonoBehaviour //one frame after switch attempt public void PostVRModeSwitch(bool isVR) { + if (_softVRSwitch) return; //close the menus TryCatchHell.CloseCohtmlMenus(); diff --git a/DesktopVRSwitch/HarmonyPatches.cs b/DesktopVRSwitch/HarmonyPatches.cs index 0b7b1e0..50e6e0a 100644 --- a/DesktopVRSwitch/HarmonyPatches.cs +++ b/DesktopVRSwitch/HarmonyPatches.cs @@ -3,6 +3,7 @@ using ABI_RC.Core.Player; using ABI_RC.Core.Savior; using ABI_RC.Core.Util.Object_Behaviour; using ABI_RC.Systems.IK; +using ABI_RC.Systems.IK.TrackingModules; using ABI_RC.Systems.MovementSystem; using HarmonyLib; using NAK.Melons.DesktopVRSwitch.Patches; @@ -96,6 +97,16 @@ internal class IKSystemPatches { __instance.referenceTransform.localScale = Vector3.one; } + [HarmonyPostfix] //lazy fix so device indecies can change properly + [HarmonyPatch(typeof(SteamVRTrackingModule), "ModuleDestroy")] + private static void Postfix_SteamVRTrackingModule_ModuleDestroy(ref SteamVRTrackingModule __instance) + { + for (int i = 0; i < __instance.TrackingPoints.Count; i++) + { + UnityEngine.Object.Destroy(__instance.TrackingPoints[i].referenceGameObject); + } + __instance.TrackingPoints.Clear(); + } } internal class VRTrackerManagerPatches