This commit is contained in:
NotAKidoS 2023-02-18 09:49:38 -06:00
parent 04f35bdc54
commit dcde01c2a9
9 changed files with 26 additions and 27 deletions

View file

@ -89,40 +89,40 @@ public class DesktopVRSwitch : MonoBehaviour
} }
//one frame after switch attempt //one frame after switch attempt
public void FailedVRModeSwitch(bool enterVR) public void FailedVRModeSwitch(bool isVR)
{ {
//let tracked objects know a switch failed //let tracked objects know a switch failed
VRModeSwitchTracker.FailVRModeSwitch(enterVR); VRModeSwitchTracker.FailVRModeSwitch(isVR);
} }
//one frame before switch attempt //one frame before switch attempt
public void PreVRModeSwitch(bool enterVR) public void PreVRModeSwitch(bool isVR)
{ {
//let tracked objects know we are attempting to switch //let tracked objects know we are attempting to switch
VRModeSwitchTracker.PreVRModeSwitch(enterVR); VRModeSwitchTracker.PreVRModeSwitch(isVR);
} }
//one frame after switch attempt //one frame after switch attempt
public void PostVRModeSwitch(bool enterVR) public void PostVRModeSwitch(bool isVR)
{ {
//close the menus //close the menus
TryCatchHell.CloseCohtmlMenus(); TryCatchHell.CloseCohtmlMenus();
//the base of VR checks //the base of VR checks
TryCatchHell.SetCheckVR(enterVR); TryCatchHell.SetCheckVR(isVR);
TryCatchHell.SetMetaPort(enterVR); TryCatchHell.SetMetaPort(isVR);
//game basics for functional gameplay post switch //game basics for functional gameplay post switch
TryCatchHell.RepositionCohtmlHud(enterVR); TryCatchHell.RepositionCohtmlHud(isVR);
TryCatchHell.UpdateHudOperations(enterVR); TryCatchHell.UpdateHudOperations(isVR);
TryCatchHell.DisableMirrorCanvas(); TryCatchHell.DisableMirrorCanvas();
TryCatchHell.SwitchActiveCameraRigs(enterVR); TryCatchHell.SwitchActiveCameraRigs(isVR);
TryCatchHell.ResetCVRInputManager(); TryCatchHell.ResetCVRInputManager();
TryCatchHell.UpdateRichPresence(); TryCatchHell.UpdateRichPresence();
TryCatchHell.UpdateGestureReconizerCam(); TryCatchHell.UpdateGestureReconizerCam();
//let tracked objects know we switched //let tracked objects know we switched
VRModeSwitchTracker.PostVRModeSwitch(enterVR); VRModeSwitchTracker.PostVRModeSwitch(isVR);
//reload avatar by default, optional for debugging //reload avatar by default, optional for debugging
if (_reloadLocalAvatar) if (_reloadLocalAvatar)

View file

@ -20,7 +20,7 @@ public class CVRPickupObjectTracker : MonoBehaviour
VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch; VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch;
} }
public void PostVRModeSwitch(bool enterVR, Camera activeCamera) public void PostVRModeSwitch(bool isVR, Camera activeCamera)
{ {
if (pickupObject != null) if (pickupObject != null)
{ {

View file

@ -17,7 +17,7 @@ public class CameraFacingObjectTracker : MonoBehaviour
VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch; VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch;
} }
public void PostVRModeSwitch(bool enterVR, Camera activeCamera) public void PostVRModeSwitch(bool isVR, Camera activeCamera)
{ {
cameraFacingObject.m_Camera = activeCamera; cameraFacingObject.m_Camera = activeCamera;
} }

View file

@ -22,13 +22,13 @@ public class IKSystemTracker : MonoBehaviour
VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch; VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch;
} }
public void PostVRModeSwitch(bool enterVR, Camera activeCamera) public void PostVRModeSwitch(bool isVR, Camera activeCamera)
{ {
var _trackingModules = _traverseModules.GetValue<List<TrackingModule>>(); var _trackingModules = _traverseModules.GetValue<List<TrackingModule>>();
SteamVRTrackingModule openVRTrackingModule = _trackingModules.FirstOrDefault(m => m is SteamVRTrackingModule) as SteamVRTrackingModule; SteamVRTrackingModule openVRTrackingModule = _trackingModules.FirstOrDefault(m => m is SteamVRTrackingModule) as SteamVRTrackingModule;
if (openVRTrackingModule != null) if (openVRTrackingModule != null)
{ {
if (enterVR) if (isVR)
{ {
openVRTrackingModule.ModuleStart(); openVRTrackingModule.ModuleStart();
} }

View file

@ -22,7 +22,7 @@ public class MovementSystemTracker : MonoBehaviour
VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch; VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch;
} }
public void PreVRModeSwitch(bool enterVR, Camera activeCamera) public void PreVRModeSwitch(bool isVR, Camera activeCamera)
{ {
//correct rotationPivot y position, so we dont teleport up/down //correct rotationPivot y position, so we dont teleport up/down
Vector3 position = movementSystem.rotationPivot.transform.position; Vector3 position = movementSystem.rotationPivot.transform.position;
@ -36,11 +36,11 @@ public class MovementSystemTracker : MonoBehaviour
//so the user can still switch even if avatar is null (if it failed to load for example). //so the user can still switch even if avatar is null (if it failed to load for example).
} }
public void PostVRModeSwitch(bool enterVR, Camera activeCamera) public void PostVRModeSwitch(bool isVR, Camera activeCamera)
{ {
//lazy way of correcting Desktop & VR offset issue (game does the maths) //lazy way of correcting Desktop & VR offset issue (game does the maths)
movementSystem.TeleportToPosRot(preSwitchWorldPosition, preSwitchWorldRotation, false); movementSystem.TeleportToPosRot(preSwitchWorldPosition, preSwitchWorldRotation, false);
//recenter desktop collision to player object //recenter desktop collision to player object
if (!enterVR) movementSystem.UpdateColliderCenter(movementSystem.transform.position); if (!isVR) movementSystem.UpdateColliderCenter(movementSystem.transform.position);
} }
} }

