mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
simplified mod, added proper BTKUILib support
This commit is contained in:
parent
fb5c3c00b5
commit
da42d3da57
6 changed files with 273 additions and 212 deletions
|
@ -2,35 +2,42 @@
|
|||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DesktopVRIK;
|
||||
namespace NAK.Melons.DesktopVRIK;
|
||||
|
||||
public class DesktopVRIKMod : MelonMod
|
||||
{
|
||||
internal const string SettingsCategory = "DesktopVRIK";
|
||||
private static MelonPreferences_Category m_categoryDesktopVRIK;
|
||||
private static MelonPreferences_Entry<bool> m_entryEnabled,
|
||||
m_entryEmulateHipMovement,
|
||||
m_entryEnforceViewPosition,
|
||||
m_entryEmoteVRIK,
|
||||
m_entryEmoteLookAtIK,
|
||||
m_entryPlantFeet;
|
||||
private static MelonPreferences_Entry<float> m_entryEmulateVRChatHipMovementWeight;
|
||||
internal static MelonPreferences_Category m_categoryDesktopVRIK;
|
||||
internal static MelonPreferences_Entry<bool> m_entryEnabled,
|
||||
m_entryEnforceViewPosition,
|
||||
m_entryEmoteVRIK,
|
||||
m_entryEmoteLookAtIK;
|
||||
internal static MelonPreferences_Entry<float> m_entryEmulateVRChatHipMovementWeight;
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
m_categoryDesktopVRIK = MelonPreferences.CreateCategory(SettingsCategory);
|
||||
m_entryEnabled = m_categoryDesktopVRIK.CreateEntry<bool>("Enabled", true, description: "Attempt to give Desktop VRIK on avatar load.");
|
||||
m_entryEmulateHipMovement = m_categoryDesktopVRIK.CreateEntry<bool>("Emulate Hip Movement", true, description: "Emulates VRChat-like hip movement when moving head up/down on desktop.");
|
||||
m_entryEmulateVRChatHipMovementWeight = m_categoryDesktopVRIK.CreateEntry<float>("Hip Movement Weight", 0.5f, description: "The weight modifier for the hip movement.");
|
||||
m_entryEnabled = m_categoryDesktopVRIK.CreateEntry<bool>("Enabled", true, description: "Toggle DesktopVRIK entirely. Requires avatar reload.");
|
||||
m_entryEmulateVRChatHipMovementWeight = m_categoryDesktopVRIK.CreateEntry<float>("Body Movement Weight", 0.5f, description: "Emulates VRChat-like body movement when looking up/down. Set to 0 to disable.");
|
||||
m_entryEnforceViewPosition = m_categoryDesktopVRIK.CreateEntry<bool>("Enforce View Position", false, description: "Corrects view position to use VRIK offsets.");
|
||||
m_entryEmoteVRIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote VRIK", true, description: "Disable VRIK while emoting. Only disable if you are ok with looking dumb.");
|
||||
m_entryEmoteLookAtIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote LookAtIK", true, description: "Disable LookAtIK while emoting. This setting doesn't really matter, as LookAtIK isn't networked while doing an emote.");
|
||||
m_entryPlantFeet = m_categoryDesktopVRIK.CreateEntry<bool>("Plant Feet", true, description: "Enables Plant Feet for VRIK while in Desktop. Keeps avatar on ground when entering Idle instead of hovering.");
|
||||
|
||||
foreach (var setting in m_categoryDesktopVRIK.Entries)
|
||||
{
|
||||
setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
|
||||
}
|
||||
|
||||
//BTKUILib Misc Support
|
||||
if (MelonMod.RegisteredMelons.Any(it => it.Info.Name == "BTKUILib"))
|
||||
{
|
||||
MelonLogger.Msg("Initializing BTKUILib support.");
|
||||
BTKUI_Integration.BTKUI_Integration.Init();
|
||||
}
|
||||
|
||||
//Apply patches (i stole)
|
||||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||
ApplyPatches(typeof(HarmonyPatches.IKSystemPatches));
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
||||
}
|
||||
|
||||
|
@ -47,14 +54,25 @@ public class DesktopVRIKMod : MelonMod
|
|||
private void UpdateAllSettings()
|
||||
{
|
||||
if (!DesktopVRIK.Instance) return;
|
||||
DesktopVRIK.Instance.Setting_Enabled = m_entryEnabled.Value;
|
||||
DesktopVRIK.Instance.Setting_EmulateVRChatHipMovement = m_entryEmulateHipMovement.Value;
|
||||
DesktopVRIK.Instance.Setting_EmulateVRChatHipMovementWeight = Mathf.Clamp01(m_entryEmulateVRChatHipMovementWeight.Value);
|
||||
DesktopVRIK.Instance.Setting_EmoteVRIK = m_entryEmoteVRIK.Value;
|
||||
DesktopVRIK.Instance.Setting_EmoteLookAtIK = m_entryEmoteLookAtIK.Value;
|
||||
DesktopVRIK.Instance.Setting_PlantFeet = m_entryPlantFeet.Value;
|
||||
DesktopVRIK.Setting_Enabled = m_entryEnabled.Value;
|
||||
DesktopVRIK.Setting_EmulateVRChatHipMovementWeight = Mathf.Clamp01(m_entryEmulateVRChatHipMovementWeight.Value);
|
||||
DesktopVRIK.Setting_EmoteVRIK = m_entryEmoteVRIK.Value;
|
||||
DesktopVRIK.Setting_EmoteLookAtIK = m_entryEmoteLookAtIK.Value;
|
||||
DesktopVRIK.Instance.ChangeViewpointHandling(m_entryEnforceViewPosition.Value);
|
||||
}
|
||||
|
||||
private void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings();
|
||||
|
||||
private void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
HarmonyInstance.PatchAll(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerInstance.Msg($"Failed while patching {type.Name}!");
|
||||
LoggerInstance.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue