From e5d4ea9d29d95ad79f403748ab5439c2e6206d5e Mon Sep 17 00:00:00 2001 From: SDraw Date: Sun, 11 Aug 2024 17:36:10 +0300 Subject: [PATCH] Minor change of grab state detection --- ml_prm/ModUi.cs | 2 +- ml_prm/README.md | 2 +- ml_prm/RemoteGestureHandler.cs | 4 ++-- ml_prm/Utils.cs | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ml_prm/ModUi.cs b/ml_prm/ModUi.cs index 616da80..49e3714 100644 --- a/ml_prm/ModUi.cs +++ b/ml_prm/ModUi.cs @@ -122,7 +122,7 @@ namespace ml_prm ms_fallDamageToggle = ms_category.AddToggle("Fall damage", "Enable ragdoll when falling from height", Settings.FallDamage); ms_fallDamageToggle.OnValueUpdated += (state) => OnToggleUpdate(UiIndex.FallDamage, state); - ms_gestureGrabToggle = ms_category.AddToggle("Gesture grab", "Enable grabbing of ragdolled body parts by remote players with trigger gesture

Warning: can lead to unpredictable physics behaviour in some cases", Settings.GestureGrab); + ms_gestureGrabToggle = ms_category.AddToggle("Gesture grab", "Enable grabbing of ragdolled body parts by remote players with trigger/grab gesture

Warning: can lead to unpredictable physics behaviour in some cases", Settings.GestureGrab); ms_gestureGrabToggle.OnValueUpdated += (state) => OnToggleUpdate(UiIndex.GestureGrab, state); ms_friendsGrabToggle = ms_category.AddToggle("Friends grab only", " ", Settings.FriendsGrab); diff --git a/ml_prm/README.md b/ml_prm/README.md index 7353c9f..20b8b31 100644 --- a/ml_prm/README.md +++ b/ml_prm/README.md @@ -29,7 +29,7 @@ Optional mod's settings page with [BTKUILib](https://github.com/BTK-Development/ * **Buoyancy:** enables floating in fluid volumes; `true` by default. * Note: Forcibly enabled in worlds that don't allow flight. * **Fall damage:** enables ragdoll when falling from specific height; `true` by default. -* **Gesture grab:** enables grabbing of ragdolled body parts by remote players with trigger gesture; `false` by default. +* **Gesture grab:** enables grabbing of ragdolled body parts by remote players with trigger/grab gesture; `false` by default. * Note: Can lead to unpredictable physics behaviour in some cases. * **Friends grab only:** Allow only friends to be able to grab your radgolled body parts; `true` by default. * **Velocity multiplier:** velocity force multiplier based on player's movement direction; `2.0` by default. diff --git a/ml_prm/RemoteGestureHandler.cs b/ml_prm/RemoteGestureHandler.cs index a946d8f..06c98f8 100644 --- a/ml_prm/RemoteGestureHandler.cs +++ b/ml_prm/RemoteGestureHandler.cs @@ -30,7 +30,7 @@ namespace ml_prm void Update() { - bool l_state = Mathf.Approximately(m_puppetMaster.PlayerAvatarMovementDataInput.AnimatorGestureLeft, 1f); + bool l_state = m_puppetMaster.IsLeftGrabPointerActive(); if(m_stateLeft != l_state) { m_stateLeft = l_state; @@ -38,7 +38,7 @@ namespace ml_prm OnGestureState.Invoke(m_puppetMaster, true, m_stateLeft); } - l_state = Mathf.Approximately(m_puppetMaster.PlayerAvatarMovementDataInput.AnimatorGestureRight, 1f); + l_state = m_puppetMaster.IsRightGrabPointerActive(); if(m_stateRight != l_state) { m_stateRight = l_state; diff --git a/ml_prm/Utils.cs b/ml_prm/Utils.cs index 17a85b0..b98c19b 100644 --- a/ml_prm/Utils.cs +++ b/ml_prm/Utils.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Reflection; using UnityEngine; using System.Linq; +using ABI_RC.Systems.IK.SubSystems; namespace ml_prm { @@ -43,5 +44,19 @@ namespace ml_prm } public static bool IsInEnumeration(object p_obj, object[] p_enumeration) => p_enumeration.Contains(p_obj); + + public static bool IsLeftGrabPointerActive(this PuppetMaster p_source) + { + bool l_result = ((p_source._playerAvatarMovementDataCurrent.AnimatorGestureLeft >= 0.5f) && (p_source._playerAvatarMovementDataCurrent.AnimatorGestureLeft <= 1f)); + l_result |= ((FingerSystem.GetCurlNormalized(p_source._playerAvatarMovementDataCurrent.LeftMiddle1Stretched) >= 0.5f) && (FingerSystem.GetCurlNormalized(p_source._playerAvatarMovementDataCurrent.LeftMiddle2Stretched) >= 0.5f) && (FingerSystem.GetCurlNormalized(p_source._playerAvatarMovementDataCurrent.LeftMiddle3Stretched) >= 0.5f)); + return l_result; + } + + public static bool IsRightGrabPointerActive(this PuppetMaster p_source) + { + bool l_result = ((p_source._playerAvatarMovementDataCurrent.AnimatorGestureRight >= 0.5f) && (p_source._playerAvatarMovementDataCurrent.AnimatorGestureRight <= 1f)); + l_result |= ((FingerSystem.GetCurlNormalized(p_source._playerAvatarMovementDataCurrent.RightMiddle1Stretched) >= 0.5f) && (FingerSystem.GetCurlNormalized(p_source._playerAvatarMovementDataCurrent.RightMiddle2Stretched) >= 0.5f) && (FingerSystem.GetCurlNormalized(p_source._playerAvatarMovementDataCurrent.RightMiddle3Stretched) >= 0.5f)); + return l_result; + } } }