diff --git a/ml_lme/LeapInput.cs b/ml_lme/LeapInput.cs index 03b3762..fddc1fd 100644 --- a/ml_lme/LeapInput.cs +++ b/ml_lme/LeapInput.cs @@ -150,14 +150,17 @@ namespace ml_lme } } - if(m_inVR) + if(!ModSupporter.SkipFingersOverride()) { - m_inputManager.individualFingerTracking = !m_steamVrModule.GetIndexGestureToggle(); - m_inputManager.individualFingerTracking |= (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present); + if(m_inVR) + { + m_inputManager.individualFingerTracking = !m_steamVrModule.GetIndexGestureToggle(); + m_inputManager.individualFingerTracking |= (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present); + } + else + m_inputManager.individualFingerTracking = (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present); + IKSystem.Instance.FingerSystem.controlActive = m_inputManager.individualFingerTracking; } - else - m_inputManager.individualFingerTracking = (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present); - IKSystem.Instance.FingerSystem.controlActive = m_inputManager.individualFingerTracking; } m_handRayLeft.enabled = (l_data.m_leftHand.m_present && (!m_inVR || !Utils.IsLeftHandTracked() || !Settings.FingersOnly)); diff --git a/ml_lme/ModSupporter.cs b/ml_lme/ModSupporter.cs new file mode 100644 index 0000000..9747c8d --- /dev/null +++ b/ml_lme/ModSupporter.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ml_lme +{ + static class ModSupporter + { + static bool ms_copycatMod = false; + + public static void Init() + { + if(MelonLoader.MelonMod.RegisteredMelons.FirstOrDefault(m => m.Info.Name == "PlayerMovementCopycat") != null) + MelonLoader.MelonCoroutines.Start(WaitForCopycatInstance()); + } + + // PlayerMovementCopycat support + static IEnumerator WaitForCopycatInstance() + { + while(ml_pmc.PoseCopycat.Instance == null) + yield return null; + + ms_copycatMod = true; + } + static bool IsCopycating() => (ml_pmc.PoseCopycat.Instance.IsActive() && ml_pmc.PoseCopycat.Instance.IsFingerTrackingActive()); + + public static bool SkipFingersOverride() + { + bool l_result = false; + l_result |= (ms_copycatMod && IsCopycating()); + return l_result; + } + } +} diff --git a/ml_lme/ml_lme.csproj b/ml_lme/ml_lme.csproj index 25fb3c8..62a7c85 100644 --- a/ml_lme/ml_lme.csproj +++ b/ml_lme/ml_lme.csproj @@ -55,6 +55,10 @@ C:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll False + + D:\Games\Steam\steamapps\common\ChilloutVR\Mods\ml_pmc.dll + False + @@ -89,6 +93,7 @@ + diff --git a/ml_prm/Main.cs b/ml_prm/Main.cs index 24cb968..d997fb6 100644 --- a/ml_prm/Main.cs +++ b/ml_prm/Main.cs @@ -126,12 +126,12 @@ namespace ml_prm } static void OnSetupIKScaling_Postfix(ref UnityEngine.Vector3 ___scaleDifference) => ms_instance?.OnSetupIKScaling(___scaleDifference.y); - void OnSetupIKScaling(float scaleDifference) + void OnSetupIKScaling(float p_scaleDifference) { try { if (m_localController != null) - m_localController.OnAvatarScaling(1f + scaleDifference); + m_localController.OnAvatarScaling(1f + p_scaleDifference); } catch (Exception e) { diff --git a/ml_prm/ModUi.cs b/ml_prm/ModUi.cs index 1c50179..2a77f31 100644 --- a/ml_prm/ModUi.cs +++ b/ml_prm/ModUi.cs @@ -19,6 +19,7 @@ namespace ml_prm Slipperiness, Bounciness, ViewVelocity, + JumpRecover, VelocityMultiplier, MovementDrag, AngularDrag, @@ -77,6 +78,9 @@ namespace ml_prm ms_uiElements.Add(l_modCategory.AddToggle("View direction velocity", "Apply velocity to camera view direction", Settings.ViewVelocity)); (ms_uiElements[(int)UiIndex.ViewVelocity] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(UiIndex.ViewVelocity, state); + ms_uiElements.Add(l_modCategory.AddToggle("Jump recover", "Recover from ragdoll state by jumping", Settings.JumpRecover)); + (ms_uiElements[(int)UiIndex.JumpRecover] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(UiIndex.JumpRecover, state); + ms_uiElements.Add(l_modRoot.AddSlider("Velocity multiplier", "Velocity multiplier upon entering ragdoll state", Settings.VelocityMultiplier, 1f, 50f)); (ms_uiElements[(int)UiIndex.VelocityMultiplier] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => OnSliderUpdate(UiIndex.VelocityMultiplier, value); @@ -131,6 +135,10 @@ namespace ml_prm case UiIndex.ViewVelocity: Settings.SetSetting(Settings.ModSetting.ViewVelocity, p_state); break; + + case UiIndex.JumpRecover: + Settings.SetSetting(Settings.ModSetting.JumpRecover, p_state); + break; } if(p_force) @@ -173,6 +181,7 @@ namespace ml_prm OnToggleUpdate(UiIndex.Slipperiness, false, true); OnToggleUpdate(UiIndex.Bounciness, false, true); OnToggleUpdate(UiIndex.ViewVelocity, false, true); + OnToggleUpdate(UiIndex.JumpRecover, false, true); OnSliderUpdate(UiIndex.VelocityMultiplier, 2f, true); OnSliderUpdate(UiIndex.MovementDrag, 2f, true); OnSliderUpdate(UiIndex.AngularDrag, 2f, true); diff --git a/ml_prm/RagdollController.cs b/ml_prm/RagdollController.cs index 7091657..d78601c 100644 --- a/ml_prm/RagdollController.cs +++ b/ml_prm/RagdollController.cs @@ -133,25 +133,39 @@ namespace ml_prm } } - if(Settings.Hotkey && Input.GetKeyDown(KeyCode.R) && !ViewManager.Instance.isGameMenuOpen()) - SwitchRagdoll(); - if((m_avatarRagdollToggle != null) && m_avatarRagdollToggle.isActiveAndEnabled && m_avatarRagdollToggle.shouldOverride && (m_enabled != m_avatarRagdollToggle.isOn)) SwitchRagdoll(); if((m_customTrigger != null) && m_customTrigger.GetStateWithReset() && m_avatarReady && !m_enabled && Settings.PointersReaction) SwitchRagdoll(); + + if(Settings.Hotkey && Input.GetKeyDown(KeyCode.R) && !ViewManager.Instance.isGameMenuOpen()) + SwitchRagdoll(); + + if(m_avatarReady && m_enabled && CVRInputManager.Instance.jump && Settings.JumpRecover) + SwitchRagdoll(); } void LateUpdate() { - if(m_avatarReady && m_enabled && !BodySystem.isCalibrating) + if(m_avatarReady) { - if(BodySystem.isCalibratedAsFullBody) - BodySystem.TrackingPositionWeight = 0f; + if(m_enabled) + { + if(!BodySystem.isCalibrating) + { + if(BodySystem.isCalibratedAsFullBody) + BodySystem.TrackingPositionWeight = 0f; - foreach(var l_link in m_boneLinks) - l_link.Item1.CopyGlobal(l_link.Item2); + foreach(var l_link in m_boneLinks) + l_link.Item1.CopyGlobal(l_link.Item2); + } + } + else + { + foreach(var l_link in m_boneLinks) + l_link.Item2.CopyGlobal(l_link.Item1); + } } } @@ -287,15 +301,13 @@ namespace ml_prm } } - internal void OnAvatarScaling(float scaleDifference) + internal void OnAvatarScaling(float p_scaleDifference) { if(m_avatarReady) { - m_puppetRoot.localScale = Vector3.one * scaleDifference; - for(int i = 0; i < m_jointAnchors.Count; i++) - { - m_jointAnchors[i].Item1.connectedAnchor = m_jointAnchors[i].Item2 * scaleDifference; - } + m_puppetRoot.localScale = Vector3.one * p_scaleDifference; + foreach(var l_pair in m_jointAnchors) + l_pair.Item1.connectedAnchor = l_pair.Item2 * p_scaleDifference; } } @@ -437,10 +449,6 @@ namespace ml_prm if(!Utils.IsWorldSafe()) m_reachedGround = false; // Force player to unragdoll and reach ground first - // Copy before set to non-kinematic to reduce stacked forces - foreach(var l_link in m_boneLinks) - l_link.Item2.CopyGlobal(l_link.Item1); - m_puppetRoot.gameObject.SetActive(true); foreach(Rigidbody l_body in m_rigidBodies) diff --git a/ml_prm/Settings.cs b/ml_prm/Settings.cs index 5f6d824..e5d92f7 100644 --- a/ml_prm/Settings.cs +++ b/ml_prm/Settings.cs @@ -21,7 +21,8 @@ namespace ml_prm RecoverDelay, Slipperiness, Bounciness, - ViewVelocity + ViewVelocity, + JumpRecover } public static bool Hotkey { get; private set; } = true; @@ -37,6 +38,7 @@ namespace ml_prm public static bool Slipperiness { get; private set; } = false; public static bool Bounciness { get; private set; } = false; public static bool ViewVelocity { get; private set; } = false; + public static bool JumpRecover { get; private set; } = false; static public event Action HotkeyChange; static public event Action VelocityMultiplierChange; @@ -51,6 +53,7 @@ namespace ml_prm static public event Action SlipperinessChange; static public event Action BouncinessChange; static public event Action ViewVelocityChange; + static public event Action JumpRecoverChange; static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; @@ -72,7 +75,8 @@ namespace ml_prm ms_category.CreateEntry(ModSetting.RecoverDelay.ToString(), RecoverDelay), ms_category.CreateEntry(ModSetting.Slipperiness.ToString(), Slipperiness), ms_category.CreateEntry(ModSetting.Bounciness.ToString(), Bounciness), - ms_category.CreateEntry(ModSetting.ViewVelocity.ToString(), ViewVelocity) + ms_category.CreateEntry(ModSetting.ViewVelocity.ToString(), ViewVelocity), + ms_category.CreateEntry(ModSetting.JumpRecover.ToString(), JumpRecover) }; Hotkey = (bool)ms_entries[(int)ModSetting.Hotkey].BoxedValue; @@ -88,6 +92,7 @@ namespace ml_prm Slipperiness = (bool)ms_entries[(int)ModSetting.Slipperiness].BoxedValue; Bounciness = (bool)ms_entries[(int)ModSetting.Bounciness].BoxedValue; ViewVelocity = (bool)ms_entries[(int)ModSetting.ViewVelocity].BoxedValue; + JumpRecover = (bool)ms_entries[(int)ModSetting.JumpRecover].BoxedValue; } public static void SetSetting(ModSetting p_settings, object p_value) @@ -158,6 +163,13 @@ namespace ml_prm } break; + case ModSetting.JumpRecover: + { + JumpRecover = (bool)p_value; + JumpRecoverChange?.Invoke((bool)p_value); + } + break; + // Floats case ModSetting.VelocityMultiplier: {