mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
Move many mods to Deprecated folder, fix spelling
This commit is contained in:
parent
5e822cec8d
commit
0042590aa6
539 changed files with 7475 additions and 3120 deletions
|
@ -0,0 +1,23 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVRGestureRecognizerTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Updating CVRGestureRecognizer _camera to active camera.");
|
||||
|
||||
CVRGestureRecognizer.Instance._camera = args.PlayerCamera;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
using ABI_RC.Core;
|
||||
using ABI_RC.Systems.InputManagement;
|
||||
using ABI_RC.Systems.InputManagement.InputModules;
|
||||
using ABI_RC.Systems.InputManagement.XR.Modules;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVRInputManagerTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Resetting CVRInputManager inputs.");
|
||||
|
||||
CVRInputManager.Instance.inputEnabled = true;
|
||||
|
||||
// IM CRYING
|
||||
//CVRInputManager.Instance.reload = true;
|
||||
|
||||
// TODO: MOVE THIS TO DIFFERENT TRACKER
|
||||
RootLogic.Instance.ToggleMouse(args.IsUsingVr);
|
||||
|
||||
//just in case
|
||||
CVRInputManager.Instance.textInputFocused = false;
|
||||
//sometimes head can get stuck, so just in case
|
||||
CVRInputManager.Instance.independentHeadToggle = false;
|
||||
//just nice to load into desktop with idle gesture
|
||||
CVRInputManager.Instance.gestureLeft = 0f;
|
||||
CVRInputManager.Instance.gestureLeftRaw = 0f;
|
||||
CVRInputManager.Instance.gestureRight = 0f;
|
||||
CVRInputManager.Instance.gestureRightRaw = 0f;
|
||||
//turn off finger tracking input
|
||||
CVRInputManager.Instance.individualFingerTracking = false;
|
||||
|
||||
//add input module if you started in desktop
|
||||
if (CVRInputManager._moduleXR == null)
|
||||
{
|
||||
CVRInputManager.Instance.AddInputModule(CVRInputManager._moduleXR = new CVRInputModule_XR());
|
||||
}
|
||||
else
|
||||
{
|
||||
// set to null so input manager doesnt attempt to access it
|
||||
|
||||
if (CVRInputManager._moduleXR._leftModule != null)
|
||||
if (CVRInputManager._moduleXR._leftModule is CVRXRModule_SteamVR leftModule) leftModule._steamVr = null;
|
||||
if (CVRInputManager._moduleXR._rightModule != null)
|
||||
if (CVRInputManager._moduleXR._rightModule is CVRXRModule_SteamVR rightModule) rightModule._steamVr = null;
|
||||
}
|
||||
|
||||
//enable xr input or whatnot
|
||||
CVRInputManager._moduleXR.InputEnabled = args.IsUsingVr;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using ABI.CCK.Components;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVRPickupObjectTracker : MonoBehaviour
|
||||
{
|
||||
internal CVRPickupObject _pickupObject;
|
||||
internal Transform _storedGripOrigin;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
public void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
if (_pickupObject == null)
|
||||
return;
|
||||
|
||||
// Drop the object if it is being held locally
|
||||
if (_pickupObject._controllerRay != null)
|
||||
_pickupObject._controllerRay.DropObject(true);
|
||||
|
||||
// Swap the grip origins
|
||||
(_storedGripOrigin, _pickupObject.gripOrigin) = (_pickupObject.gripOrigin, _storedGripOrigin);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.Player;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVRWorldTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Configuring CVRWorld. Updating PostProcessing & DesktopCameraController FOV settings.");
|
||||
|
||||
// some post processing settings aren't used in VR
|
||||
CVRWorld.Instance.UpdatePostProcessing();
|
||||
UpdateCVRDesktopCameraController();
|
||||
}
|
||||
|
||||
private void UpdateCVRDesktopCameraController()
|
||||
{
|
||||
// Just making sure- Starting in VR will not call Start() as rig is disabled
|
||||
if (CVR_DesktopCameraController._cam == null)
|
||||
CVR_DesktopCameraController._cam = PlayerSetup.Instance.desktopCamera.GetComponent<Camera>();
|
||||
|
||||
CVR_DesktopCameraController.defaultFov = Mathf.Clamp(CVRWorld.Instance.fov, 60f, 120f);
|
||||
CVR_DesktopCameraController.zoomFov = CVR_DesktopCameraController.defaultFov * 0.5f;
|
||||
CVR_DesktopCameraController.enableZoom = CVRWorld.Instance.enableZoom;
|
||||
|
||||
// must happen after PlayerSetupTracker
|
||||
CVR_DesktopCameraController.UpdateFov();
|
||||
|
||||
CVR_MenuManager.Instance.coreData.instance.current_game_rule_no_zoom = !CVRWorld.Instance.enableZoom;
|
||||
|
||||
// UICamera has a script that copies the FOV from the desktop cam.
|
||||
// Toggling the cameras on/off resets the aspect ratio,
|
||||
// so when rigs switch, that is already handled.
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVR_InteractableManagerTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg($"Enabling CVR_InteractableManager enableInteractions.");
|
||||
|
||||
// ?
|
||||
CVR_InteractableManager.enableInteractions = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVR_MenuManagerTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch += OnPreSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch -= OnPreSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPreSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Closing CVR_MenuManager - Quick Menu.");
|
||||
|
||||
CVR_MenuManager.Instance.ToggleQuickMenu(false);
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Updating CVR_Menu_Data core data.");
|
||||
|
||||
CVR_MenuManager.Instance.coreData.core.inVr = args.IsUsingVr;
|
||||
CVR_MenuManager.Instance.quickMenu.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using ABI_RC.Core.Util.Object_Behaviour;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CameraFacingObjectTracker : MonoBehaviour
|
||||
{
|
||||
private CameraFacingObject _cameraFacingObject;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_cameraFacingObject = GetComponent<CameraFacingObject>();
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
public void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
_cameraFacingObject.m_Camera = args.PlayerCamera;
|
||||
}
|
||||
}
|
21
.Deprecated/DesktopVRSwitch/VRModeTrackers/CheckVRTracker.cs
Normal file
21
.Deprecated/DesktopVRSwitch/VRModeTrackers/CheckVRTracker.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CheckVRTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
CheckVR.Instance.hasVrDeviceLoaded = args.IsUsingVr;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
using ABI_RC.Core;
|
||||
using ABI_RC.Core.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CohtmlHudTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Configuring new hud affinity for CohtmlHud.");
|
||||
|
||||
CohtmlHud.Instance.gameObject.transform.parent = Utils.GetPlayerCameraObject(args.IsUsingVr).transform;
|
||||
|
||||
// This handles rotation and position
|
||||
CVRTools.ConfigureHudAffinity();
|
||||
CohtmlHud.Instance.gameObject.transform.localScale = new Vector3(1.2f, 1f, 1.2f);
|
||||
|
||||
// required to set menu vr mode (why is it offset in js?)
|
||||
CohtmlHud.uiCoreGameData.isVr = args.IsUsingVr;
|
||||
if (CohtmlHud.Instance._isReady)
|
||||
CohtmlHud.Instance.hudView.View.TriggerEvent("updateCoreGameVars", CohtmlHud.uiCoreGameData);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using ABI_RC.Core.Player;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class HudOperationsTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Switching HudOperations worldLoadingItem & worldLoadStatus.");
|
||||
|
||||
HudOperations.Instance.worldLoadingItem = args.IsUsingVr ? HudOperations.Instance.worldLoadingItemVr : HudOperations.Instance.worldLoadingItemDesktop;
|
||||
HudOperations.Instance.worldLoadStatus = args.IsUsingVr ? HudOperations.Instance.worldLoadStatusVr : HudOperations.Instance.worldLoadStatusDesktop;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
using ABI_RC.Systems.IK;
|
||||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using ABI_RC.Systems.IK.TrackingModules;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class IKSystemTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch += OnPreSwitch;
|
||||
VRModeSwitchManager.OnFailVRModeSwitch += OnFailedSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch -= OnPreSwitch;
|
||||
VRModeSwitchManager.OnFailVRModeSwitch -= OnFailedSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPreSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
BodySystem.TrackingEnabled = false;
|
||||
BodySystem.TrackingPositionWeight = 0f;
|
||||
BodySystem.TrackingLocomotionEnabled = false;
|
||||
|
||||
if (IKSystem.vrik != null)
|
||||
IKSystem.vrik.enabled = false;
|
||||
}
|
||||
|
||||
private void OnFailedSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
BodySystem.TrackingEnabled = true;
|
||||
BodySystem.TrackingPositionWeight = 1f;
|
||||
BodySystem.TrackingLocomotionEnabled = true;
|
||||
|
||||
if (IKSystem.vrik != null)
|
||||
IKSystem.vrik.enabled = true;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
if (IKSystem.vrik != null)
|
||||
UnityEngine.Object.DestroyImmediate(IKSystem.vrik);
|
||||
|
||||
// Make sure you are fully tracking
|
||||
BodySystem.TrackingEnabled = true;
|
||||
BodySystem.TrackingPositionWeight = 1f;
|
||||
BodySystem.TrackingLocomotionEnabled = true;
|
||||
BodySystem.isCalibratedAsFullBody = false;
|
||||
BodySystem.isCalibrating = false;
|
||||
BodySystem.isRecalibration = false;
|
||||
|
||||
// Make it so you don't instantly end up in FBT from Desktop
|
||||
IKSystem.firstAvatarLoaded = ModSettings.EntryEnterCalibrationOnSwitch.Value;
|
||||
|
||||
// Turn off finger tracking just in case the user switched controllers
|
||||
IKSystem.Instance.FingerSystem.controlActive = false;
|
||||
|
||||
SetupSteamVRTrackingModule(args.IsUsingVr);
|
||||
}
|
||||
|
||||
private void SetupSteamVRTrackingModule(bool enableVR)
|
||||
{
|
||||
SteamVRTrackingModule openVRModule = IKSystem.Instance._trackingModules.OfType<SteamVRTrackingModule>().FirstOrDefault();
|
||||
|
||||
if (openVRModule != null)
|
||||
{
|
||||
if (enableVR)
|
||||
openVRModule.ModuleStart();
|
||||
else
|
||||
openVRModule.ModuleDestroy();
|
||||
}
|
||||
else if (enableVR)
|
||||
{
|
||||
IKSystem.Instance.AddTrackingModule(new SteamVRTrackingModule());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
using Valve.VR;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class MetaPortTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg($"Setting MetaPort isUsingVr to {args.IsUsingVr}.");
|
||||
|
||||
// Main thing most of the game checks for if using VR
|
||||
MetaPort.Instance.isUsingVr = args.IsUsingVr;
|
||||
|
||||
// replace
|
||||
UpdateRichPresence();
|
||||
ResetSteamVROverrides(args.IsUsingVr);
|
||||
}
|
||||
|
||||
private void UpdateRichPresence()
|
||||
{
|
||||
// Hacky way of updating rich presence
|
||||
if (MetaPort.Instance.settings.GetSettingsBool("ImplementationRichPresenceDiscordEnabled", true))
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Forcing Discord Rich Presence update.");
|
||||
MetaPort.Instance.settings.SetSettingsBool("ImplementationRichPresenceDiscordEnabled", false);
|
||||
MetaPort.Instance.settings.SetSettingsBool("ImplementationRichPresenceDiscordEnabled", true);
|
||||
}
|
||||
if (MetaPort.Instance.settings.GetSettingsBool("ImplementationRichPresenceSteamEnabled", true))
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Forcing Steam Rich Presence update.");
|
||||
MetaPort.Instance.settings.SetSettingsBool("ImplementationRichPresenceSteamEnabled", false);
|
||||
MetaPort.Instance.settings.SetSettingsBool("ImplementationRichPresenceSteamEnabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetSteamVROverrides(bool intoVR)
|
||||
{
|
||||
if (intoVR)
|
||||
{
|
||||
// Testing
|
||||
//XRSettings.gameViewRenderMode = DesktopVRSwitch.EntryRenderVRGameView.Value ? GameViewRenderMode.LeftEye : GameViewRenderMode.None;
|
||||
XRSettings.eyeTextureResolutionScale = 1; // unsure if will cause issues with FSR?
|
||||
SteamVR_Settings.instance.pauseGameWhenDashboardVisible = false;
|
||||
|
||||
if (MetaPort.Instance.settings.GetSettingsBool("InteractionTobiiEyeTracking", false))
|
||||
MetaPort.Instance.TobiiXrInitializer.Initialize();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset physics time to Desktop default
|
||||
Time.fixedDeltaTime = 0.02f;
|
||||
|
||||
// Reset queued frames
|
||||
QualitySettings.maxQueuedFrames = 2;
|
||||
|
||||
// Reset framerate target
|
||||
int graphicsFramerateTarget = MetaPort.Instance.settings.GetSettingInt("GraphicsFramerateTarget", 0);
|
||||
ABI_RC.Core.CVRTools.SetFramerateTarget(graphicsFramerateTarget);
|
||||
|
||||
// Reset VSync setting
|
||||
bool graphicsVSync = MetaPort.Instance.settings.GetSettingsBool("GraphicsVSync", false);
|
||||
QualitySettings.vSyncCount = graphicsVSync ? 1 : 0;
|
||||
|
||||
// Reset anti-aliasing
|
||||
int graphicsMsaaLevel = MetaPort.Instance.settings.GetSettingInt("GraphicsMsaaLevel", 0);
|
||||
QualitySettings.antiAliasing = graphicsMsaaLevel;
|
||||
|
||||
// Won't do anything if not already running
|
||||
MetaPort.Instance.TobiiXrInitializer.DeInitialize();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
using ABI_RC.Systems.MovementSystem;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class MovementSystemTracker : VRModeTracker
|
||||
{
|
||||
private Vector3 preSwitchWorldPosition;
|
||||
private Quaternion preSwitchWorldRotation;
|
||||
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch += OnPreSwitch;
|
||||
VRModeSwitchManager.OnFailVRModeSwitch += OnFailedSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch -= OnPreSwitch;
|
||||
VRModeSwitchManager.OnFailVRModeSwitch -= OnFailedSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPreSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
|
||||
DesktopVRSwitch.Logger.Msg("Storing player world position and rotation.");
|
||||
|
||||
var pivotTransform = MovementSystem.Instance.rotationPivot.transform;
|
||||
preSwitchWorldPosition = pivotTransform.position;
|
||||
preSwitchWorldPosition.y = MovementSystem.Instance.transform.position.y;
|
||||
preSwitchWorldRotation = pivotTransform.rotation;
|
||||
|
||||
MovementSystem.Instance.ChangeCrouch(false);
|
||||
MovementSystem.Instance.ChangeProne(false);
|
||||
MovementSystem.Instance.SetImmobilized(true);
|
||||
|
||||
}
|
||||
|
||||
private void OnFailedSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Resetting MovementSystem mobility.");
|
||||
|
||||
MovementSystem.Instance.SetImmobilized(false);
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
// Lazy
|
||||
MelonLoader.MelonCoroutines.Start(TeleportFrameAfter(args.IsUsingVr));
|
||||
}
|
||||
|
||||
private IEnumerator TeleportFrameAfter(bool intoVR)
|
||||
{
|
||||
yield return null; // need to wait a frame
|
||||
|
||||
DesktopVRSwitch.Logger.Msg("Resetting MovementSystem mobility and applying stored position and rotation.");
|
||||
|
||||
MovementSystem.Instance.rotationPivot = Utils.GetPlayerCameraObject(intoVR).transform;
|
||||
MovementSystem.Instance.TeleportToPosRot(preSwitchWorldPosition, preSwitchWorldRotation);
|
||||
|
||||
if (!intoVR)
|
||||
MovementSystem.Instance.UpdateColliderCenter(MovementSystem.Instance.transform.position);
|
||||
|
||||
MovementSystem.Instance.ChangeCrouch(false);
|
||||
MovementSystem.Instance.ChangeProne(false);
|
||||
MovementSystem.Instance.SetImmobilized(false);
|
||||
MovementSystem.Instance.independentHeadTurn = false;
|
||||
MovementSystem.Instance.independentHeadToggle = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using ABI_RC.Core.Player;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class PlayerSetupTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Switching active PlayerSetup camera rigs. Updating Desktop camera FOV.");
|
||||
|
||||
PlayerSetup.Instance.desktopCameraRig.SetActive(!args.IsUsingVr);
|
||||
PlayerSetup.Instance.vrCameraRig.SetActive(args.IsUsingVr);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using ABI_RC.Systems.Camera;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class PortableCameraTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Forcing PortableCamera canvas mirroring off.");
|
||||
|
||||
// Tell the game we are in mirror mode so it'll disable it (if enabled)
|
||||
PortableCamera.Instance.mode = MirroringMode.Mirror;
|
||||
PortableCamera.Instance.ChangeMirroring();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public abstract class VRModeTracker
|
||||
{
|
||||
public virtual void TrackerInit() { }
|
||||
public virtual void TrackerDestroy() { }
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class ViewManagerTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch += OnPreSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch -= OnPreSwitch;
|
||||
}
|
||||
|
||||
private void OnPreSwitch(object sender, VRModeSwitchManager.VRModeEventArgs args)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Msg("Closing ViewManager - Main Menu.");
|
||||
|
||||
ViewManager.Instance.UiStateToggle(false);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue