mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
[ThirdPerson] BetterShadowClone support
This commit is contained in:
parent
5ee7dca50b
commit
1de39260f4
6 changed files with 66 additions and 16 deletions
|
@ -12,7 +12,8 @@ internal static class CameraLogic
|
|||
{
|
||||
private static float _dist;
|
||||
private static float _scale = 1f;
|
||||
private static Camera _thirdpersonCam;
|
||||
private static Camera _thirdPersonCam;
|
||||
private static Camera _uiCam;
|
||||
private static Camera _desktopCam;
|
||||
private static int _storedCamMask;
|
||||
private static CameraFovClone _cameraFovClone;
|
||||
|
@ -36,38 +37,40 @@ internal static class CameraLogic
|
|||
_state = !CheckIsRestricted() && value;
|
||||
if (_state) _storedCamMask = _desktopCam.cullingMask;
|
||||
_desktopCam.cullingMask = _state ? 0 : _storedCamMask;
|
||||
_thirdpersonCam.gameObject.SetActive(_state);
|
||||
_uiCam.cullingMask = _state ? _uiCam.cullingMask & ~(1 << CVRLayers.PlayerClone) : _uiCam.cullingMask | (1 << CVRLayers.PlayerClone);
|
||||
_thirdPersonCam.gameObject.SetActive(_state);
|
||||
}
|
||||
}
|
||||
|
||||
internal static IEnumerator SetupCamera()
|
||||
{
|
||||
yield return new WaitUntil(() => PlayerSetup.Instance);
|
||||
|
||||
_thirdpersonCam = new GameObject("ThirdPersonCameraObj", typeof(Camera)).GetComponent<Camera>();
|
||||
|
||||
_cameraFovClone = _thirdpersonCam.gameObject.AddComponent<CameraFovClone>();
|
||||
|
||||
_thirdPersonCam = new GameObject("ThirdPersonCameraObj", typeof(Camera)).GetComponent<Camera>();
|
||||
|
||||
_cameraFovClone = _thirdPersonCam.gameObject.AddComponent<CameraFovClone>();
|
||||
|
||||
_desktopCam = PlayerSetup.Instance.desktopCamera.GetComponent<Camera>();
|
||||
_cameraFovClone.targetCamera = _desktopCam;
|
||||
|
||||
_thirdpersonCam.transform.SetParent(_desktopCam.transform);
|
||||
_thirdPersonCam.transform.SetParent(_desktopCam.transform);
|
||||
_uiCam = _desktopCam.transform.Find("_UICamera").GetComponent<Camera>();
|
||||
|
||||
RelocateCam(CameraLocation.Default);
|
||||
|
||||
_thirdpersonCam.gameObject.SetActive(false);
|
||||
|
||||
_thirdPersonCam.gameObject.SetActive(false);
|
||||
|
||||
ThirdPerson.Logger.Msg("Finished setting up third person camera.");
|
||||
}
|
||||
|
||||
internal static void CopyPlayerCamValues()
|
||||
{
|
||||
Camera activePlayerCam = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
||||
if (_thirdpersonCam == null || activePlayerCam == null)
|
||||
if (_thirdPersonCam == null || activePlayerCam == null)
|
||||
return;
|
||||
|
||||
ThirdPerson.Logger.Msg("Copying active camera settings & components.");
|
||||
CVRTools.CopyToDestCam(activePlayerCam, _thirdpersonCam);
|
||||
CVRTools.CopyToDestCam(activePlayerCam, _thirdPersonCam);
|
||||
|
||||
if (!CheckIsRestricted())
|
||||
return;
|
||||
|
@ -78,7 +81,7 @@ internal static class CameraLogic
|
|||
|
||||
internal static void RelocateCam(CameraLocation location, bool resetDist = false)
|
||||
{
|
||||
Transform thirdPersonCam = _thirdpersonCam.transform;
|
||||
Transform thirdPersonCam = _thirdPersonCam.transform;
|
||||
thirdPersonCam.rotation = _desktopCam.transform.rotation;
|
||||
if (resetDist) ResetDist();
|
||||
switch (location)
|
||||
|
@ -106,12 +109,19 @@ internal static class CameraLogic
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void ResetDist() => _dist = 0;
|
||||
internal static void ScrollDist(float sign) { _dist += sign * 0.25f; RelocateCam(CurrentLocation); }
|
||||
internal static void AdjustScale(float height) { _scale = height; RelocateCam(CurrentLocation); }
|
||||
internal static void CheckVRMode() { if (MetaPort.Instance.isUsingVr) State = false; }
|
||||
private static bool CheckIsRestricted()
|
||||
=> !CVRWorld.Instance.enableZoom;
|
||||
|
||||
internal static bool ShouldNotHideHead_ThirdPerson(Camera cam)
|
||||
{
|
||||
if (cam != _desktopCam)
|
||||
return true; // we dont care
|
||||
|
||||
return !State;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue