NAK_CVR_Mods/CVRGizmos/Main.cs
NotAKidoS 65b57db665 Added new GizmoTypes
typeof(CVRGizmos_ToggleStateTrigger),
            typeof(CVRGizmos_Avatar),
            typeof(CVRGizmos_AvatarPickupMarker),
            //may be broken
            typeof(CVRGizmos_DistanceConstrain),
2022-09-14 18:29:14 -05:00

49 lines
No EOL
1.6 KiB
C#

using ABI_RC.Core.Player;
using MelonLoader;
using UnityEngine;
using System.Collections;
namespace CVRGizmos;
public class CVRGizmos : MelonMod
{
private static MelonPreferences_Category m_categoryCVRGizmos;
private static MelonPreferences_Entry<bool> m_entryCVRGizmosEnabled;
private static MelonPreferences_Entry<bool> m_entryCVRGizmosLocalOnly;
public override void OnApplicationStart()
{
m_categoryCVRGizmos = MelonPreferences.CreateCategory(nameof(CVRGizmos));
m_entryCVRGizmosEnabled = m_categoryCVRGizmos.CreateEntry<bool>("Enabled", false);
m_entryCVRGizmosLocalOnly = m_categoryCVRGizmos.CreateEntry<bool>("Local Only", false);
m_entryCVRGizmosEnabled.Value = false;
m_categoryCVRGizmos.SaveToFile(false);
m_entryCVRGizmosEnabled.OnValueChangedUntyped += CVRGizmosEnabled;
m_entryCVRGizmosLocalOnly.OnValueChangedUntyped += CVRGizmosLocalOnly;
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
}
IEnumerator WaitForLocalPlayer()
{
while (PlayerSetup.Instance == null)
yield return null;
PlayerSetup.Instance.gameObject.AddComponent<CVRGizmoManager>();
}
public void CVRGizmosEnabled()
{
if (!CVRGizmoManager.Instance) return;
CVRGizmoManager.Instance.EnableGizmos(m_entryCVRGizmosEnabled.Value);
}
public void CVRGizmosLocalOnly()
{
if (!CVRGizmoManager.Instance) return;
CVRGizmoManager.Instance.g_localOnly = m_entryCVRGizmosLocalOnly.Value;
CVRGizmoManager.Instance.RefreshGizmos();
}
}