This commit is contained in:
NotAKidoS 2023-02-09 21:29:06 -06:00
parent 7d775af7d3
commit 1b188433a2
3 changed files with 47 additions and 51 deletions

View file

@ -1,51 +1,48 @@
using ABI_RC.Core.Player;
using ABI_RC.Core.IO;
using ABI_RC.Core.IO;
using ABI_RC.Core.Player;
using MelonLoader;
using UnityEngine;
namespace PathCamDisabler;
public class PathCamDisabler : MelonMod
namespace NAK.Melons.PathCamDisabler
{
private static MelonPreferences_Category m_categoryPathCamDisabler;
private static MelonPreferences_Entry<bool> m_entryDisablePathCam, m_entryDisableFlightBind;
public override void OnInitializeMelon()
public class PathCamDisablerMod : MelonMod
{
m_categoryPathCamDisabler = MelonPreferences.CreateCategory(nameof(PathCamDisabler));
m_entryDisablePathCam = m_categoryPathCamDisabler.CreateEntry<bool>("Disable Path Camera Controller.", true, description: "Disable path camera controller so you can use your numpad keys without funky shit.");
m_entryDisableFlightBind = m_categoryPathCamDisabler.CreateEntry<bool>("Disable Flight Binding (if controller off).", false, description: "Disables the flight binding as the path camera controller handles that...?");
m_categoryPathCamDisabler.SaveToFile(false);
internal const string SettingsCategory = "PathCamDisabler";
internal static MelonPreferences_Category m_categoryPathCamDisabler;
internal static MelonPreferences_Entry<bool> m_entryDisablePathCam, m_entryDisableFlightBind;
foreach (var setting in m_categoryPathCamDisabler.Entries)
public override void OnInitializeMelon()
{
setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
m_categoryPathCamDisabler = MelonPreferences.CreateCategory(SettingsCategory);
m_entryDisablePathCam = m_categoryPathCamDisabler.CreateEntry<bool>("Disable Path Camera Controller.", true, description: "Disable Path Camera Controller.");
m_entryDisableFlightBind = m_categoryPathCamDisabler.CreateEntry<bool>("Disable Flight Binding (if controller off).", false, description: "Disable flight bind if Path Camera Controller is also disabled.");
m_entryDisablePathCam.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
MelonLoader.MelonCoroutines.Start(WaitForCVRPathCamController());
}
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
}
System.Collections.IEnumerator WaitForLocalPlayer()
{
while (CVRPathCamController.Instance == null)
yield return null;
UpdateSettings();
}
private void UpdateSettings()
{
CVRPathCamController.Instance.enabled = !m_entryDisablePathCam.Value;
}
private void OnUpdateSettings(object arg1, object arg2) => UpdateSettings();
public override void OnUpdate()
{
if (m_entryDisablePathCam.Value && !m_entryDisableFlightBind.Value)
private System.Collections.IEnumerator WaitForCVRPathCamController()
{
if (Input.GetKeyDown(KeyCode.Keypad5))
while (CVRPathCamController.Instance == null)
yield return null;
UpdateSettings();
}
private void UpdateSettings()
{
CVRPathCamController.Instance.enabled = !m_entryDisablePathCam.Value;
}
private void OnUpdateSettings(object arg1, object arg2) => UpdateSettings();
public override void OnUpdate()
{
if (m_entryDisablePathCam.Value && !m_entryDisableFlightBind.Value)
{
PlayerSetup.Instance._movementSystem.ToggleFlight();
if (Input.GetKeyDown(KeyCode.Keypad5))
{
PlayerSetup.Instance._movementSystem.ToggleFlight();
}
}
}
}