mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
added scale modifier
ThirdPerson distance now uses avatar height as modifier, so you keep the same distance across avatars & while scaling.
This commit is contained in:
parent
5c0e8a2ff4
commit
0dae699932
2 changed files with 16 additions and 8 deletions
|
@ -14,6 +14,7 @@ namespace NAK.ThirdPerson;
|
||||||
internal static class CameraLogic
|
internal static class CameraLogic
|
||||||
{
|
{
|
||||||
private static float _dist;
|
private static float _dist;
|
||||||
|
private static float _scale = 1f;
|
||||||
private static Camera _ourCam;
|
private static Camera _ourCam;
|
||||||
private static Camera _desktopCam;
|
private static Camera _desktopCam;
|
||||||
private static CameraFovClone _cameraFovClone;
|
private static CameraFovClone _cameraFovClone;
|
||||||
|
@ -64,7 +65,7 @@ internal static class CameraLogic
|
||||||
ThirdPerson.Logger.Msg("Finished setting up third person camera.");
|
ThirdPerson.Logger.Msg("Finished setting up third person camera.");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void CopyFromPlayerCam()
|
internal static void CopyPlayerCamValues()
|
||||||
{
|
{
|
||||||
Camera ourCamComponent = _ourCam.GetComponent<Camera>();
|
Camera ourCamComponent = _ourCam.GetComponent<Camera>();
|
||||||
Camera playerCamComponent = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
Camera playerCamComponent = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
||||||
|
@ -153,23 +154,23 @@ internal static class CameraLogic
|
||||||
switch (location)
|
switch (location)
|
||||||
{
|
{
|
||||||
case CameraLocation.FrontView:
|
case CameraLocation.FrontView:
|
||||||
_ourCam.transform.localPosition = new Vector3(0, 0.015f, 0.55f - _dist);
|
_ourCam.transform.localPosition = new Vector3(0, 0.015f, 0.55f - _dist) * _scale;
|
||||||
_ourCam.transform.localRotation = new Quaternion(0, 180, 0, 0);
|
_ourCam.transform.localRotation = new Quaternion(0, 180, 0, 0);
|
||||||
CurrentLocation = CameraLocation.FrontView;
|
CurrentLocation = CameraLocation.FrontView;
|
||||||
break;
|
break;
|
||||||
case CameraLocation.RightSide:
|
case CameraLocation.RightSide:
|
||||||
_ourCam.transform.localPosition = new Vector3(0.3f, 0.015f, -0.55f + _dist);
|
_ourCam.transform.localPosition = new Vector3(0.3f, 0.015f, -0.55f + _dist) * _scale;
|
||||||
_ourCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
_ourCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
||||||
CurrentLocation = CameraLocation.RightSide;
|
CurrentLocation = CameraLocation.RightSide;
|
||||||
break;
|
break;
|
||||||
case CameraLocation.LeftSide:
|
case CameraLocation.LeftSide:
|
||||||
_ourCam.transform.localPosition = new Vector3(-0.3f, 0.015f, -0.55f + _dist);
|
_ourCam.transform.localPosition = new Vector3(-0.3f, 0.015f, -0.55f + _dist) * _scale;
|
||||||
_ourCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
_ourCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
||||||
CurrentLocation = CameraLocation.LeftSide;
|
CurrentLocation = CameraLocation.LeftSide;
|
||||||
break;
|
break;
|
||||||
case CameraLocation.Default:
|
case CameraLocation.Default:
|
||||||
default:
|
default:
|
||||||
_ourCam.transform.localPosition = new Vector3(0, 0.015f, -0.55f + _dist);
|
_ourCam.transform.localPosition = new Vector3(0, 0.015f, -0.88f + _dist) * _scale;
|
||||||
_ourCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
_ourCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
||||||
CurrentLocation = CameraLocation.Default;
|
CurrentLocation = CameraLocation.Default;
|
||||||
break;
|
break;
|
||||||
|
@ -179,4 +180,5 @@ internal static class CameraLogic
|
||||||
private static void ResetDist() => _dist = 0;
|
private static void ResetDist() => _dist = 0;
|
||||||
internal static void IncrementDist() { _dist += 0.25f; RelocateCam(CurrentLocation); }
|
internal static void IncrementDist() { _dist += 0.25f; RelocateCam(CurrentLocation); }
|
||||||
internal static void DecrementDist() { _dist -= 0.25f; RelocateCam(CurrentLocation); }
|
internal static void DecrementDist() { _dist -= 0.25f; RelocateCam(CurrentLocation); }
|
||||||
|
internal static void AdjustScale(float height) { _scale = height; RelocateCam(CurrentLocation); }
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using ABI.CCK.Components;
|
using ABI.CCK.Components;
|
||||||
|
using ABI_RC.Core.Player;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using static NAK.ThirdPerson.CameraLogic;
|
using static NAK.ThirdPerson.CameraLogic;
|
||||||
|
@ -10,15 +11,20 @@ internal static class Patches
|
||||||
internal static void Apply(HarmonyLib.Harmony harmony)
|
internal static void Apply(HarmonyLib.Harmony harmony)
|
||||||
{
|
{
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
typeof(CVRWorld).GetMethod("SetDefaultCamValues", BindingFlags.NonPublic | BindingFlags.Instance),
|
typeof(CVRWorld).GetMethod(nameof(CVRWorld.SetDefaultCamValues), BindingFlags.NonPublic | BindingFlags.Instance),
|
||||||
postfix: typeof(Patches).GetMethod(nameof(OnWorldStart), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod()
|
postfix: typeof(Patches).GetMethod(nameof(OnWorldStart), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod()
|
||||||
);
|
);
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
typeof(CVRWorld).GetMethod("CopyRefCamValues", BindingFlags.NonPublic | BindingFlags.Instance),
|
typeof(CVRWorld).GetMethod(nameof(CVRWorld.CopyRefCamValues), BindingFlags.NonPublic | BindingFlags.Instance),
|
||||||
postfix: typeof(Patches).GetMethod(nameof(OnWorldStart), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod()
|
postfix: typeof(Patches).GetMethod(nameof(OnWorldStart), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod()
|
||||||
);
|
);
|
||||||
|
harmony.Patch(
|
||||||
|
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupIKScaling), BindingFlags.NonPublic | BindingFlags.Instance),
|
||||||
|
postfix: typeof(Patches).GetMethod(nameof(OnScaleAdjusted), BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Copy camera settings & postprocessing components
|
//Copy camera settings & postprocessing components
|
||||||
private static void OnWorldStart() => CopyFromPlayerCam();
|
private static void OnWorldStart() => CopyPlayerCamValues();
|
||||||
|
private static void OnScaleAdjusted(float height) => AdjustScale(height);
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue