Autopilot uses submarine position as a "reference position" (instead of the position of the nav terminal), radar display bugfix, ragdolls aren't teleported outside the sub if they're in a tiny gap between hulls (e.g. passing through a broken wall between rooms)

This commit is contained in:
Regalis
2016-04-20 17:28:20 +03:00
parent 188220c464
commit e271873a43
4 changed files with 64 additions and 48 deletions
@@ -560,6 +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;
Vector2 ragdollSpeed = refLimb.LinearVelocity == Vector2.Zero ? Vector2.Zero : Vector2.Normalize(refLimb.LinearVelocity);
SetPosition(refLimb.SimPosition + ragdollSpeed + ConvertUnits.ToSimUnits(currentHull.Submarine.Position));
character.CursorPosition += currentHull.Submarine.Position;