From 96bc8a1cc9ed73586eabc866655d2d499176b31a Mon Sep 17 00:00:00 2001 From: SDraw Date: Wed, 15 Nov 2023 02:03:24 +0300 Subject: [PATCH] Fixed issue with fluid volumes --- ml_prm/Properties/AssemblyInfo.cs | 2 +- ml_prm/RagdollController.cs | 4 ++++ ml_prm/Utils.cs | 9 +++++++++ ml_prm/ml_prm.csproj | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ml_prm/Properties/AssemblyInfo.cs b/ml_prm/Properties/AssemblyInfo.cs index 169c7cd..72d550e 100644 --- a/ml_prm/Properties/AssemblyInfo.cs +++ b/ml_prm/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.1.0", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.1.1", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonPriority(2)] [assembly: MelonLoader.MelonOptionalDependencies("BTKUILib")] diff --git a/ml_prm/RagdollController.cs b/ml_prm/RagdollController.cs index 37aa858..11b7cf2 100644 --- a/ml_prm/RagdollController.cs +++ b/ml_prm/RagdollController.cs @@ -534,6 +534,7 @@ public void SwitchRagdoll() if(MovementSystem.Instance.flying) MovementSystem.Instance.ChangeFlight(false); MovementSystem.Instance.SetImmobilized(true); + MovementSystem.Instance.ClearFluidVolumes(); BodySystem.TrackingPositionWeight = 0f; m_applyHipsPosition = IKSystem.Instance.applyOriginalHipPosition; IKSystem.Instance.applyOriginalHipPosition = true; @@ -601,6 +602,9 @@ public void SwitchRagdoll() foreach(Rigidbody l_body in m_rigidBodies) l_body.isKinematic = true; + foreach(PhysicsInfluencer l_physicsInfluencer in m_physicsInfluencers) + l_physicsInfluencer.ClearFluidVolumes(); + m_lastPosition = PlayerSetup.Instance.transform.position; m_velocity = Vector3.zero; m_downTime = float.MinValue; diff --git a/ml_prm/Utils.cs b/ml_prm/Utils.cs index 5843122..22226e1 100644 --- a/ml_prm/Utils.cs +++ b/ml_prm/Utils.cs @@ -11,7 +11,10 @@ static class Utils { static readonly FieldInfo ms_groundedRaw = typeof(MovementSystem).GetField("_isGroundedRaw", BindingFlags.NonPublic | BindingFlags.Instance); static readonly FieldInfo ms_appliedGravity = typeof(MovementSystem).GetField("_appliedGravity", BindingFlags.NonPublic | BindingFlags.Instance); + static readonly FieldInfo ms_touchingVolumes = typeof(MovementSystem).GetField("_touchingVolumes", BindingFlags.NonPublic | BindingFlags.Instance); static readonly FieldInfo ms_referencePoints = typeof(PhysicsInfluencer).GetField("_referencePoints", BindingFlags.NonPublic | BindingFlags.Instance); + static readonly FieldInfo ms_influencerTouchingVolumes = typeof(PhysicsInfluencer).GetField("_touchingVolumes", BindingFlags.NonPublic | BindingFlags.Instance); + static readonly FieldInfo ms_influencerSubmergedColliders = typeof(PhysicsInfluencer).GetField("_submergedColliders", BindingFlags.NonPublic | BindingFlags.Instance); public static bool IsInVR() => ((CheckVR.Instance != null) && CheckVR.Instance.hasVrDeviceLoaded); public static bool IsWorldSafe() => ((CVRWorld.Instance != null) && CVRWorld.Instance.allowFlying); @@ -31,6 +34,7 @@ public static float GetWorldMovementLimit() public static bool IsGrounded(this MovementSystem p_instance) => (bool)ms_groundedRaw.GetValue(p_instance); public static Vector3 GetAppliedGravity(this MovementSystem p_instance) => (Vector3)ms_appliedGravity.GetValue(p_instance); public static void SetAppliedGravity(this MovementSystem p_instance, Vector3 p_vec) => ms_appliedGravity.SetValue(p_instance, p_vec); + public static void ClearFluidVolumes(this MovementSystem p_instance) => (ms_touchingVolumes.GetValue(p_instance) as List)?.Clear(); public static void CopyGlobal(this Transform p_source, Transform p_target) { @@ -42,5 +46,10 @@ public static bool IsReady(this PhysicsInfluencer p_instance) { return ((ms_referencePoints.GetValue(p_instance) as List).Count > 0); } + public static void ClearFluidVolumes(this PhysicsInfluencer p_instance) + { + (ms_influencerTouchingVolumes.GetValue(p_instance) as List)?.Clear(); + (ms_influencerSubmergedColliders.GetValue(p_instance) as Dictionary)?.Clear(); + } } } diff --git a/ml_prm/ml_prm.csproj b/ml_prm/ml_prm.csproj index b276fe1..e4fd07b 100644 --- a/ml_prm/ml_prm.csproj +++ b/ml_prm/ml_prm.csproj @@ -4,7 +4,7 @@ netstandard2.1 x64 PlayerRagdollMod - 1.1.0 + 1.1.1 SDraw None PlayerRagdollMod