mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[DesktopVRSwitch] Handle CVRWorld- Post Processing & FOV settings.
This commit is contained in:
parent
70ae268149
commit
900c6646af
17 changed files with 62 additions and 48 deletions
|
@ -47,14 +47,8 @@ class CVRWorldPatches
|
|||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRWorld), nameof(CVRWorld.SetDefaultCamValues))]
|
||||
static void Postfix_CVRWorld_SetDefaultCamValues()
|
||||
{
|
||||
ReferenceCameraPatch.OnWorldLoad();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRWorld), nameof(CVRWorld.CopyRefCamValues))]
|
||||
static void Postfix_CVRWorld_CopyRefCamValues()
|
||||
static void Postfix_CVRWorld_HandleCamValues()
|
||||
{
|
||||
ReferenceCameraPatch.OnWorldLoad();
|
||||
}
|
||||
|
@ -66,7 +60,7 @@ class CameraFacingObjectPatches
|
|||
[HarmonyPatch(typeof(CameraFacingObject), nameof(CameraFacingObject.Start))]
|
||||
static void Postfix_CameraFacingObject_Start(ref CameraFacingObject __instance)
|
||||
{
|
||||
__instance.gameObject.AddComponent<CameraFacingObjectTracker>()._cameraFacingObject = __instance;
|
||||
__instance.gameObject.AddComponent<CameraFacingObjectTracker>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,19 +3,6 @@ using MelonLoader;
|
|||
using NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
using UnityEngine;
|
||||
|
||||
/**
|
||||
I know the TryCatchHell thing might be a bit exessive, but it is
|
||||
built so if a user that happens to have access to a build I do not,
|
||||
I will have a good idea of what broke and where, and what to look out
|
||||
for when updates/experimentals release. (which has happened a few times)
|
||||
|
||||
It is also just in case other mods break or tweak functionality that
|
||||
could fuck with switching. Or if they try to detect switching and break...
|
||||
|
||||
The VRModeSwitchTracker system is also built so I can easily & quickly make adjustments to
|
||||
components that may or may not change between builds without breaking the rest of the mod.
|
||||
**/
|
||||
|
||||
namespace NAK.DesktopVRSwitch;
|
||||
|
||||
public class DesktopVRSwitch : MelonMod
|
||||
|
@ -94,6 +81,9 @@ public class DesktopVRSwitch : MelonMod
|
|||
|
||||
// Portable camera tracker
|
||||
VRModeSwitchManager.RegisterVRModeTracker(new PortableCameraTracker());
|
||||
|
||||
// CVRWorld tracker - Must come after PlayerSetupTracker
|
||||
VRModeSwitchManager.RegisterVRModeTracker(new CVRWorldTracker());
|
||||
}
|
||||
|
||||
void ApplyPatches(Type type)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
|
51
DesktopVRSwitch/VRModeTrackers/CVRWorldTracker.cs
Normal file
51
DesktopVRSwitch/VRModeTrackers/CVRWorldTracker.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
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(bool intoVR)
|
||||
{
|
||||
CVRWorld _cvrWorld = CVRWorld.Instance;
|
||||
if (_cvrWorld == null)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Error("Error while getting CVRWorld!");
|
||||
return;
|
||||
}
|
||||
DesktopVRSwitch.Logger.Msg("Configuring CVRWorld. Updating PostProcessing & DesktopCameraController FOV settings.");
|
||||
|
||||
// some post processing settings aren't used in VR
|
||||
_cvrWorld.UpdatePostProcessing();
|
||||
UpdateCVRDesktopCameraController(_cvrWorld);
|
||||
}
|
||||
|
||||
private void UpdateCVRDesktopCameraController(CVRWorld _cvrWorld)
|
||||
{
|
||||
// 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.fov, 60f, 120f);
|
||||
CVR_DesktopCameraController.zoomFov = CVR_DesktopCameraController.defaultFov * 0.5f;
|
||||
CVR_DesktopCameraController.enableZoom = _cvrWorld.enableZoom;
|
||||
CVR_DesktopCameraController.UpdateFov(); // must happen after PlayerSetupTracker
|
||||
CVR_MenuManager.Instance.coreData.instance.current_game_rule_no_zoom = !_cvrWorld.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.
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVR_InteractableManagerTracker : VRModeTracker
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVR_MenuManagerTracker : VRModeTracker
|
||||
|
|
|
@ -5,10 +5,11 @@ namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
|||
|
||||
public class CameraFacingObjectTracker : MonoBehaviour
|
||||
{
|
||||
internal CameraFacingObject _cameraFacingObject;
|
||||
CameraFacingObject _cameraFacingObject;
|
||||
|
||||
void Start()
|
||||
{
|
||||
_cameraFacingObject = GetComponent<CameraFacingObject>();
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
|
@ -19,6 +20,7 @@ public class CameraFacingObjectTracker : MonoBehaviour
|
|||
|
||||
public void OnPostSwitch(bool intoVR)
|
||||
{
|
||||
// TODO: cache camera
|
||||
_cameraFacingObject.m_Camera = Utils.GetPlayerCameraObject(intoVR).GetComponent<Camera>();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CheckVRTracker : VRModeTracker
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Core;
|
||||
using ABI_RC.Core.UI;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Core.Player;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class HudOperationsTracker : VRModeTracker
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using ABI_RC.Systems.IK.TrackingModules;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class IKSystemTracker : VRModeTracker
|
||||
|
|
|
@ -57,14 +57,12 @@ public class MetaPortTracker : VRModeTracker
|
|||
if (intoVR)
|
||||
{
|
||||
// Testing
|
||||
XRSettings.eyeTextureResolutionScale = 1;
|
||||
XRSettings.gameViewRenderMode = DesktopVRSwitch.EntryRenderVRGameView.Value ? GameViewRenderMode.LeftEye : GameViewRenderMode.None;
|
||||
//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;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ public class MovementSystemTracker : VRModeTracker
|
|||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
// why do i do this
|
||||
private MovementSystem GetMovementSystemInstance()
|
||||
{
|
||||
MovementSystem _movementSystem = MovementSystem.Instance;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Core.Player;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class PlayerSetupTracker : VRModeTracker
|
||||
|
@ -27,16 +26,5 @@ public class PlayerSetupTracker : VRModeTracker
|
|||
|
||||
_playerSetup.desktopCameraRig.SetActive(!intoVR);
|
||||
_playerSetup.vrCameraRig.SetActive(intoVR);
|
||||
|
||||
// This might error if we started in VR.
|
||||
// '_cam' is not set until Start().
|
||||
if (CVR_DesktopCameraController._cam == null)
|
||||
CVR_DesktopCameraController._cam = _playerSetup.desktopCamera.GetComponent<UnityEngine.Camera>();
|
||||
|
||||
CVR_DesktopCameraController.UpdateFov();
|
||||
|
||||
// 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.
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Systems.Camera;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class PortableCameraTracker : VRModeTracker
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Core.Player;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class VRTrackerManagerTracker : VRModeTracker
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class ViewManagerTracker : VRModeTracker
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue