simplified mod, added proper BTKUILib support

This commit is contained in:
NotAKidoS 2023-01-13 18:30:22 -06:00
parent fb5c3c00b5
commit da42d3da57
6 changed files with 273 additions and 212 deletions

View file

@ -0,0 +1,30 @@
using System.Runtime.CompilerServices;
using BTKUILib;
using BTKUILib.UIObjects;
namespace NAK.Melons.DesktopVRIK.BTKUI_Integration;
public static class BTKUI_Integration
{
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Init()
{
Page miscPage = QuickMenuAPI.MiscTabPage;
Category CategoryUI = miscPage.AddCategory("DesktopVRIK");
var setting_Enabled = CategoryUI.AddToggle(DesktopVRIKMod.m_entryEnabled.DisplayName, DesktopVRIKMod.m_entryEnabled.Description, DesktopVRIKMod.m_entryEnabled.Value);
setting_Enabled.OnValueUpdated += b => DesktopVRIKMod.m_entryEnabled.Value = b;
var setting_EnforceViewPosition = CategoryUI.AddToggle(DesktopVRIKMod.m_entryEnforceViewPosition.DisplayName, DesktopVRIKMod.m_entryEnforceViewPosition.Description, DesktopVRIKMod.m_entryEnforceViewPosition.Value);
setting_EnforceViewPosition.OnValueUpdated += b => DesktopVRIKMod.m_entryEnforceViewPosition.Value = b;
var setting_DisableEmoteVRIK = CategoryUI.AddToggle(DesktopVRIKMod.m_entryEmoteVRIK.DisplayName, DesktopVRIKMod.m_entryEmoteVRIK.Description, DesktopVRIKMod.m_entryEmoteVRIK.Value);
setting_DisableEmoteVRIK.OnValueUpdated += b => DesktopVRIKMod.m_entryEmoteVRIK.Value = b;
var setting_DisableEmoteLookAtIK = CategoryUI.AddToggle(DesktopVRIKMod.m_entryEmoteLookAtIK.DisplayName, DesktopVRIKMod.m_entryEmoteLookAtIK.Description, DesktopVRIKMod.m_entryEmoteLookAtIK.Value);
setting_DisableEmoteLookAtIK.OnValueUpdated += b => DesktopVRIKMod.m_entryEmoteLookAtIK.Value = b;
var setting_EmulateHipMovementWeight = miscPage.AddSlider(DesktopVRIKMod.m_entryEmulateVRChatHipMovementWeight.DisplayName, DesktopVRIKMod.m_entryEmulateVRChatHipMovementWeight.Description, DesktopVRIKMod.m_entryEmulateVRChatHipMovementWeight.Value, 0f, 1f);
setting_EmulateHipMovementWeight.OnValueUpdated += f => DesktopVRIKMod.m_entryEmulateVRChatHipMovementWeight.Value = f;
}
}

View file

@ -7,19 +7,17 @@ using RootMotion.FinalIK;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
namespace DesktopVRIK; namespace NAK.Melons.DesktopVRIK;
public class DesktopVRIK : MonoBehaviour public class DesktopVRIK : MonoBehaviour
{ {
public static DesktopVRIK Instance; public static DesktopVRIK Instance;
public bool Setting_Enabled, public static bool Setting_Enabled,
Setting_EmulateVRChatHipMovement,
Setting_EnforceViewPosition, Setting_EnforceViewPosition,
Setting_EmoteVRIK, Setting_EmoteVRIK,
Setting_EmoteLookAtIK, Setting_EmoteLookAtIK;
Setting_PlantFeet; public static float Setting_EmulateVRChatHipMovementWeight;
public float Setting_EmulateVRChatHipMovementWeight;
public Transform viewpoint; public Transform viewpoint;
public Vector3 initialCamPos; public Vector3 initialCamPos;
@ -31,6 +29,7 @@ public class DesktopVRIK : MonoBehaviour
public void ChangeViewpointHandling(bool enabled) public void ChangeViewpointHandling(bool enabled)
{ {
if (Setting_EnforceViewPosition == enabled) return;
Setting_EnforceViewPosition = enabled; Setting_EnforceViewPosition = enabled;
if (enabled) if (enabled)
{ {
@ -42,25 +41,40 @@ public class DesktopVRIK : MonoBehaviour
public void OnPreSolverUpdate() public void OnPreSolverUpdate()
{ {
//this order matters, rotation offset will be choppy if avatar is not cenetered first
//Reset avatar offset (VRIK will literally make you walk away from root otherwise) //Reset avatar offset (VRIK will literally make you walk away from root otherwise)
IKSystem.vrik.transform.localPosition = Vector3.zero; IKSystem.vrik.transform.localPosition = Vector3.zero;
IKSystem.vrik.transform.localRotation = Quaternion.identity; IKSystem.vrik.transform.localRotation = Quaternion.identity;
//VRChat hip movement emulation //VRChat hip movement emulation
if (Setting_EmulateVRChatHipMovement) if (Setting_EmulateVRChatHipMovementWeight != 0)
{ {
float angle = PlayerSetup.Instance.desktopCamera.transform.localEulerAngles.x; float angle = PlayerSetup.Instance.desktopCamera.transform.localEulerAngles.x;
angle = (angle > 180) ? angle - 360 : angle; if (angle > 180) angle -= 360;
float weight = (Setting_EmulateVRChatHipMovementWeight - MovementSystem.Instance.movementVector.magnitude); float leanAmount = angle * (1 - MovementSystem.Instance.movementVector.magnitude) * Setting_EmulateVRChatHipMovementWeight;
Quaternion rotation = Quaternion.AngleAxis(angle * weight, IKSystem.Instance.avatar.transform.right); Quaternion rotation = Quaternion.AngleAxis(leanAmount, IKSystem.Instance.avatar.transform.right);
IKSystem.vrik.solver.AddRotationOffset(IKSolverVR.RotationOffset.Head, rotation); IKSystem.vrik.solver.AddRotationOffset(IKSolverVR.RotationOffset.Head, rotation);
} }
IKSystem.vrik.solver.plantFeet = Setting_PlantFeet; IKSystem.vrik.solver.plantFeet = true;
} }
public void CalibrateDesktopVRIK(CVRAvatar avatar) public void CalibrateDesktopVRIK(CVRAvatar avatar)
{ {
//ikpose layer (specified by avatar author)
int? ikposeLayerIndex = PlayerSetup.Instance.animatorManager.GetAnimatorLayerIndex("IKPose");
int? locoLayerIndex = PlayerSetup.Instance.animatorManager.GetAnimatorLayerIndex("Locomotion/Emotes");
if (ikposeLayerIndex != -1)
{
PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("IKPose", 1f);
if (locoLayerIndex != -1)
{
PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("Locomotion/Emotes", 0f);
}
IKSystem.Instance.animator.Update(0f);
}
//Stuff to make bad armatures work (Fuck you Default Robot Kyle) //Stuff to make bad armatures work (Fuck you Default Robot Kyle)
IKSystem.Instance.animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;
avatar.transform.localPosition = Vector3.zero; avatar.transform.localPosition = Vector3.zero;
Quaternion originalRotation = avatar.transform.rotation; Quaternion originalRotation = avatar.transform.rotation;
avatar.transform.rotation = Quaternion.identity; avatar.transform.rotation = Quaternion.identity;
@ -69,10 +83,11 @@ public class DesktopVRIK : MonoBehaviour
IKSystem.vrik.fixTransforms = false; IKSystem.vrik.fixTransforms = false;
IKSystem.vrik.solver.plantFeet = false; IKSystem.vrik.solver.plantFeet = false;
IKSystem.vrik.solver.locomotion.weight = 1f; IKSystem.vrik.solver.locomotion.weight = 0f;
IKSystem.vrik.solver.locomotion.angleThreshold = 30f; IKSystem.vrik.solver.locomotion.angleThreshold = 30f;
IKSystem.vrik.solver.locomotion.maxLegStretch = 0.75f; IKSystem.vrik.solver.locomotion.maxLegStretch = 0.75f;
//nuke weights //nuke weights
IKSystem.vrik.AutoDetectReferences();
IKSystem.vrik.solver.spine.headClampWeight = 0f; IKSystem.vrik.solver.spine.headClampWeight = 0f;
IKSystem.vrik.solver.spine.minHeadHeight = 0f; IKSystem.vrik.solver.spine.minHeadHeight = 0f;
IKSystem.vrik.solver.leftArm.positionWeight = 0f; IKSystem.vrik.solver.leftArm.positionWeight = 0f;
@ -115,7 +130,15 @@ public class DesktopVRIK : MonoBehaviour
IKSystem.vrik.onPreSolverUpdate.AddListener(new UnityAction(this.OnPreSolverUpdate)); IKSystem.vrik.onPreSolverUpdate.AddListener(new UnityAction(this.OnPreSolverUpdate));
} }
//(Fuck you Default Robot Kyle).. oh wait nvm, not related if (ikposeLayerIndex != -1)
{
PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("IKPose", 0f);
if (locoLayerIndex != -1)
{
PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("Locomotion/Emotes", 1f);
}
}
avatar.transform.rotation = originalRotation; avatar.transform.rotation = originalRotation;
IKSystem.Instance.ResetIK(); IKSystem.Instance.ResetIK();
} }

View file

@ -18,21 +18,21 @@
<Reference Include="Assembly-CSharp-firstpass"> <Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath> <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference> </Reference>
<Reference Include="BTKUILib">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\BTKUILib.dll</HintPath>
</Reference>
<Reference Include="Cohtml.Runtime"> <Reference Include="Cohtml.Runtime">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll</HintPath> <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll</HintPath>
</Reference> </Reference>
<Reference Include="Giamoz">
<HintPath>..\..\Giamoz\Giamoz\bin\Debug\net472\Giamoz.dll</HintPath>
</Reference>
<Reference Include="MelonLoader"> <Reference Include="MelonLoader">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath> <HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath>
</Reference> </Reference>
<Reference Include="SteamVR">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\SteamVR.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AnimationModule"> <Reference Include="UnityEngine.AnimationModule">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll</HintPath> <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule"> <Reference Include="UnityEngine.CoreModule">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll</HintPath> <HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference> </Reference>

View file

@ -4,7 +4,6 @@ using ABI_RC.Core.Savior;
using ABI_RC.Systems.IK; using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.SubSystems; using ABI_RC.Systems.IK.SubSystems;
using ABI_RC.Systems.MovementSystem; using ABI_RC.Systems.MovementSystem;
using ABI_RC.Core.Player.AvatarTracking.Local;
using HarmonyLib; using HarmonyLib;
using RootMotion.FinalIK; using RootMotion.FinalIK;
using UnityEngine; using UnityEngine;
@ -33,17 +32,17 @@ using UnityEngine;
**/ **/
namespace DesktopVRIK; namespace NAK.Melons.DesktopVRIK.HarmonyPatches;
[HarmonyPatch] class PlayerSetupPatches
internal class HarmonyPatches
{ {
private static bool emotePlayed = false;
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), "SetupAvatarGeneral")] [HarmonyPatch(typeof(PlayerSetup), "SetupAvatarGeneral")]
private static void SetupDesktopIKSystem(ref CVRAvatar ____avatarDescriptor, ref Animator ____animator) static void SetupDesktopIKSystem(ref CVRAvatar ____avatarDescriptor, ref Animator ____animator)
{ {
if (!MetaPort.Instance.isUsingVr && DesktopVRIK.Instance.Setting_Enabled) if (!MetaPort.Instance.isUsingVr && DesktopVRIK.Setting_Enabled)
{ {
if (____avatarDescriptor != null && ____animator != null && ____animator.isHuman) if (____avatarDescriptor != null && ____animator != null && ____animator.isHuman)
{ {
@ -53,11 +52,56 @@ internal class HarmonyPatches
} }
} }
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), "Update")]
private static void CorrectVRIK(ref bool ____emotePlaying, ref LookAtIK ___lookIK)
{
if (!MetaPort.Instance.isUsingVr && DesktopVRIK.Setting_Enabled)
{
bool changed = ____emotePlaying != emotePlayed;
if (changed)
{
emotePlayed = ____emotePlaying;
IKSystem.vrik.transform.localPosition = Vector3.zero;
IKSystem.vrik.transform.localRotation = Quaternion.identity;
if (DesktopVRIK.Setting_EmoteLookAtIK && ___lookIK != null)
{
___lookIK.enabled = !____emotePlaying;
}
if (DesktopVRIK.Setting_EmoteVRIK)
{
BodySystem.TrackingEnabled = !____emotePlaying;
IKSystem.vrik.solver?.Reset();
}
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), "HandleDesktopCameraPosition")]
private static void Postfix_PlayerSetup_HandleDesktopCameraPosition(bool ignore, ref PlayerSetup __instance, ref MovementSystem ____movementSystem, ref int ___headBobbingLevel)
{
if (DesktopVRIK.Setting_Enabled && DesktopVRIK.Setting_EnforceViewPosition)
{
if (!____movementSystem.disableCameraControl || ignore)
{
if (___headBobbingLevel == 2 && DesktopVRIK.Instance.viewpoint != null)
{
__instance.desktopCamera.transform.localPosition = Vector3.zero;
__instance.desktopCameraRig.transform.position = DesktopVRIK.Instance.viewpoint.position;
}
}
}
}
}
class IKSystemPatches
{
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(IKSystem), "InitializeAvatar")] [HarmonyPatch(typeof(IKSystem), "InitializeAvatar")]
private static void InitializeDesktopAvatarVRIK(CVRAvatar avatar, ref VRIK ____vrik, ref HumanPoseHandler ____poseHandler, ref HumanPose ___humanPose) private static void InitializeDesktopAvatarVRIK(CVRAvatar avatar, ref VRIK ____vrik, ref HumanPoseHandler ____poseHandler, ref HumanPose ___humanPose)
{ {
if (!MetaPort.Instance.isUsingVr && DesktopVRIK.Instance.Setting_Enabled) if (!MetaPort.Instance.isUsingVr && DesktopVRIK.Setting_Enabled)
{ {
if (IKSystem.Instance.animator != null && IKSystem.Instance.animator.avatar != null && IKSystem.Instance.animator.avatar.isHuman) if (IKSystem.Instance.animator != null && IKSystem.Instance.animator.avatar != null && IKSystem.Instance.animator.avatar.isHuman)
{ {
@ -66,11 +110,12 @@ internal class HarmonyPatches
{ {
____poseHandler = new HumanPoseHandler(IKSystem.Instance.animator.avatar, IKSystem.Instance.animator.transform); ____poseHandler = new HumanPoseHandler(IKSystem.Instance.animator.avatar, IKSystem.Instance.animator.transform);
} }
____poseHandler.GetHumanPose(ref ___humanPose); ____poseHandler.GetHumanPose(ref ___humanPose);
for (int i = 0; i < TPoseMuscles.Length; i++) //for (int i = 0; i < TPoseMuscles.Length; i++)
{ //{
IKSystem.Instance.ApplyMuscleValue((MuscleIndex)i, TPoseMuscles[i], ref ___humanPose.muscles); // IKSystem.Instance.ApplyMuscleValue((MuscleIndex)i, TPoseMuscles[i], ref ___humanPose.muscles);
} //}
____poseHandler.SetHumanPose(ref ___humanPose); ____poseHandler.SetHumanPose(ref ___humanPose);
//need IKSystem to see VRIK component for setup //need IKSystem to see VRIK component for setup
@ -85,61 +130,6 @@ internal class HarmonyPatches
} }
} }
private static bool emotePlayed = false;
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), "Update")]
private static void CorrectVRIK(ref bool ____emotePlaying, ref LookAtIK ___lookIK)
{
if (MetaPort.Instance.isUsingVr || DesktopVRIK.Instance == null) return;
//might need to rework this in the future
if (____emotePlaying && !emotePlayed)
{
emotePlayed = true;
if (DesktopVRIK.Instance.Setting_EmoteVRIK)
{
BodySystem.TrackingEnabled = false;
//IKSystem.vrik.solver.Reset();
}
if (DesktopVRIK.Instance.Setting_EmoteLookAtIK && ___lookIK != null)
{
___lookIK.enabled = false;
}
IKSystem.vrik.transform.localPosition = Vector3.zero;
IKSystem.vrik.transform.localRotation = Quaternion.identity;
}
else if (!____emotePlaying && emotePlayed)
{
emotePlayed = false;
IKSystem.vrik.solver.Reset();
BodySystem.TrackingEnabled = true;
if (___lookIK != null)
{
___lookIK.enabled = true;
}
IKSystem.vrik.transform.localPosition = Vector3.zero;
IKSystem.vrik.transform.localRotation = Quaternion.identity;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), "HandleDesktopCameraPosition")]
private static void Postfix_PlayerSetup_HandleDesktopCameraPosition(bool ignore, ref PlayerSetup __instance, ref MovementSystem ____movementSystem, ref int ___headBobbingLevel)
{
if (DesktopVRIK.Instance.Setting_EnforceViewPosition)
{
if (!____movementSystem.disableCameraControl || ignore)
{
if (___headBobbingLevel == 2 && DesktopVRIK.Instance.viewpoint != null)
{
__instance.desktopCamera.transform.localPosition = Vector3.zero;
__instance.desktopCameraRig.transform.position = DesktopVRIK.Instance.viewpoint.position;
}
}
}
}
private static readonly float[] TPoseMuscles = new float[] private static readonly float[] TPoseMuscles = new float[]
{ {
0f, 0f,
@ -238,5 +228,4 @@ internal class HarmonyPatches
0.8116842f, 0.8116842f,
0.811684f 0.811684f
}; };
} }

View file

@ -2,35 +2,42 @@
using MelonLoader; using MelonLoader;
using UnityEngine; using UnityEngine;
namespace DesktopVRIK; namespace NAK.Melons.DesktopVRIK;
public class DesktopVRIKMod : MelonMod public class DesktopVRIKMod : MelonMod
{ {
internal const string SettingsCategory = "DesktopVRIK"; internal const string SettingsCategory = "DesktopVRIK";
private static MelonPreferences_Category m_categoryDesktopVRIK; internal static MelonPreferences_Category m_categoryDesktopVRIK;
private static MelonPreferences_Entry<bool> m_entryEnabled, internal static MelonPreferences_Entry<bool> m_entryEnabled,
m_entryEmulateHipMovement,
m_entryEnforceViewPosition, m_entryEnforceViewPosition,
m_entryEmoteVRIK, m_entryEmoteVRIK,
m_entryEmoteLookAtIK, m_entryEmoteLookAtIK;
m_entryPlantFeet; internal static MelonPreferences_Entry<float> m_entryEmulateVRChatHipMovementWeight;
private static MelonPreferences_Entry<float> m_entryEmulateVRChatHipMovementWeight;
public override void OnInitializeMelon() public override void OnInitializeMelon()
{ {
m_categoryDesktopVRIK = MelonPreferences.CreateCategory(SettingsCategory); m_categoryDesktopVRIK = MelonPreferences.CreateCategory(SettingsCategory);
m_entryEnabled = m_categoryDesktopVRIK.CreateEntry<bool>("Enabled", true, description: "Attempt to give Desktop VRIK on avatar load."); m_entryEnabled = m_categoryDesktopVRIK.CreateEntry<bool>("Enabled", true, description: "Toggle DesktopVRIK entirely. Requires avatar reload.");
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>("Body Movement Weight", 0.5f, description: "Emulates VRChat-like body movement when looking up/down. Set to 0 to disable.");
m_entryEmulateVRChatHipMovementWeight = m_categoryDesktopVRIK.CreateEntry<float>("Hip Movement Weight", 0.5f, description: "The weight modifier for the hip movement.");
m_entryEnforceViewPosition = m_categoryDesktopVRIK.CreateEntry<bool>("Enforce View Position", false, description: "Corrects view position to use VRIK offsets."); 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_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_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) foreach (var setting in m_categoryDesktopVRIK.Entries)
{ {
setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings); 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()); MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
} }
@ -47,14 +54,25 @@ public class DesktopVRIKMod : MelonMod
private void UpdateAllSettings() private void UpdateAllSettings()
{ {
if (!DesktopVRIK.Instance) return; if (!DesktopVRIK.Instance) return;
DesktopVRIK.Instance.Setting_Enabled = m_entryEnabled.Value; DesktopVRIK.Setting_Enabled = m_entryEnabled.Value;
DesktopVRIK.Instance.Setting_EmulateVRChatHipMovement = m_entryEmulateHipMovement.Value; DesktopVRIK.Setting_EmulateVRChatHipMovementWeight = Mathf.Clamp01(m_entryEmulateVRChatHipMovementWeight.Value);
DesktopVRIK.Instance.Setting_EmulateVRChatHipMovementWeight = Mathf.Clamp01(m_entryEmulateVRChatHipMovementWeight.Value); DesktopVRIK.Setting_EmoteVRIK = m_entryEmoteVRIK.Value;
DesktopVRIK.Instance.Setting_EmoteVRIK = m_entryEmoteVRIK.Value; DesktopVRIK.Setting_EmoteLookAtIK = m_entryEmoteLookAtIK.Value;
DesktopVRIK.Instance.Setting_EmoteLookAtIK = m_entryEmoteLookAtIK.Value;
DesktopVRIK.Instance.Setting_PlantFeet = m_entryPlantFeet.Value;
DesktopVRIK.Instance.ChangeViewpointHandling(m_entryEnforceViewPosition.Value); DesktopVRIK.Instance.ChangeViewpointHandling(m_entryEnforceViewPosition.Value);
} }
private void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings(); 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);
}
}
} }

View file

@ -6,13 +6,13 @@ using System.Reflection;
[assembly: AssemblyVersion(AssemblyInfoParams.Version)] [assembly: AssemblyVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] [assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] [assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyTitle(nameof(DesktopVRIK))] [assembly: AssemblyTitle(nameof(NAK.Melons.DesktopVRIK))]
[assembly: AssemblyCompany(AssemblyInfoParams.Author)] [assembly: AssemblyCompany(AssemblyInfoParams.Author)]
[assembly: AssemblyProduct(nameof(DesktopVRIK))] [assembly: AssemblyProduct(nameof(NAK.Melons.DesktopVRIK))]
[assembly: MelonInfo( [assembly: MelonInfo(
typeof(DesktopVRIK.DesktopVRIKMod), typeof(NAK.Melons.DesktopVRIK.DesktopVRIKMod),
nameof(DesktopVRIK), nameof(NAK.Melons.DesktopVRIK),
AssemblyInfoParams.Version, AssemblyInfoParams.Version,
AssemblyInfoParams.Author, AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidOnSteam/DesktopVRIK" downloadLink: "https://github.com/NotAKidOnSteam/DesktopVRIK"
@ -21,10 +21,11 @@ using System.Reflection;
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] [assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] [assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
[assembly: MelonOptionalDependencies("BTKUILib")]
namespace DesktopVRIK.Properties; namespace DesktopVRIK.Properties;
internal static class AssemblyInfoParams internal static class AssemblyInfoParams
{ {
public const string Version = "1.0.4"; public const string Version = "1.0.5";
public const string Author = "NotAKidoS"; public const string Author = "NotAKidoS";
} }