From 8919bf5c10cbf673f3985b4a9f10f23833b215ff Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 26 Apr 2019 11:18:47 +0300 Subject: [PATCH] (2cf47ee24) Cherry pick some steering fixes from the human-ai branch: fix ladder usage while swimming. --- .../Source/Characters/AI/IndoorsSteeringManager.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs index e1109f83f..e264c0f05 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs @@ -218,13 +218,13 @@ namespace Barotrauma } else if (character.Submarine != currentPath.CurrentNode.Submarine) { - pos -= FarseerPhysics.ConvertUnits.ToSimUnits(currentPath.CurrentNode.Submarine.Position-character.Submarine.Position); + pos -= FarseerPhysics.ConvertUnits.ToSimUnits(currentPath.CurrentNode.Submarine.Position - character.Submarine.Position); } } } //only humanoids can climb ladders - if (character.AnimController is HumanoidAnimController && IsNextLadderSameAsCurrent) + if (!character.AnimController.InWater && character.AnimController is HumanoidAnimController && IsNextLadderSameAsCurrent) { if (character.SelectedConstruction != currentPath.CurrentNode.Ladders.Item && currentPath.CurrentNode.Ladders.Item.IsInsideTrigger(character.WorldPosition)) @@ -234,7 +234,7 @@ namespace Barotrauma } var collider = character.AnimController.Collider; - if (character.IsClimbing) + if (character.IsClimbing && !character.AnimController.InWater) { Vector2 diff = currentPath.CurrentNode.SimPosition - pos; bool nextLadderSameAsCurrent = IsNextLadderSameAsCurrent; @@ -278,6 +278,12 @@ namespace Barotrauma } else if (character.AnimController.InWater) { + // If the character is underwater, we don't need the ladders anymore + if (character.IsClimbing) + { + character.AnimController.Anim = AnimController.Animation.None; + character.SelectedConstruction = null; + } if (Vector2.DistanceSquared(pos, currentPath.CurrentNode.SimPosition) < MathUtils.Pow(collider.radius * 3, 2)) { currentPath.SkipToNextNode();