diff --git a/ThirdPerson/CameraLogic.cs b/ThirdPerson/CameraLogic.cs index f764910..9cc3d3e 100644 --- a/ThirdPerson/CameraLogic.cs +++ b/ThirdPerson/CameraLogic.cs @@ -14,8 +14,8 @@ namespace NAK.ThirdPerson; internal static class CameraLogic { private static float _dist; - private static GameObject _ourCam; - private static GameObject _desktopCam; + private static Camera _ourCam; + private static Camera _desktopCam; private static CameraFovClone _cameraFovClone; internal static CameraLocation CurrentLocation = CameraLocation.Default; @@ -35,7 +35,8 @@ internal static class CameraLogic set { _state = value; - _ourCam.SetActive(_state); + _desktopCam.enabled = !_state; + _ourCam.gameObject.SetActive(_state); } } @@ -47,13 +48,12 @@ internal static class CameraLogic { yield return new WaitUntil(() => PlayerSetup.Instance); - _ourCam = new GameObject("ThirdPersonCameraObj") { }; - _ourCam.AddComponent(); + _ourCam = new GameObject("ThirdPersonCameraObj", typeof(Camera)).GetComponent(); - _cameraFovClone = _ourCam.AddComponent(); + _cameraFovClone = _ourCam.gameObject.AddComponent(); - _desktopCam = PlayerSetup.Instance.desktopCamera; - _cameraFovClone.targetCamera = _desktopCam.GetComponent(); + _desktopCam = PlayerSetup.Instance.desktopCamera.GetComponent(); + _cameraFovClone.targetCamera = _desktopCam; _ourCam.transform.SetParent(_desktopCam.transform); @@ -67,24 +67,24 @@ internal static class CameraLogic internal static void CopyFromPlayerCam() { Camera ourCamComponent = _ourCam.GetComponent(); - Camera playerCamComponent = _desktopCam.GetComponent(); + Camera playerCamComponent = PlayerSetup.Instance.GetActiveCamera().GetComponent(); if (ourCamComponent == null || playerCamComponent == null) return; ThirdPerson.Logger.Msg("Copying active camera settings & components."); - //steal basic settings + // Copy basic settings ourCamComponent.farClipPlane = playerCamComponent.farClipPlane; ourCamComponent.nearClipPlane = playerCamComponent.nearClipPlane; ourCamComponent.cullingMask = playerCamComponent.cullingMask; ourCamComponent.depthTextureMode = playerCamComponent.depthTextureMode; - //steal post processing if added + // Copy post processing if added PostProcessLayer ppLayerPlayerCam = playerCamComponent.GetComponent(); PostProcessLayer ppLayerThirdPerson = ourCamComponent.AddComponentIfMissing(); if (ppLayerPlayerCam != null && ppLayerThirdPerson != null) { ppLayerThirdPerson.enabled = ppLayerPlayerCam.enabled; ppLayerThirdPerson.volumeLayer = ppLayerPlayerCam.volumeLayer; - //need to copy these via reflection, otherwise post processing will error + // Copy these via reflection, otherwise post processing will error if (!_setupPostProcessing) { _setupPostProcessing = true; @@ -95,7 +95,7 @@ internal static class CameraLogic } } - //what even is this aura camera stuff + // Copy Aura camera settings AuraCamera auraPlayerCam = playerCamComponent.GetComponent(); AuraCamera auraThirdPerson = ourCamComponent.AddComponentIfMissing(); if (auraPlayerCam != null && auraThirdPerson != null) @@ -108,7 +108,7 @@ internal static class CameraLogic auraThirdPerson.enabled = false; } - //flare layer thing? the sun :_:_:_:_:_: + // Copy Flare layer settings FlareLayer flarePlayerCam = playerCamComponent.GetComponent(); FlareLayer flareThirdPerson = ourCamComponent.AddComponentIfMissing(); if (flarePlayerCam != null && flareThirdPerson != null) @@ -120,7 +120,7 @@ internal static class CameraLogic flareThirdPerson.enabled = false; } - //and now what the fuck is fog scattering + // Copy Azure Fog Scattering settings AzureFogScattering azureFogPlayerCam = playerCamComponent.GetComponent(); AzureFogScattering azureFogThirdPerson = ourCamComponent.AddComponentIfMissing(); if (azureFogPlayerCam != null && azureFogThirdPerson != null) @@ -132,7 +132,7 @@ internal static class CameraLogic Object.Destroy(ourCamComponent.GetComponent()); } - //why is there so many thingsssssssss + // Copy Beautify settings Beautify beautifyPlayerCam = playerCamComponent.GetComponent(); Beautify beautifyThirdPerson = ourCamComponent.AddComponentIfMissing(); if (beautifyPlayerCam != null && beautifyThirdPerson != null) diff --git a/ThirdPerson/format.json b/ThirdPerson/format.json index 3bdf445..556fcd8 100644 --- a/ThirdPerson/format.json +++ b/ThirdPerson/format.json @@ -7,7 +7,7 @@ "loaderversion": "0.5.7", "modtype": "Mod", "author": "Davi & NotAKidoS", - "description": "Allows you to go into third person view by pressing Ctrl + T to toggle and Ctrl + Y to change the mode", + "description": "Allows you to go into third person view by pressing Ctrl + T to toggle and Ctrl + Y to cycle modes.", "searchtags": [ "third person view", "3rd person", @@ -15,8 +15,8 @@ ], "requirements": [], "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r2/ThirdPerson.dll", - "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/", - "changelog": "- Made thirdperson Desktop only.\n- Copy postprocessing settings on world start.\n- Added CameraFovClone component to copy zoom from desktop camera.\n- Removed logic that disabled thirdperson when opening a menu, as Game UI renders on top anyways.", + "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/ThirdPerson", + "changelog": "- Made thirdperson Desktop only.\n- Copy postprocessing settings on world start.\n- Added CameraFovClone component to copy zoom from desktop camera.\n- Removed logic that disabled thirdperson when opening a menu, as Game UI renders on top anyways.\n- Prevent thirdperson zooming while in Menus or UnityExplorer.\n- Inverted thirdperson zoom direction when in Front View.", "embedcolor": "F61961" } ] \ No newline at end of file