From 571ed150fef01bcda7d1ad56863fd9e719f758d5 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 10 Sep 2018 16:14:44 +0300 Subject: [PATCH] Ragdolls can't be dragged through walls or other colliders. Closes #772 --- .../Animation/HumanoidAnimController.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs index d503d7df7..965ddd280 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs @@ -1083,8 +1083,31 @@ namespace Barotrauma } } } + Limb pullLimb = i == 0 ? leftHand : rightHand; + if (GameMain.Client == null) + { + //stop dragging if there's something between the pull limb and the target limb + Vector2 sourceSimPos = pullLimb.SimPosition; + Vector2 targetSimPos = targetLimb.SimPosition; + if (character.Submarine != null && character.SelectedCharacter.Submarine == null) + { + targetSimPos -= character.Submarine.SimPosition; + } + else if (character.Submarine == null && character.SelectedCharacter.Submarine != null) + { + sourceSimPos -= character.SelectedCharacter.Submarine.SimPosition; + } + + var body = Submarine.CheckVisibility(sourceSimPos, targetSimPos, ignoreSubs: true); + if (body != null) + { + character.DeselectCharacter(); + return; + } + } + if (i == 1 && inWater) { targetLimb.pullJoint.Enabled = false;