mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
[ThirdPerson] Added restriction when world has Zoom disabled.
This commit is contained in:
parent
3482826441
commit
374ab6c11e
3 changed files with 28 additions and 30 deletions
|
@ -1,15 +1,10 @@
|
||||||
using ABI_RC.Core.Base;
|
using ABI_RC.Core.Player;
|
||||||
using ABI_RC.Core.Player;
|
|
||||||
using ABI_RC.Core.Savior;
|
using ABI_RC.Core.Savior;
|
||||||
using ABI_RC.Core.Util.Object_Behaviour;
|
using ABI_RC.Core.Util.Object_Behaviour;
|
||||||
using Aura2API;
|
|
||||||
using BeautifyEffect;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Reflection;
|
|
||||||
using ABI_RC.Core;
|
using ABI_RC.Core;
|
||||||
|
using ABI.CCK.Components;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AzureSky;
|
|
||||||
using UnityEngine.Rendering.PostProcessing;
|
|
||||||
|
|
||||||
namespace NAK.ThirdPerson;
|
namespace NAK.ThirdPerson;
|
||||||
|
|
||||||
|
@ -38,17 +33,13 @@ internal static class CameraLogic
|
||||||
get => _state;
|
get => _state;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_state = value;
|
_state = !CheckIsRestricted() && value;
|
||||||
if (_state) _storedCamMask = _desktopCam.cullingMask;
|
if (_state) _storedCamMask = _desktopCam.cullingMask;
|
||||||
_desktopCam.cullingMask = _state ? 0 : _storedCamMask;
|
_desktopCam.cullingMask = _state ? 0 : _storedCamMask;
|
||||||
_thirdpersonCam.gameObject.SetActive(_state);
|
_thirdpersonCam.gameObject.SetActive(_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool _setupPostProcessing;
|
|
||||||
private static readonly FieldInfo _ppResourcesFieldInfo = typeof(PostProcessLayer).GetField("m_Resources", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
private static readonly FieldInfo _ppOldResourcesFieldInfo = typeof(PostProcessLayer).GetField("m_OldResources", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
|
|
||||||
internal static IEnumerator SetupCamera()
|
internal static IEnumerator SetupCamera()
|
||||||
{
|
{
|
||||||
yield return new WaitUntil(() => PlayerSetup.Instance);
|
yield return new WaitUntil(() => PlayerSetup.Instance);
|
||||||
|
@ -71,41 +62,46 @@ internal static class CameraLogic
|
||||||
|
|
||||||
internal static void CopyPlayerCamValues()
|
internal static void CopyPlayerCamValues()
|
||||||
{
|
{
|
||||||
Camera ourCamComponent = _thirdpersonCam;
|
|
||||||
Camera activePlayerCam = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
Camera activePlayerCam = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
||||||
if (ourCamComponent == null || activePlayerCam == null)
|
if (_thirdpersonCam == null || activePlayerCam == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ThirdPerson.Logger.Msg("Copying active camera settings & components.");
|
ThirdPerson.Logger.Msg("Copying active camera settings & components.");
|
||||||
|
CVRTools.CopyToDestCam(activePlayerCam, _thirdpersonCam);
|
||||||
|
|
||||||
|
if (!CheckIsRestricted())
|
||||||
|
return;
|
||||||
|
|
||||||
CVRTools.CopyToDestCam(_thirdpersonCam, activePlayerCam);
|
ThirdPerson.Logger.Msg("Third person camera is restricted by the world.");
|
||||||
|
State = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void RelocateCam(CameraLocation location, bool resetDist = false)
|
internal static void RelocateCam(CameraLocation location, bool resetDist = false)
|
||||||
{
|
{
|
||||||
_thirdpersonCam.transform.rotation = _desktopCam.transform.rotation;
|
Transform thirdPersonCam = _thirdpersonCam.transform;
|
||||||
|
thirdPersonCam.rotation = _desktopCam.transform.rotation;
|
||||||
if (resetDist) ResetDist();
|
if (resetDist) ResetDist();
|
||||||
switch (location)
|
switch (location)
|
||||||
{
|
{
|
||||||
case CameraLocation.FrontView:
|
case CameraLocation.FrontView:
|
||||||
_thirdpersonCam.transform.localPosition = new Vector3(0, 0.015f, 1f - _dist) * _scale;
|
thirdPersonCam.localPosition = new Vector3(0, 0.015f, 1f - _dist) * _scale;
|
||||||
_thirdpersonCam.transform.localRotation = new Quaternion(0, 180, 0, 0);
|
thirdPersonCam.localRotation = new Quaternion(0, 180, 0, 0);
|
||||||
CurrentLocation = CameraLocation.FrontView;
|
CurrentLocation = CameraLocation.FrontView;
|
||||||
break;
|
break;
|
||||||
case CameraLocation.RightSide:
|
case CameraLocation.RightSide:
|
||||||
_thirdpersonCam.transform.localPosition = new Vector3(0.3f, 0.015f, -1.5f + _dist) * _scale;
|
thirdPersonCam.localPosition = new Vector3(0.3f, 0.015f, -1.5f + _dist) * _scale;
|
||||||
_thirdpersonCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
thirdPersonCam.localRotation = new Quaternion(0, 0, 0, 0);
|
||||||
CurrentLocation = CameraLocation.RightSide;
|
CurrentLocation = CameraLocation.RightSide;
|
||||||
break;
|
break;
|
||||||
case CameraLocation.LeftSide:
|
case CameraLocation.LeftSide:
|
||||||
_thirdpersonCam.transform.localPosition = new Vector3(-0.3f, 0.015f, -1.5f + _dist) * _scale;
|
thirdPersonCam.localPosition = new Vector3(-0.3f, 0.015f, -1.5f + _dist) * _scale;
|
||||||
_thirdpersonCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
thirdPersonCam.localRotation = new Quaternion(0, 0, 0, 0);
|
||||||
CurrentLocation = CameraLocation.LeftSide;
|
CurrentLocation = CameraLocation.LeftSide;
|
||||||
break;
|
break;
|
||||||
case CameraLocation.Default:
|
case CameraLocation.Default:
|
||||||
default:
|
default:
|
||||||
_thirdpersonCam.transform.localPosition = new Vector3(0, 0.015f, -1.5f + _dist) * _scale;
|
thirdPersonCam.localPosition = new Vector3(0, 0.015f, -1.5f + _dist) * _scale;
|
||||||
_thirdpersonCam.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
thirdPersonCam.localRotation = new Quaternion(0, 0, 0, 0);
|
||||||
CurrentLocation = CameraLocation.Default;
|
CurrentLocation = CameraLocation.Default;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -116,4 +112,6 @@ internal static class CameraLogic
|
||||||
internal static void ScrollDist(float sign) { _dist += sign * 0.25f; RelocateCam(CurrentLocation); }
|
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 AdjustScale(float height) { _scale = height; RelocateCam(CurrentLocation); }
|
||||||
internal static void CheckVRMode() { if (MetaPort.Instance.isUsingVr) State = false; }
|
internal static void CheckVRMode() { if (MetaPort.Instance.isUsingVr) State = false; }
|
||||||
}
|
private static bool CheckIsRestricted()
|
||||||
|
=> !CVRWorld.Instance.enableZoom;
|
||||||
|
}
|
|
@ -27,6 +27,6 @@ using System.Reflection;
|
||||||
namespace NAK.ThirdPerson.Properties;
|
namespace NAK.ThirdPerson.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "1.0.6";
|
public const string Version = "1.0.7";
|
||||||
public const string Author = "Davi & NotAKidoS";
|
public const string Author = "Davi & NotAKidoS";
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
"_id": 16,
|
"_id": 16,
|
||||||
"name": "ThirdPerson",
|
"name": "ThirdPerson",
|
||||||
"modversion": "1.0.6",
|
"modversion": "1.0.7",
|
||||||
"gameversion": "2023r173",
|
"gameversion": "2023r173",
|
||||||
"loaderversion": "0.6.1",
|
"loaderversion": "0.6.1",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
|
@ -14,9 +14,9 @@
|
||||||
"third person"
|
"third person"
|
||||||
],
|
],
|
||||||
"requirements": [],
|
"requirements": [],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r22/ThirdPerson.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r23/ThirdPerson.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/ThirdPerson",
|
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/ThirdPerson",
|
||||||
"changelog": "- Fixed not updating stored culling mask on world join or ThirdPerson toggle.\n- Switched to using CVRTools.CopyToDestCam when copying camera settings.",
|
"changelog": "- Added restriction to worlds with Zoom disabled.",
|
||||||
"embedcolor": "#F61961"
|
"embedcolor": "#F61961"
|
||||||
}
|
}
|
||||||
]
|
]
|
Loading…
Add table
Add a link
Reference in a new issue