From 6c538443fdc876adc014c3566fbe8557abcedc9c Mon Sep 17 00:00:00 2001 From: Regalis Date: Fri, 22 Apr 2016 17:21:34 +0300 Subject: [PATCH] - characters aren't teleported through gaps if a wall doesn't have a hole there - characters aren't teleported outside until they're far enough from hulls (prevents them from "jumping" outside as they're teleported partially inside the body of the sub) - arms are mirrored/flipped when turning in water --- .../Animation/HumanoidAnimController.cs | 4 ++-- .../Source/Characters/Animation/Ragdoll.cs | 19 +++++++------------ Subsurface/Source/Characters/Character.cs | 3 ++- Subsurface/Source/Map/SubmarineBody.cs | 7 +++++++ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs index eb6f9cdfe..2bf8b162b 100644 --- a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs @@ -1151,8 +1151,8 @@ namespace Barotrauma case LimbType.LeftArm: case LimbType.RightHand: case LimbType.RightArm: - mirror = !inWater; - flipAngle = !inWater; + mirror = true; + flipAngle = true; break; case LimbType.LeftThigh: case LimbType.LeftLeg: diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs index f7fddcf91..fcf7c7eb4 100644 --- a/Subsurface/Source/Characters/Animation/Ragdoll.cs +++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs @@ -560,17 +560,15 @@ namespace Barotrauma { if (newHull == null && currentHull.Submarine != null) { - //if there's a hull right above and below the position, don't teleport outside the sub - //(the character is most likely inside some small gap between hulls) - if (Hull.FindHull(findPos + Vector2.UnitY * Submarine.GridSize.Y * 2.0f, currentHull) != null && - Hull.FindHull(findPos - Vector2.UnitY * Submarine.GridSize.Y * 2.0f, currentHull) != null) return; - - if (Hull.FindHull(findPos + Vector2.UnitX * Submarine.GridSize.X * 2.0f, currentHull) != null && - Hull.FindHull(findPos - Vector2.UnitX * Submarine.GridSize.X * 2.0f, currentHull) != null) return; - + for (int i = -1; i < 2; i += 2) + { + //don't teleport outside the sub if right next to a hull + if (Hull.FindHull(findPos + new Vector2(Submarine.GridSize.X * 2.0f * i, 0.0f), currentHull) != null) return; + if (Hull.FindHull(findPos + new Vector2(0.0f, Submarine.GridSize.Y * 2.0f * i), currentHull) != null) return; + } Vector2 ragdollSpeed = refLimb.LinearVelocity == Vector2.Zero ? Vector2.Zero : Vector2.Normalize(refLimb.LinearVelocity); - SetPosition(refLimb.SimPosition + ragdollSpeed + ConvertUnits.ToSimUnits(currentHull.Submarine.Position)); + SetPosition(refLimb.SimPosition + ConvertUnits.ToSimUnits(currentHull.Submarine.Position)); character.CursorPosition += currentHull.Submarine.Position; } else if (currentHull == null && newHull != null && newHull.Submarine != null) @@ -703,9 +701,6 @@ namespace Barotrauma splashSoundTimer = 0.5f; } - - - //1.0 when the limb is parallel to the surface of the water // = big splash and a large impact float parallel = (float)Math.Abs(Math.Sin(limb.Rotation)); diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index e948afa6d..793f3fa94 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -971,8 +971,9 @@ namespace Barotrauma foreach (Item item in inventory.Items) { if (item == null || item.body == null || item.body.Enabled) continue; - item.Submarine = Submarine; + item.SetTransform(SimPosition, 0.0f); + item.Submarine = Submarine; } } diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs index 57e586dca..8e9e39e1b 100644 --- a/Subsurface/Source/Map/SubmarineBody.cs +++ b/Subsurface/Source/Map/SubmarineBody.cs @@ -450,6 +450,13 @@ namespace Barotrauma foreach (Gap gap in Gap.GapList) { if (gap.Open == 0.0f || gap.IsRoomToRoom) continue; + + if (gap.ConnectedWall != null) + { + int sectionIndex = gap.ConnectedWall.FindSectionIndex(gap.Position); + if (sectionIndex > -1 && !gap.ConnectedWall.SectionBodyDisabled(sectionIndex)) continue; + } + if (gap.isHorizontal) { if (targetPos.Y < gap.WorldRect.Y && targetPos.Y > gap.WorldRect.Y - gap.WorldRect.Height &&