mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[ThirdPerson] BetterShadowClone support
This commit is contained in:
parent
5ee7dca50b
commit
1de39260f4
6 changed files with 66 additions and 16 deletions
|
@ -31,6 +31,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EzCurls", "EzCurls\EzCurls.
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsGunMod", "PhysicsGunMod\PhysicsGunMod.csproj", "{F94DDB73-9041-4F5C-AD43-6960701E8417}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsGunMod", "PhysicsGunMod\PhysicsGunMod.csproj", "{F94DDB73-9041-4F5C-AD43-6960701E8417}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MirrorClone", "MirrorClone\MirrorClone.csproj", "{D5E81123-9D3B-4420-9CCD-1861657BE00B}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterShadowClone", "BetterShadowClone\BetterShadowClone.csproj", "{D0C40987-AF16-490A-9304-F99D5A5A774C}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -93,6 +97,14 @@ Global
|
||||||
{F94DDB73-9041-4F5C-AD43-6960701E8417}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{F94DDB73-9041-4F5C-AD43-6960701E8417}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{F94DDB73-9041-4F5C-AD43-6960701E8417}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{F94DDB73-9041-4F5C-AD43-6960701E8417}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{F94DDB73-9041-4F5C-AD43-6960701E8417}.Release|Any CPU.Build.0 = Release|Any CPU
|
{F94DDB73-9041-4F5C-AD43-6960701E8417}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D5E81123-9D3B-4420-9CCD-1861657BE00B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D5E81123-9D3B-4420-9CCD-1861657BE00B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D5E81123-9D3B-4420-9CCD-1861657BE00B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D5E81123-9D3B-4420-9CCD-1861657BE00B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D0C40987-AF16-490A-9304-F99D5A5A774C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D0C40987-AF16-490A-9304-F99D5A5A774C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D0C40987-AF16-490A-9304-F99D5A5A774C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D0C40987-AF16-490A-9304-F99D5A5A774C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -12,7 +12,8 @@ internal static class CameraLogic
|
||||||
{
|
{
|
||||||
private static float _dist;
|
private static float _dist;
|
||||||
private static float _scale = 1f;
|
private static float _scale = 1f;
|
||||||
private static Camera _thirdpersonCam;
|
private static Camera _thirdPersonCam;
|
||||||
|
private static Camera _uiCam;
|
||||||
private static Camera _desktopCam;
|
private static Camera _desktopCam;
|
||||||
private static int _storedCamMask;
|
private static int _storedCamMask;
|
||||||
private static CameraFovClone _cameraFovClone;
|
private static CameraFovClone _cameraFovClone;
|
||||||
|
@ -36,7 +37,8 @@ internal static class CameraLogic
|
||||||
_state = !CheckIsRestricted() && 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);
|
_uiCam.cullingMask = _state ? _uiCam.cullingMask & ~(1 << CVRLayers.PlayerClone) : _uiCam.cullingMask | (1 << CVRLayers.PlayerClone);
|
||||||
|
_thirdPersonCam.gameObject.SetActive(_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,18 +46,19 @@ internal static class CameraLogic
|
||||||
{
|
{
|
||||||
yield return new WaitUntil(() => PlayerSetup.Instance);
|
yield return new WaitUntil(() => PlayerSetup.Instance);
|
||||||
|
|
||||||
_thirdpersonCam = new GameObject("ThirdPersonCameraObj", typeof(Camera)).GetComponent<Camera>();
|
_thirdPersonCam = new GameObject("ThirdPersonCameraObj", typeof(Camera)).GetComponent<Camera>();
|
||||||
|
|
||||||
_cameraFovClone = _thirdpersonCam.gameObject.AddComponent<CameraFovClone>();
|
_cameraFovClone = _thirdPersonCam.gameObject.AddComponent<CameraFovClone>();
|
||||||
|
|
||||||
_desktopCam = PlayerSetup.Instance.desktopCamera.GetComponent<Camera>();
|
_desktopCam = PlayerSetup.Instance.desktopCamera.GetComponent<Camera>();
|
||||||
_cameraFovClone.targetCamera = _desktopCam;
|
_cameraFovClone.targetCamera = _desktopCam;
|
||||||
|
|
||||||
_thirdpersonCam.transform.SetParent(_desktopCam.transform);
|
_thirdPersonCam.transform.SetParent(_desktopCam.transform);
|
||||||
|
_uiCam = _desktopCam.transform.Find("_UICamera").GetComponent<Camera>();
|
||||||
|
|
||||||
RelocateCam(CameraLocation.Default);
|
RelocateCam(CameraLocation.Default);
|
||||||
|
|
||||||
_thirdpersonCam.gameObject.SetActive(false);
|
_thirdPersonCam.gameObject.SetActive(false);
|
||||||
|
|
||||||
ThirdPerson.Logger.Msg("Finished setting up third person camera.");
|
ThirdPerson.Logger.Msg("Finished setting up third person camera.");
|
||||||
}
|
}
|
||||||
|
@ -63,11 +66,11 @@ internal static class CameraLogic
|
||||||
internal static void CopyPlayerCamValues()
|
internal static void CopyPlayerCamValues()
|
||||||
{
|
{
|
||||||
Camera activePlayerCam = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
Camera activePlayerCam = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
||||||
if (_thirdpersonCam == 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);
|
CVRTools.CopyToDestCam(activePlayerCam, _thirdPersonCam);
|
||||||
|
|
||||||
if (!CheckIsRestricted())
|
if (!CheckIsRestricted())
|
||||||
return;
|
return;
|
||||||
|
@ -78,7 +81,7 @@ internal static class CameraLogic
|
||||||
|
|
||||||
internal static void RelocateCam(CameraLocation location, bool resetDist = false)
|
internal static void RelocateCam(CameraLocation location, bool resetDist = false)
|
||||||
{
|
{
|
||||||
Transform thirdPersonCam = _thirdpersonCam.transform;
|
Transform thirdPersonCam = _thirdPersonCam.transform;
|
||||||
thirdPersonCam.rotation = _desktopCam.transform.rotation;
|
thirdPersonCam.rotation = _desktopCam.transform.rotation;
|
||||||
if (resetDist) ResetDist();
|
if (resetDist) ResetDist();
|
||||||
switch (location)
|
switch (location)
|
||||||
|
@ -107,11 +110,18 @@ internal static class CameraLogic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void ResetDist() => _dist = 0;
|
private static void ResetDist() => _dist = 0;
|
||||||
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()
|
private static bool CheckIsRestricted()
|
||||||
=> !CVRWorld.Instance.enableZoom;
|
=> !CVRWorld.Instance.enableZoom;
|
||||||
|
|
||||||
|
internal static bool ShouldNotHideHead_ThirdPerson(Camera cam)
|
||||||
|
{
|
||||||
|
if (cam != _desktopCam)
|
||||||
|
return true; // we dont care
|
||||||
|
|
||||||
|
return !State;
|
||||||
|
}
|
||||||
}
|
}
|
11
ThirdPerson/Integrations/BSCAddon.cs
Normal file
11
ThirdPerson/Integrations/BSCAddon.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using NAK.BetterShadowClone;
|
||||||
|
|
||||||
|
namespace NAK.ThirdPerson.Integrations;
|
||||||
|
|
||||||
|
public static class BSCAddon
|
||||||
|
{
|
||||||
|
public static void Initialize()
|
||||||
|
{
|
||||||
|
ShadowCloneMod.wantsToHideHead += CameraLogic.ShouldNotHideHead_ThirdPerson;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using NAK.ThirdPerson.Properties;
|
using NAK.ThirdPerson.Properties;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using CurvedUI;
|
||||||
|
|
||||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||||
|
@ -23,6 +24,7 @@ using System.Reflection;
|
||||||
[assembly: MelonColor(255, 246, 25, 97)]
|
[assembly: MelonColor(255, 246, 25, 97)]
|
||||||
[assembly: MelonAuthorColor(255, 158, 21, 32)]
|
[assembly: MelonAuthorColor(255, 158, 21, 32)]
|
||||||
[assembly: HarmonyDontPatchAll]
|
[assembly: HarmonyDontPatchAll]
|
||||||
|
[assembly: MelonOptionalDependencies("BetterShadowClone")]
|
||||||
|
|
||||||
namespace NAK.ThirdPerson.Properties;
|
namespace NAK.ThirdPerson.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
|
|
|
@ -14,6 +14,17 @@ public class ThirdPerson : MelonMod
|
||||||
|
|
||||||
Patches.Apply(HarmonyInstance);
|
Patches.Apply(HarmonyInstance);
|
||||||
MelonCoroutines.Start(SetupCamera());
|
MelonCoroutines.Start(SetupCamera());
|
||||||
|
|
||||||
|
InitializeIntegration("BetterShadowClone", Integrations.BSCAddon.Initialize);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitializeIntegration(string modName, Action integrationAction)
|
||||||
|
{
|
||||||
|
if (RegisteredMelons.All(it => it.Info.Name != modName))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Logger.Msg($"Initializing {modName} integration.");
|
||||||
|
integrationAction.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUpdate()
|
public override void OnUpdate()
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project Sdk="Microsoft.NET.Sdk" />
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BetterShadowClone\BetterShadowClone.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue