mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2026-06-24 07:18:28 +00:00
[NAK_CVR_Mods] Unfucked for 2026r182
This commit is contained in:
parent
c13dc8375a
commit
281403d68b
209 changed files with 3936 additions and 1122 deletions
119
.Deprecated/ThirdPerson/CameraLogic.cs
Normal file
119
.Deprecated/ThirdPerson/CameraLogic.cs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Core.Util.Object_Behaviour;
|
||||
using ABI_RC.Core;
|
||||
using ABI.CCK.Components;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.ThirdPerson;
|
||||
|
||||
internal static class CameraLogic
|
||||
{
|
||||
private static float _dist;
|
||||
private static float _scale = 1f;
|
||||
private static Camera _thirdPersonCam;
|
||||
private static Camera _desktopCam;
|
||||
private static int _storedCamMask;
|
||||
private static CameraFovClone _cameraFovClone;
|
||||
|
||||
internal static CameraLocation CurrentLocation = CameraLocation.Default;
|
||||
|
||||
internal enum CameraLocation
|
||||
{
|
||||
Default,
|
||||
FrontView,
|
||||
RightSide,
|
||||
LeftSide
|
||||
}
|
||||
|
||||
private static bool _state;
|
||||
internal static bool State
|
||||
{
|
||||
get => _state;
|
||||
set
|
||||
{
|
||||
if (_state == value) return;
|
||||
_state = !CheckIsRestricted() && value;
|
||||
|
||||
if (_state) _storedCamMask = _desktopCam.cullingMask;
|
||||
_desktopCam.cullingMask = _state ? 0 : _storedCamMask;
|
||||
_thirdPersonCam.gameObject.SetActive(_state);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetupCamera()
|
||||
{
|
||||
_thirdPersonCam = new GameObject("ThirdPersonCameraObj", typeof(Camera)).GetComponent<Camera>();
|
||||
|
||||
_cameraFovClone = _thirdPersonCam.gameObject.AddComponent<CameraFovClone>();
|
||||
|
||||
_desktopCam = PlayerSetup.Instance.desktopCam;
|
||||
_cameraFovClone.targetCamera = _desktopCam;
|
||||
|
||||
_thirdPersonCam.transform.SetParent(_desktopCam.transform);
|
||||
|
||||
RelocateCam(CameraLocation.Default);
|
||||
|
||||
_thirdPersonCam.gameObject.SetActive(false);
|
||||
|
||||
ThirdPerson.Logger.Msg("Finished setting up third person camera.");
|
||||
}
|
||||
|
||||
internal static void CopyPlayerCamValues()
|
||||
{
|
||||
Camera activePlayerCam = PlayerSetup.Instance.activeCam;
|
||||
if (!_thirdPersonCam || !activePlayerCam)
|
||||
return;
|
||||
|
||||
ThirdPerson.Logger.Msg("Copying active camera settings & components.");
|
||||
CVRTools.CopyToDestCam(activePlayerCam, _thirdPersonCam);
|
||||
|
||||
// Remove PlayerClone
|
||||
// _thirdPersonCam.cullingMask &= ~(1 << CVRLayers.PlayerClone);
|
||||
|
||||
if (!CheckIsRestricted())
|
||||
return;
|
||||
|
||||
ThirdPerson.Logger.Msg("Third person camera is restricted by the world.");
|
||||
State = false;
|
||||
}
|
||||
|
||||
internal static void RelocateCam(CameraLocation location, bool resetDist = false)
|
||||
{
|
||||
Transform thirdPersonCam = _thirdPersonCam.transform;
|
||||
thirdPersonCam.rotation = _desktopCam.transform.rotation;
|
||||
if (resetDist) ResetDist();
|
||||
switch (location)
|
||||
{
|
||||
case CameraLocation.FrontView:
|
||||
thirdPersonCam.localPosition = new Vector3(0, 0.015f, 1f - _dist) * _scale;
|
||||
thirdPersonCam.localRotation = new Quaternion(0, 180, 0, 0);
|
||||
CurrentLocation = CameraLocation.FrontView;
|
||||
break;
|
||||
case CameraLocation.RightSide:
|
||||
thirdPersonCam.localPosition = new Vector3(0.3f, 0.015f, -1.5f + _dist) * _scale;
|
||||
thirdPersonCam.localRotation = new Quaternion(0, 0, 0, 0);
|
||||
CurrentLocation = CameraLocation.RightSide;
|
||||
break;
|
||||
case CameraLocation.LeftSide:
|
||||
thirdPersonCam.localPosition = new Vector3(-0.3f, 0.015f, -1.5f + _dist) * _scale;
|
||||
thirdPersonCam.localRotation = new Quaternion(0, 0, 0, 0);
|
||||
CurrentLocation = CameraLocation.LeftSide;
|
||||
break;
|
||||
case CameraLocation.Default:
|
||||
default:
|
||||
thirdPersonCam.localPosition = new Vector3(0, 0.015f, -1.5f + _dist) * _scale;
|
||||
thirdPersonCam.localRotation = new Quaternion(0, 0, 0, 0);
|
||||
CurrentLocation = CameraLocation.Default;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ResetDist() => _dist = 0;
|
||||
internal static void ScrollDist(float sign) { _dist += sign * 0.25f; RelocateCam(CurrentLocation); }
|
||||
internal static void AdjustScale(float avatarScaleRelation) { _scale = avatarScaleRelation; RelocateCam(CurrentLocation); }
|
||||
internal static void CheckVRMode() { if (MetaPort.Instance.isUsingVr) State = false; }
|
||||
|
||||
private static bool CheckIsRestricted()
|
||||
=> CVRWorld.Instance && !CVRWorld.Instance.enableZoom;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue