[DesktopCameraFix] Update viewpoint when disabling mod.

This commit is contained in:
NotAKidoS 2023-06-13 14:33:17 -05:00
parent 6ee3d80ef8
commit c32d8735be
2 changed files with 9 additions and 18 deletions

View file

@ -1,24 +1,27 @@
using ABI_RC.Core.IO;
using ABI_RC.Core.Player;
using MelonLoader;
using UnityEngine;
namespace NAK.DesktopCameraFix;
public class DesktopCameraFix : MelonMod
{
internal const string SettingsCategory = nameof(DesktopCameraFix);
public static readonly MelonPreferences_Category Category =
MelonPreferences.CreateCategory(SettingsCategory);
MelonPreferences.CreateCategory(nameof(DesktopCameraFix));
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
Category.CreateEntry("Enabled", true, description: "Toggle DesktopCameraFix entirely.");
public override void OnInitializeMelon()
{
EntryEnabled.OnEntryValueChanged.Subscribe(OnEntryEnabledChanged);
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
}
void OnEntryEnabledChanged(bool newValue, bool oldValue)
{
if (newValue) PlayerSetup.Instance.SetViewPointOffset();
}
void ApplyPatches(Type type)
{
try