diff --git a/ReModCE/Components/ThirdPersonComponent.cs b/ReModCE/Components/ThirdPersonComponent.cs index e4693d0..cb27ed8 100644 --- a/ReModCE/Components/ThirdPersonComponent.cs +++ b/ReModCE/Components/ThirdPersonComponent.cs @@ -4,6 +4,7 @@ using ReMod.Core.UI.QuickMenu; using ReModCE.Managers; using UnityEngine; +using CameraTakePhotoEnumerator = VRC.UserCamera.CameraUtil._TakeScreenShot_d__5; namespace ReModCE.Components { @@ -16,12 +17,12 @@ internal enum ThirdPersonMode internal class ThirdPersonComponent : ModComponent { - private Camera _cameraBack; - private Camera _cameraFront; + private static Camera _cameraBack; + private static Camera _cameraFront; private Camera _referenceCamera; private Camera _photoCamera; - private ThirdPersonMode _cameraSetup; + private static ThirdPersonMode _cameraSetup; private ConfigValue EnableThirdpersonHotkey; private ReMenuToggle _hotkeyToggle; @@ -42,6 +43,9 @@ public ThirdPersonComponent() SetThirdPersonMode(ThirdPersonMode.Off); } }; + + ReModCE.Harmony.Patch(typeof (CameraTakePhotoEnumerator).GetMethod("MoveNext"), + GetLocalPatch(nameof(CameraEnumeratorMoveNextPatch))); } public override void OnUiManagerInit(UiManager uiManager) @@ -158,5 +162,13 @@ public override void OnUpdate() HandleHotkeys(); HandleThirdperson(); } + + private static void CameraEnumeratorMoveNextPatch(ref CameraTakePhotoEnumerator __instance) + { + if(_cameraSetup == ThirdPersonMode.Off) + return; + + __instance.field_Public_Camera_0 = _cameraSetup == ThirdPersonMode.Back ? _cameraBack : _cameraFront; + } } } \ No newline at end of file