Fixed camera being placed at {-2147483647, -2147483647} when starting a round, fixed debugdraw crashing the game, moving spectator camera along with the closest sub in Submarine.ForceTranslate

This commit is contained in:
Regalis
2016-10-08 17:19:54 +03:00
parent e50b801a47
commit 1ba87165b0
4 changed files with 18 additions and 10 deletions
+14 -8
View File
@@ -268,16 +268,22 @@ namespace Barotrauma
{
Body.SetTransform(Body.Position + ConvertUnits.ToSimUnits(amount), 0.0f);
if (Character.Controlled != null)
bool isClosestSub = false;
if (Character.Controlled == null)
{
Character.Controlled.CursorPosition += amount;
isClosestSub = Submarine.GetClosest(GameMain.GameScreen.Cam.WorldViewCenter) == submarine;
}
else
{
isClosestSub = Character.Controlled.Submarine == submarine;
if (Character.Controlled.Submarine == submarine ||
(Character.Controlled == null && Submarine.GetClosest(GameMain.GameScreen.Cam.WorldViewCenter) == submarine))
{
GameMain.GameScreen.Cam.Position += amount;
if (GameMain.GameScreen.Cam.TargetPos != Vector2.Zero) GameMain.GameScreen.Cam.TargetPos += amount;
}
Character.Controlled.CursorPosition += amount;
}
if (isClosestSub)
{
GameMain.GameScreen.Cam.Position += amount;
if (GameMain.GameScreen.Cam.TargetPos != Vector2.Zero) GameMain.GameScreen.Cam.TargetPos += amount;
}
}