From c42e28f340b45947b66a1e62355d6601da667c5f Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:36:15 -0500 Subject: [PATCH] overcomplicate --- ThirdPerson/CameraLogic.cs | 2 +- ThirdPerson/Patches.cs | 9 +++++++++ ThirdPerson/ThirdPerson.cs | 3 +-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ThirdPerson/CameraLogic.cs b/ThirdPerson/CameraLogic.cs index 1c943e7..85836c2 100644 --- a/ThirdPerson/CameraLogic.cs +++ b/ThirdPerson/CameraLogic.cs @@ -175,7 +175,7 @@ internal static class CameraLogic CurrentLocation = CameraLocation.Default; break; } - } + } private static void ResetDist() => _dist = 0; internal static void IncrementDist() { _dist += 0.25f; RelocateCam(CurrentLocation); } diff --git a/ThirdPerson/Patches.cs b/ThirdPerson/Patches.cs index 3a72a2d..3ee2ffd 100644 --- a/ThirdPerson/Patches.cs +++ b/ThirdPerson/Patches.cs @@ -1,7 +1,9 @@ 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; @@ -22,9 +24,16 @@ 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/ThirdPerson.cs b/ThirdPerson/ThirdPerson.cs index 09e9774..a2d917d 100644 --- a/ThirdPerson/ThirdPerson.cs +++ b/ThirdPerson/ThirdPerson.cs @@ -44,7 +44,6 @@ public class ThirdPerson : MelonMod if (!Input.GetKey(KeyCode.LeftControl)) return; if (Input.GetKeyDown(KeyCode.T)) State = !State; if (!State || !Input.GetKeyDown(KeyCode.Y)) return; - int cycle = Input.GetKeyDown(KeyCode.LeftShift) ? -1 : 1; - RelocateCam((CameraLocation)(((int)CurrentLocation + cycle) % Enum.GetValues(typeof(CameraLocation)).Length), true); + RelocateCam((CameraLocation)(((int)CurrentLocation + (Input.GetKey(KeyCode.LeftShift) ? -1 : 1) + Enum.GetValues(typeof(CameraLocation)).Length) % Enum.GetValues(typeof(CameraLocation)).Length), true); } } \ No newline at end of file