View file

@ -10,35 +10,35 @@ public class VRModeSwitchTracker
public static event UnityAction<bool, Camera> OnPostVRModeSwitch; public static event UnityAction<bool, Camera> OnPostVRModeSwitch;
public static event UnityAction<bool, Camera> OnFailVRModeSwitch; public static event UnityAction<bool, Camera> OnFailVRModeSwitch;
public static void PreVRModeSwitch(bool enterVR) public static void PreVRModeSwitch(bool isVR)
{ {
TryCatchHell.TryCatchWrapper(() => TryCatchHell.TryCatchWrapper(() =>
{ {
DesktopVRSwitchMod.Logger.Msg("Invoking VRModeSwitchTracker.OnPreVRModeSwitch."); DesktopVRSwitchMod.Logger.Msg("Invoking VRModeSwitchTracker.OnPreVRModeSwitch.");
Camera activeCamera = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>(); Camera activeCamera = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
VRModeSwitchTracker.OnPreVRModeSwitch?.Invoke(enterVR, activeCamera); VRModeSwitchTracker.OnPreVRModeSwitch?.Invoke(isVR, activeCamera);
}, },
"Error while invoking VRModeSwitchTracker.OnPreVRModeSwitch. Did someone do a fucky?"); "Error while invoking VRModeSwitchTracker.OnPreVRModeSwitch. Did someone do a fucky?");
} }
public static void PostVRModeSwitch(bool enterVR) public static void PostVRModeSwitch(bool isVR)
{ {
TryCatchHell.TryCatchWrapper(() => TryCatchHell.TryCatchWrapper(() =>
{ {
DesktopVRSwitchMod.Logger.Msg("Invoking VRModeSwitchTracker.OnPostVRModeSwitch."); DesktopVRSwitchMod.Logger.Msg("Invoking VRModeSwitchTracker.OnPostVRModeSwitch.");
Camera activeCamera = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>(); Camera activeCamera = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
VRModeSwitchTracker.OnPostVRModeSwitch?.Invoke(enterVR, activeCamera); VRModeSwitchTracker.OnPostVRModeSwitch?.Invoke(isVR, activeCamera);
}, },
"Error while invoking VRModeSwitchTracker.OnPostVRModeSwitch. Did someone do a fucky?"); "Error while invoking VRModeSwitchTracker.OnPostVRModeSwitch. Did someone do a fucky?");
} }
public static void FailVRModeSwitch(bool enterVR) public static void FailVRModeSwitch(bool isVR)
{ {
TryCatchHell.TryCatchWrapper(() => TryCatchHell.TryCatchWrapper(() =>
{ {
DesktopVRSwitchMod.Logger.Msg("Invoking VRModeSwitchTracker.OnFailVRModeSwitch."); DesktopVRSwitchMod.Logger.Msg("Invoking VRModeSwitchTracker.OnFailVRModeSwitch.");
Camera activeCamera = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>(); Camera activeCamera = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
VRModeSwitchTracker.OnFailVRModeSwitch?.Invoke(enterVR, activeCamera); VRModeSwitchTracker.OnFailVRModeSwitch?.Invoke(isVR, activeCamera);
}, },
"Error while invoking OnFailVRModeSwitch.OnPreVRModeSwitch. Did someone do a fucky?"); "Error while invoking OnFailVRModeSwitch.OnPreVRModeSwitch. Did someone do a fucky?");
} }

View file

@ -22,7 +22,7 @@ public class VRTrackerManagerTracker : MonoBehaviour
VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch; VRModeSwitchTracker.OnPostVRModeSwitch -= PostVRModeSwitch;
} }
public void PostVRModeSwitch(bool enterVR, Camera activeCamera) public void PostVRModeSwitch(bool isVR, Camera activeCamera)
{ {
//force the VRTrackerManager to reset anything its stored //force the VRTrackerManager to reset anything its stored
//this makes it get correct Left/Right hand if entering VR with different controllers //this makes it get correct Left/Right hand if entering VR with different controllers

View file

@ -25,6 +25,6 @@ using System.Reflection;
namespace NAK.Melons.DesktopVRSwitch.Properties; namespace NAK.Melons.DesktopVRSwitch.Properties;
internal static class AssemblyInfoParams internal static class AssemblyInfoParams
{ {
public const string Version = "4.3.1"; public const string Version = "4.3.2";
public const string Author = "NotAKidoS"; public const string Author = "NotAKidoS";
} }

View file

@ -177,4 +177,3 @@ internal class TryCatchHell
"Failed to update CVRGestureRecognizer camera."); "Failed to update CVRGestureRecognizer camera.");
} }
} }