diff --git a/ThirdPerson/CameraLogic.cs b/ThirdPerson/CameraLogic.cs index 9e34d68..b1264e0 100644 --- a/ThirdPerson/CameraLogic.cs +++ b/ThirdPerson/CameraLogic.cs @@ -17,6 +17,7 @@ internal static class CameraLogic private static float _scale = 1f; private static Camera _ourCam; private static Camera _desktopCam; + private static int _desktopCamMask; private static CameraFovClone _cameraFovClone; internal static CameraLocation CurrentLocation = CameraLocation.Default; @@ -36,14 +37,14 @@ internal static class CameraLogic set { _state = value; - _desktopCam.enabled = !_state; + _desktopCam.cullingMask = _state ? 0 : _desktopCamMask; _ourCam.gameObject.SetActive(_state); } } - private static bool _setupPostProcessing; - private static readonly FieldInfo _ppResourcesFieldInfo = typeof(PostProcessLayer).GetField("m_Resources", BindingFlags.NonPublic | BindingFlags.Instance); - private static readonly FieldInfo _ppOldResourcesFieldInfo = typeof(PostProcessLayer).GetField("m_OldResources", BindingFlags.NonPublic | BindingFlags.Instance); + static bool _setupPostProcessing; + static readonly FieldInfo _ppResourcesFieldInfo = typeof(PostProcessLayer).GetField("m_Resources", BindingFlags.NonPublic | BindingFlags.Instance); + static readonly FieldInfo _ppOldResourcesFieldInfo = typeof(PostProcessLayer).GetField("m_OldResources", BindingFlags.NonPublic | BindingFlags.Instance); internal static IEnumerator SetupCamera() { @@ -54,6 +55,7 @@ internal static class CameraLogic _cameraFovClone = _ourCam.gameObject.AddComponent(); _desktopCam = PlayerSetup.Instance.desktopCamera.GetComponent(); + _desktopCamMask = _desktopCam.cullingMask; _cameraFovClone.targetCamera = _desktopCam; _ourCam.transform.SetParent(_desktopCam.transform); @@ -178,7 +180,6 @@ internal static class CameraLogic } private static void ResetDist() => _dist = 0; - internal static void IncrementDist() { _dist += 0.25f; RelocateCam(CurrentLocation); } - internal static void DecrementDist() { _dist -= 0.25f; RelocateCam(CurrentLocation); } + internal static void ScrollDist(float sign) { _dist += sign * 0.25f; RelocateCam(CurrentLocation); } internal static void AdjustScale(float height) { _scale = height; RelocateCam(CurrentLocation); } } diff --git a/ThirdPerson/Patches.cs b/ThirdPerson/Patches.cs index 3ee2ffd..e80c204 100644 --- a/ThirdPerson/Patches.cs +++ b/ThirdPerson/Patches.cs @@ -1,9 +1,7 @@ using ABI.CCK.Components; using ABI_RC.Core.Player; -using ABI_RC.Core.Util.Object_Behaviour; using MelonLoader; using System.Reflection; -using UnityEngine; using static NAK.ThirdPerson.CameraLogic; namespace NAK.ThirdPerson; @@ -24,16 +22,10 @@ internal static class Patches typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupIKScaling), BindingFlags.NonPublic | BindingFlags.Instance), postfix: typeof(Patches).GetMethod(nameof(OnScaleAdjusted), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod() ); - harmony.Patch( - typeof(CameraFacingObject).GetMethod(nameof(CameraFacingObject.Start), BindingFlags.NonPublic | BindingFlags.Instance), - postfix: typeof(Patches).GetMethod(nameof(OnCameraFacingObjectStart), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod() - ); } //Copy camera settings & postprocessing components private static void OnWorldStart() => CopyPlayerCamValues(); //Adjust camera distance with height as modifier private static void OnScaleAdjusted(float height) => AdjustScale(height); - //Fix bug when in thirdperson and desktop camera is disabled for performance - private static void OnCameraFacingObjectStart(ref Camera ___m_Camera) { if (___m_Camera == null) ___m_Camera = PlayerSetup.Instance.GetActiveCamera().GetComponent(); } } \ No newline at end of file diff --git a/ThirdPerson/Properties/AssemblyInfo.cs b/ThirdPerson/Properties/AssemblyInfo.cs index e6738da..4c3bd0f 100644 --- a/ThirdPerson/Properties/AssemblyInfo.cs +++ b/ThirdPerson/Properties/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Reflection; [assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] [assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] -[assembly: MelonColor(ConsoleColor.DarkMagenta)] +[assembly: MelonColor(255, 139, 0, 139)] namespace NAK.ThirdPerson.Properties; internal static class AssemblyInfoParams diff --git a/ThirdPerson/ThirdPerson.cs b/ThirdPerson/ThirdPerson.cs index 6617de3..fb4a480 100644 --- a/ThirdPerson/ThirdPerson.cs +++ b/ThirdPerson/ThirdPerson.cs @@ -1,5 +1,4 @@ using MelonLoader; -using System.Reflection; using UnityEngine; using static NAK.ThirdPerson.CameraLogic; @@ -22,8 +21,8 @@ public class ThirdPerson : MelonMod // Prevents scrolling while in Menus or UnityExplorer if (State && Cursor.lockState == CursorLockMode.Locked) { - if (Input.GetAxis("Mouse ScrollWheel") > 0f) IncrementDist(); - else if (Input.GetAxis("Mouse ScrollWheel") < 0f) DecrementDist(); + float scroll = Input.GetAxis("Mouse ScrollWheel"); + if (scroll != 0f) ScrollDist(Mathf.Sign(scroll)); } if (!Input.GetKey(KeyCode.LeftControl)) return;