From 0d4e6e6331614d94b3e8e4503b722418d1ef748e Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:30:46 -0600 Subject: [PATCH] [ThirdPerson] Fixes for r173 --- ThirdPerson/CameraLogic.cs | 99 +------------------------- ThirdPerson/Patches.cs | 2 - ThirdPerson/Properties/AssemblyInfo.cs | 2 +- ThirdPerson/format.json | 8 +-- 4 files changed, 8 insertions(+), 103 deletions(-) diff --git a/ThirdPerson/CameraLogic.cs b/ThirdPerson/CameraLogic.cs index 314755b..4a832c7 100644 --- a/ThirdPerson/CameraLogic.cs +++ b/ThirdPerson/CameraLogic.cs @@ -6,6 +6,7 @@ using Aura2API; using BeautifyEffect; using System.Collections; using System.Reflection; +using ABI_RC.Core; using UnityEngine; using UnityEngine.AzureSky; using UnityEngine.Rendering.PostProcessing; @@ -68,110 +69,16 @@ internal static class CameraLogic ThirdPerson.Logger.Msg("Finished setting up third person camera."); } - internal static void ResetPlayerCamValues() - { - Camera activePlayerCam = PlayerSetup.Instance.GetActiveCamera().GetComponent(); - if (activePlayerCam == null) - return; - - ThirdPerson.Logger.Msg("Resetting active camera culling mask."); - - // CopyRefCamValues does not reset to default before copying! Game issue, SetDefaultCamValues is fine. - activePlayerCam.cullingMask = MetaPort.Instance.defaultCameraMask; - } - internal static void CopyPlayerCamValues() { - Camera ourCamComponent = _thirdpersonCam.GetComponent(); + Camera ourCamComponent = _thirdpersonCam; Camera activePlayerCam = PlayerSetup.Instance.GetActiveCamera().GetComponent(); if (ourCamComponent == null || activePlayerCam == null) return; ThirdPerson.Logger.Msg("Copying active camera settings & components."); - // Copy basic settings - ourCamComponent.farClipPlane = activePlayerCam.farClipPlane; - ourCamComponent.nearClipPlane = activePlayerCam.nearClipPlane; - ourCamComponent.depthTextureMode = activePlayerCam.depthTextureMode; - - // Copy and store the active camera mask - var cullingMask= _storedCamMask = activePlayerCam.cullingMask; - cullingMask &= -32769; - cullingMask |= 256; - cullingMask |= 512; - cullingMask |= 32; - cullingMask &= -4097; - cullingMask |= 1024; - cullingMask |= 8192; - ourCamComponent.cullingMask = cullingMask; - - // Copy post processing if added - PostProcessLayer ppLayerPlayerCam = activePlayerCam.GetComponent(); - PostProcessLayer ppLayerThirdPerson = ourCamComponent.AddComponentIfMissing(); - if (ppLayerPlayerCam != null && ppLayerThirdPerson != null) - { - ppLayerThirdPerson.enabled = ppLayerPlayerCam.enabled; - ppLayerThirdPerson.volumeLayer = ppLayerPlayerCam.volumeLayer; - // Copy these via reflection, otherwise post processing will error - if (!_setupPostProcessing) - { - _setupPostProcessing = true; - PostProcessResources resources = (PostProcessResources)_ppResourcesFieldInfo.GetValue(ppLayerPlayerCam); - PostProcessResources oldResources = (PostProcessResources)_ppOldResourcesFieldInfo.GetValue(ppLayerPlayerCam); - _ppResourcesFieldInfo.SetValue(ppLayerThirdPerson, resources); - _ppResourcesFieldInfo.SetValue(ppLayerThirdPerson, oldResources); - } - } - - // Copy Aura camera settings - AuraCamera auraPlayerCam = activePlayerCam.GetComponent(); - AuraCamera auraThirdPerson = ourCamComponent.AddComponentIfMissing(); - if (auraPlayerCam != null && auraThirdPerson != null) - { - auraThirdPerson.enabled = auraPlayerCam.enabled; - auraThirdPerson.frustumSettings = auraPlayerCam.frustumSettings; - } - else - { - auraThirdPerson.enabled = false; - } - - // Copy Flare layer settings - FlareLayer flarePlayerCam = activePlayerCam.GetComponent(); - FlareLayer flareThirdPerson = ourCamComponent.AddComponentIfMissing(); - if (flarePlayerCam != null && flareThirdPerson != null) - { - flareThirdPerson.enabled = flarePlayerCam.enabled; - } - else - { - flareThirdPerson.enabled = false; - } - - // Copy Azure Fog Scattering settings - AzureFogScattering azureFogPlayerCam = activePlayerCam.GetComponent(); - AzureFogScattering azureFogThirdPerson = ourCamComponent.AddComponentIfMissing(); - if (azureFogPlayerCam != null && azureFogThirdPerson != null) - { - azureFogThirdPerson.fogScatteringMaterial = azureFogPlayerCam.fogScatteringMaterial; - } - else - { - UnityEngine.Object.Destroy(ourCamComponent.GetComponent()); - } - - // Copy Beautify settings - Beautify beautifyPlayerCam = activePlayerCam.GetComponent(); - Beautify beautifyThirdPerson = ourCamComponent.AddComponentIfMissing(); - if (beautifyPlayerCam != null && beautifyThirdPerson != null) - { - beautifyThirdPerson.quality = beautifyPlayerCam.quality; - beautifyThirdPerson.profile = beautifyPlayerCam.profile; - } - else - { - UnityEngine.Object.Destroy(ourCamComponent.gameObject.GetComponent()); - } + CVRTools.CopyToDestCam(_thirdpersonCam, activePlayerCam); } internal static void RelocateCam(CameraLocation location, bool resetDist = false) diff --git a/ThirdPerson/Patches.cs b/ThirdPerson/Patches.cs index 1df9dd6..131b45b 100644 --- a/ThirdPerson/Patches.cs +++ b/ThirdPerson/Patches.cs @@ -17,7 +17,6 @@ internal static class Patches ); harmony.Patch( typeof(CVRWorld).GetMethod(nameof(CVRWorld.CopyRefCamValues), BindingFlags.NonPublic | BindingFlags.Instance), - prefix: typeof(Patches).GetMethod(nameof(OnPreWorldStart), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod(), postfix: typeof(Patches).GetMethod(nameof(OnPostWorldStart), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod() ); harmony.Patch( @@ -31,7 +30,6 @@ internal static class Patches } //Copy camera settings & postprocessing components - private static void OnPreWorldStart() => ResetPlayerCamValues(); private static void OnPostWorldStart() => CopyPlayerCamValues(); //Adjust camera distance with height as modifier private static void OnScaleAdjusted(float height) => AdjustScale(height); diff --git a/ThirdPerson/Properties/AssemblyInfo.cs b/ThirdPerson/Properties/AssemblyInfo.cs index dcd28b7..6cc4bae 100644 --- a/ThirdPerson/Properties/AssemblyInfo.cs +++ b/ThirdPerson/Properties/AssemblyInfo.cs @@ -27,6 +27,6 @@ using System.Reflection; namespace NAK.ThirdPerson.Properties; internal static class AssemblyInfoParams { - public const string Version = "1.0.5"; + public const string Version = "1.0.6"; public const string Author = "Davi & NotAKidoS"; } \ No newline at end of file diff --git a/ThirdPerson/format.json b/ThirdPerson/format.json index b89e6b6..255e9c8 100644 --- a/ThirdPerson/format.json +++ b/ThirdPerson/format.json @@ -2,8 +2,8 @@ { "_id": 16, "name": "ThirdPerson", - "modversion": "1.0.5", - "gameversion": "2023r171", + "modversion": "1.0.6", + "gameversion": "2023r173", "loaderversion": "0.6.1", "modtype": "Mod", "author": "Davi & NotAKidoS", @@ -14,9 +14,9 @@ "third person" ], "requirements": [], - "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r16/ThirdPerson.dll", + "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r22/ThirdPerson.dll", "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/ThirdPerson", - "changelog": "- Fixed game issue where player camera culling mask was not being first reset when loading into a world with a custom reference camera specified.\n- Fixed not updating stored culling mask on world join or ThirdPerson toggle.\n\nThese changes should fix the Portable Camera not displaying anything once loading into a world while in Third Person.", + "changelog": "- Fixed not updating stored culling mask on world join or ThirdPerson toggle.\n- Switched to using CVRTools.CopyToDestCam when copying camera settings.", "embedcolor": "#F61961" } ] \ No newline at end of file