mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-03 23:09:22 +00:00
[DesktopCameraFix] Update viewpoint when disabling mod.
This commit is contained in:
parent
6ee3d80ef8
commit
c32d8735be
2 changed files with 9 additions and 18 deletions
|
@ -14,6 +14,7 @@ class PlayerSetupPatches
|
||||||
if (!DesktopCameraFix.EntryEnabled.Value)
|
if (!DesktopCameraFix.EntryEnabled.Value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// this would be much simplier if I bothered with transpilers
|
||||||
if (____movementSystem.disableCameraControl && !ignore)
|
if (____movementSystem.disableCameraControl && !ignore)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -25,18 +26,5 @@ class PlayerSetupPatches
|
||||||
{
|
{
|
||||||
__instance.desktopCamera.transform.position = viewpointTransform.position;
|
__instance.desktopCamera.transform.position = viewpointTransform.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
desktopCameraRig -> desktopCamera
|
|
||||||
desktopCameraRig is parent of desktopCamera.
|
|
||||||
|
|
||||||
desktopCamera rotates, so it pivots in place.
|
|
||||||
desktopCameraRig is moved to head bone, local position of camera is viewpoint offset when standing
|
|
||||||
|
|
||||||
if rig was moving position & rotation, this would work
|
|
||||||
but because rig handles position and camera handles rotation, camera pivots in place instead of at correct point
|
|
||||||
which is gross
|
|
||||||
|
|
||||||
**/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,27 @@
|
||||||
using ABI_RC.Core.IO;
|
using ABI_RC.Core.Player;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace NAK.DesktopCameraFix;
|
namespace NAK.DesktopCameraFix;
|
||||||
|
|
||||||
public class DesktopCameraFix : MelonMod
|
public class DesktopCameraFix : MelonMod
|
||||||
{
|
{
|
||||||
internal const string SettingsCategory = nameof(DesktopCameraFix);
|
|
||||||
|
|
||||||
public static readonly MelonPreferences_Category Category =
|
public static readonly MelonPreferences_Category Category =
|
||||||
MelonPreferences.CreateCategory(SettingsCategory);
|
MelonPreferences.CreateCategory(nameof(DesktopCameraFix));
|
||||||
|
|
||||||
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
|
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
|
||||||
Category.CreateEntry("Enabled", true, description: "Toggle DesktopCameraFix entirely.");
|
Category.CreateEntry("Enabled", true, description: "Toggle DesktopCameraFix entirely.");
|
||||||
|
|
||||||
public override void OnInitializeMelon()
|
public override void OnInitializeMelon()
|
||||||
{
|
{
|
||||||
|
EntryEnabled.OnEntryValueChanged.Subscribe(OnEntryEnabledChanged);
|
||||||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnEntryEnabledChanged(bool newValue, bool oldValue)
|
||||||
|
{
|
||||||
|
if (newValue) PlayerSetup.Instance.SetViewPointOffset();
|
||||||
|
}
|
||||||
|
|
||||||
void ApplyPatches(Type type)
|
void ApplyPatches(Type type)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue