Skip to content

Commit

Permalink
Fixed issue with fluid volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
SDraw committed Nov 14, 2023
1 parent b10b434 commit 96bc8a1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ml_prm/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down
4 changes: 4 additions & 0 deletions ml_prm/RagdollController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions ml_prm/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<FluidVolume>)?.Clear();

public static void CopyGlobal(this Transform p_source, Transform p_target)
{
Expand All @@ -42,5 +46,10 @@ public static bool IsReady(this PhysicsInfluencer p_instance)
{
return ((ms_referencePoints.GetValue(p_instance) as List<Vector3>).Count > 0);
}
public static void ClearFluidVolumes(this PhysicsInfluencer p_instance)
{
(ms_influencerTouchingVolumes.GetValue(p_instance) as List<FluidVolume>)?.Clear();
(ms_influencerSubmergedColliders.GetValue(p_instance) as Dictionary<FluidVolume, int>)?.Clear();
}
}
}
2 changes: 1 addition & 1 deletion ml_prm/ml_prm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<Platforms>x64</Platforms>
<PackageId>PlayerRagdollMod</PackageId>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
<Authors>SDraw</Authors>
<Company>None</Company>
<Product>PlayerRagdollMod</Product>
Expand Down

0 comments on commit 96bc8a1

Please sign in to comment.