Camera twitching fixes, fixed crashing when loading a sub with no hull, fixed server lobby player count only working for 0-15 players, progress on downloading subs from the server

This commit is contained in:
Regalis
2016-02-25 22:54:10 +02:00
parent b081891dc6
commit 77d3d22810
14 changed files with 464 additions and 229 deletions
+32 -27
View File
@@ -713,37 +713,42 @@ namespace Barotrauma
}
}
Vector2 topLeft = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y);
Vector2 bottomRight = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y);
foreach (Hull hull in Hull.hullList)
Vector2 center = Vector2.Zero;
if (Hull.hullList.Any())
{
if (hull.Rect.X < topLeft.X) topLeft.X = hull.Rect.X;
if (hull.Rect.Y > topLeft.Y) topLeft.Y = hull.Rect.Y;
if (hull.Rect.Right > bottomRight.X) bottomRight.X = hull.Rect.Right;
if (hull.Rect.Y - hull.Rect.Height < bottomRight.Y) bottomRight.Y = hull.Rect.Y - hull.Rect.Height;
}
Vector2 center = (topLeft + bottomRight) / 2.0f;
center.X -= center.X % GridSize.X;
center.Y -= center.Y % GridSize.Y;
foreach (Item item in Item.ItemList)
{
var wire = item.GetComponent<Items.Components.Wire>();
if (wire == null) continue;
for (int i = 0; i < wire.Nodes.Count; i++)
Vector2 topLeft = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y);
Vector2 bottomRight = new Vector2(Hull.hullList[0].Rect.X, Hull.hullList[0].Rect.Y);
foreach (Hull hull in Hull.hullList)
{
wire.Nodes[i] -= center;
}
}
if (hull.Rect.X < topLeft.X) topLeft.X = hull.Rect.X;
if (hull.Rect.Y > topLeft.Y) topLeft.Y = hull.Rect.Y;
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (MapEntity.mapEntityList[i].Submarine == null) continue;
if (hull.Rect.Right > bottomRight.X) bottomRight.X = hull.Rect.Right;
if (hull.Rect.Y - hull.Rect.Height < bottomRight.Y) bottomRight.Y = hull.Rect.Y - hull.Rect.Height;
}
center = (topLeft + bottomRight) / 2.0f;
center.X -= center.X % GridSize.X;
center.Y -= center.Y % GridSize.Y;
foreach (Item item in Item.ItemList)
{
var wire = item.GetComponent<Items.Components.Wire>();
if (wire == null) continue;
for (int i = 0; i < wire.Nodes.Count; i++)
{
wire.Nodes[i] -= center;
}
}
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (MapEntity.mapEntityList[i].Submarine == null) continue;
MapEntity.mapEntityList[i].Move(-center);
MapEntity.mapEntityList[i].Move(-center);
}
}
subBody = new SubmarineBody(this);
+14 -7
View File
@@ -226,25 +226,32 @@ namespace Barotrauma
if (dist > 1000.0f)
{
Vector2 moveAmount = ConvertUnits.ToSimUnits((Vector2)targetPosition) - body.Position;
Vector2 displayerMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
Vector2 displayMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
body.SetTransform(body.Position + moveAmount, 0.0f);
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayerMoveAmount;
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayMoveAmount;
GameMain.GameScreen.Cam.Position += displayerMoveAmount;
GameMain.GameScreen.Cam.UpdateTransform();
GameMain.GameScreen.Cam.Position += displayMoveAmount;
if (GameMain.GameScreen.Cam.TargetPos!=Vector2.Zero) GameMain.GameScreen.Cam.TargetPos += displayMoveAmount;
GameMain.GameScreen.Cam.UpdateTransform(false);
submarine.SetPrevTransform(submarine.Position);
submarine.UpdateTransform();
targetPosition = null;
}
else if (dist > 50.0f)
{
Vector2 moveAmount = Vector2.Normalize((Vector2)targetPosition - Position);
moveAmount *= ConvertUnits.ToSimUnits(Math.Min(dist, 100.0f));
Vector2 displayerMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
Vector2 displayMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
body.SetTransform(body.Position + moveAmount * deltaTime, 0.0f);
GameMain.GameScreen.Cam.Position += displayerMoveAmount * deltaTime;
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayerMoveAmount;
GameMain.GameScreen.Cam.Position += displayMoveAmount * deltaTime;
if (GameMain.GameScreen.Cam.TargetPos != Vector2.Zero) GameMain.GameScreen.Cam.TargetPos += displayMoveAmount;
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayMoveAmount;
//GameMain.GameScreen.Cam.UpdateTransform(false);
}
else
{