Unstable v0.15.17.0 (Hex is out of town edition)

This commit is contained in:
Juan Pablo Arce
2021-12-03 13:31:10 -03:00
parent cd5c8f3e13
commit 617d9ede88
245 changed files with 8088 additions and 5842 deletions
@@ -159,7 +159,7 @@ namespace Barotrauma
DebugConsole.ThrowError($"Error while removing entity \"{e}\"", exception);
GameAnalyticsManager.AddErrorEventOnce(
$"Entity.RemoveAll:Exception{e}",
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
GameAnalyticsManager.ErrorSeverity.Error,
$"Error while removing entity \"{e} ({exception.Message})\n{exception.StackTrace.CleanupStackTrace()}");
}
}
@@ -223,7 +223,7 @@ namespace Barotrauma
{
DebugConsole.ThrowError(errorLine);
}
GameAnalyticsManager.AddErrorEventOnce("Entity.RemoveAll", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg.ToString());
GameAnalyticsManager.AddErrorEventOnce("Entity.RemoveAll", GameAnalyticsManager.ErrorSeverity.Error, errorMsg.ToString());
}
dictionary.Clear();
@@ -243,14 +243,14 @@ namespace Barotrauma
DebugConsole.ThrowError($"Entity {ToString()} ({ID}) not present in entity dictionary.");
GameAnalyticsManager.AddErrorEventOnce(
$"Entity.FreeID:EntityNotFound{ID}",
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
GameAnalyticsManager.ErrorSeverity.Error,
$"Entity {ToString()} ({ID}) not present in entity dictionary.\n{Environment.StackTrace.CleanupStackTrace()}");
}
else if (existingEntity != this)
{
DebugConsole.ThrowError($"Entity ID mismatch in entity dictionary. Entity {existingEntity} had the ID {ID} (expecting {ToString()})");
GameAnalyticsManager.AddErrorEventOnce("Entity.FreeID:EntityMismatch" + ID,
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
GameAnalyticsManager.ErrorSeverity.Error,
$"Entity ID mismatch in entity dictionary. Entity {existingEntity} had the ID {ID} (expecting {ToString()})");
}
else
@@ -1575,7 +1575,7 @@ namespace Barotrauma
{
string errorMsg = "Error - tried to save a hull that's not a part of any submarine.\n" + Environment.StackTrace.CleanupStackTrace();
DebugConsole.ThrowError(errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Hull.Save:WorldHull", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Hull.Save:WorldHull", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
return null;
}
@@ -440,7 +440,7 @@ namespace Barotrauma
DebugConsole.ThrowError("Invalid triangle created by CaveGenerator (" + triangles[i][0] + ", " + triangles[i][1] + ", " + triangles[i][2] + ")");
GameAnalyticsManager.AddErrorEventOnce(
"CaveGenerator.GeneratePolygons:InvalidTriangle",
GameAnalyticsSDK.Net.EGAErrorSeverity.Warning,
GameAnalyticsManager.ErrorSeverity.Warning,
"Invalid triangle created by CaveGenerator (" + triangles[i][0] + ", " + triangles[i][1] + ", " + triangles[i][2] + "). Seed: " + level.Seed);
}
}
@@ -954,6 +954,13 @@ namespace Barotrauma
{
for (int i = 0; i < cavePathCells.Count; i++)
{
var connectingEdge = i > 0 ? cavePathCells[i].Edges.Find(e => e.AdjacentCell(cavePathCells[i]) == cavePathCells[i - 1]) : null;
if (connectingEdge != null)
{
var edgeWayPoint = new WayPoint(connectingEdge.Center, SpawnType.Path, submarine: null);
ConnectWaypoints(prevWp, edgeWayPoint, 500.0f);
prevWp = edgeWayPoint;
}
var newWaypoint = new WayPoint(cavePathCells[i].Center, SpawnType.Path, submarine: null);
ConnectWaypoints(prevWp, newWaypoint, 500.0f);
prevWp = newWaypoint;
@@ -1382,6 +1389,7 @@ namespace Barotrauma
if (tunnel.Cells.Count == 0) { return; }
List<WayPoint> wayPoints = new List<WayPoint>();
WayPoint prevWayPoint = null;
for (int i = 0; i < tunnel.Cells.Count; i++)
{
tunnel.Cells[i].CellType = CellType.Path;
@@ -1391,10 +1399,58 @@ namespace Barotrauma
};
wayPoints.Add(newWaypoint);
if (wayPoints.Count > 1)
if (prevWayPoint != null)
{
wayPoints[wayPoints.Count - 2].ConnectTo(newWaypoint);
bool solidCellBetween = false;
foreach (GraphEdge edge in tunnel.Cells[i].Edges)
{
if (edge.AdjacentCell(tunnel.Cells[i])?.CellType == CellType.Solid &&
MathUtils.LinesIntersect(newWaypoint.WorldPosition, prevWayPoint.WorldPosition, edge.Point1, edge.Point2))
{
solidCellBetween = true;
break;
}
}
if (solidCellBetween)
{
//something between the previous waypoint and this one
// -> find the edge that connects the cells and place a waypoint there, instead of connecting the centers of the cells directly
var edgeBetweenCells = tunnel.Cells[i].Edges.Find(e => e.AdjacentCell(tunnel.Cells[i]) == tunnel.Cells[i - 1]);
if (edgeBetweenCells != null)
{
var edgeWaypoint = new WayPoint(new Rectangle((int)edgeBetweenCells.Center.X, (int)edgeBetweenCells.Center.Y, 10, 10), null)
{
Tunnel = tunnel
};
prevWayPoint.ConnectTo(edgeWaypoint);
prevWayPoint = edgeWaypoint;
}
}
prevWayPoint.ConnectTo(newWaypoint);
//look back at the tunnel cells before the previous one, and see if the current cell shares edges with them
//= if we can "skip" from cell #1 to cell #3, create a waypoint between them.
//Fixes there sometimes not being a path past a destructible ice chunk even if there's space to go past it.
for (int j = i - 2; j > 0 && j > i - 5; j--)
{
foreach (GraphEdge edge in tunnel.Cells[i].Edges)
{
if (Vector2.DistanceSquared(edge.Point1, edge.Point2) < 30.0f * 30.0f) { continue; }
if (!edge.IsSolid && edge.AdjacentCell(tunnel.Cells[i]) == tunnel.Cells[j])
{
var edgeWaypoint = new WayPoint(new Rectangle((int)edge.Center.X, (int)edge.Center.Y, 10, 10), null)
{
Tunnel = tunnel
};
wayPoints[j].ConnectTo(edgeWaypoint);
edgeWaypoint.ConnectTo(newWaypoint);
break;
}
}
}
}
prevWayPoint = newWaypoint;
}
tunnel.WayPoints.AddRange(wayPoints);
@@ -1954,6 +2010,8 @@ namespace Barotrauma
wayPoints.RemoveAt(i);
}
Debug.Assert(wayPoints.Any(), "Couldn't generate waypoints around ruins.");
//connect ruin entrances to the outside waypoints
foreach (Gap g in Gap.GapList)
{
@@ -1997,6 +2055,13 @@ namespace Barotrauma
{
for (int i = 0; i < ruin.PathCells.Count; i++)
{
var connectingEdge = i > 0 ? ruin.PathCells[i].Edges.Find(e => e.AdjacentCell(ruin.PathCells[i]) == ruin.PathCells[i - 1]) : null;
if (connectingEdge != null)
{
var edgeWayPoint = new WayPoint(connectingEdge.Center, SpawnType.Path, submarine: null);
ConnectWaypoints(prevWp, edgeWayPoint, outSideWaypointInterval);
prevWp = edgeWayPoint;
}
var newWaypoint = new WayPoint(ruin.PathCells[i].Center, SpawnType.Path, submarine: null);
ConnectWaypoints(prevWp, newWaypoint, outSideWaypointInterval);
prevWp = newWaypoint;
@@ -2947,7 +3012,7 @@ namespace Barotrauma
if (!suitablePositions.Any())
{
string errorMsg = "Could not find a suitable position of interest. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + ")\n" + Environment.StackTrace.CleanupStackTrace();
GameAnalyticsManager.AddErrorEventOnce("Level.TryGetInterestingPosition:PositionTypeNotFound", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Level.TryGetInterestingPosition:PositionTypeNotFound", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
#if DEBUG
DebugConsole.ThrowError(errorMsg);
#endif
@@ -2972,7 +3037,7 @@ namespace Barotrauma
if (!farEnoughPositions.Any())
{
string errorMsg = "Could not find a position of interest far enough from the submarines. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + ")\n" + Environment.StackTrace.CleanupStackTrace();
GameAnalyticsManager.AddErrorEventOnce("Level.TryGetInterestingPosition:TooCloseToSubs", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Level.TryGetInterestingPosition:TooCloseToSubs", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
#if DEBUG
DebugConsole.ThrowError(errorMsg);
#endif
@@ -3084,7 +3149,25 @@ namespace Barotrauma
foreach (LevelWall wall in ExtraWalls)
{
if (wall is DestructibleLevelWall destructibleWall && destructibleWall.Destroyed) { continue; }
if (wall == SeaFloor)
{
if (SeaFloorTopPos < worldPos.Y - searchDepth * GridCellSize) { continue; }
}
else
{
if (wall is DestructibleLevelWall destructibleWall && destructibleWall.Destroyed) { continue; }
bool closeEnough = false;
foreach (VoronoiCell cell in wall.Cells)
{
if (Math.Abs(cell.Center.X - worldPos.X) < (searchDepth + 1) * GridCellSize &&
Math.Abs(cell.Center.Y - worldPos.Y) < (searchDepth + 1) * GridCellSize)
{
closeEnough = true;
break;
}
}
if (!closeEnough) { continue; }
}
foreach (VoronoiCell cell in wall.Cells)
{
tempCells.Add(cell);
@@ -3739,7 +3822,7 @@ namespace Barotrauma
subDockingPortOffset = MathHelper.Clamp(subDockingPortOffset, -5000.0f, 5000.0f);
string warningMsg = "Docking port very far from the sub's center of mass (submarine: " + Submarine.MainSub.Info.Name + ", dist: " + subDockingPortOffset + "). The level generator may not be able to place the outpost so that docking is possible.";
DebugConsole.NewMessage(warningMsg, Color.Orange);
GameAnalyticsManager.AddErrorEventOnce("Lever.CreateOutposts:DockingPortVeryFar" + Submarine.MainSub.Info.Name, GameAnalyticsSDK.Net.EGAErrorSeverity.Warning, warningMsg);
GameAnalyticsManager.AddErrorEventOnce("Lever.CreateOutposts:DockingPortVeryFar" + Submarine.MainSub.Info.Name, GameAnalyticsManager.ErrorSeverity.Warning, warningMsg);
}
float outpostDockingPortOffset = subPort == null ? 0.0f : outpostPort.Item.WorldPosition.X - outpost.WorldPosition.X;
@@ -3749,7 +3832,7 @@ namespace Barotrauma
outpostDockingPortOffset = MathHelper.Clamp(outpostDockingPortOffset, -5000.0f, 5000.0f);
string warningMsg = "Docking port very far from the outpost's center of mass (outpost: " + outpost.Info.Name + ", dist: " + outpostDockingPortOffset + "). The level generator may not be able to place the outpost so that docking is possible.";
DebugConsole.NewMessage(warningMsg, Color.Orange);
GameAnalyticsManager.AddErrorEventOnce("Lever.CreateOutposts:OutpostDockingPortVeryFar" + outpost.Info.Name, GameAnalyticsSDK.Net.EGAErrorSeverity.Warning, warningMsg);
GameAnalyticsManager.AddErrorEventOnce("Lever.CreateOutposts:OutpostDockingPortVeryFar" + outpost.Info.Name, GameAnalyticsManager.ErrorSeverity.Warning, warningMsg);
}
Vector2 spawnPos = outpost.FindSpawnPos(i == 0 ? StartPosition : EndPosition, minSize, subDockingPortOffset - outpostDockingPortOffset, verticalMoveDir: 1);
@@ -764,7 +764,7 @@ namespace Barotrauma
{
string errorMsg = "Failed to select a location. " + (location?.Name ?? "null") + " not found in the map.";
DebugConsole.ThrowError(errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Map.SelectLocation:LocationNotFound", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Map.SelectLocation:LocationNotFound", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
return;
}
@@ -783,7 +783,7 @@ namespace Barotrauma
{
string errorMsg = "Failed to select a mission (current location not set).";
DebugConsole.ThrowError(errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Map.SelectMission:CurrentLocationNotSet", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Map.SelectMission:CurrentLocationNotSet", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
return;
}
@@ -386,7 +386,7 @@ namespace Barotrauma
DebugConsole.ThrowError("Cloning entity \"" + e.Name + "\" failed.", ex);
GameAnalyticsManager.AddErrorEventOnce(
"MapEntity.Clone:" + e.Name,
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
GameAnalyticsManager.ErrorSeverity.Error,
"Cloning entity \"" + e.Name + "\" failed (" + ex.Message + ").\n" + ex.StackTrace.CleanupStackTrace());
return clones;
}
@@ -447,7 +447,7 @@ namespace Barotrauma
{
DebugConsole.ThrowError("Error while cloning wires - item \"" + connectedItem.Name + "\" was not found in entities to clone.");
GameAnalyticsManager.AddErrorEventOnce("MapEntity.Clone:ConnectedNotFound" + connectedItem.ID,
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
GameAnalyticsManager.ErrorSeverity.Error,
"Error while cloning wires - item \"" + connectedItem.Name + "\" was not found in entities to clone.");
continue;
}
@@ -458,7 +458,7 @@ namespace Barotrauma
{
DebugConsole.ThrowError("Error while cloning wires - connection \"" + originalWire.Connections[n].Name + "\" was not found in connected item \"" + connectedItem.Name + "\".");
GameAnalyticsManager.AddErrorEventOnce("MapEntity.Clone:ConnectionNotFound" + connectedItem.ID,
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
GameAnalyticsManager.ErrorSeverity.Error,
"Error while cloning wires - connection \"" + originalWire.Connections[n].Name + "\" was not found in connected item \"" + connectedItem.Name + "\".");
continue;
}
@@ -1407,7 +1407,7 @@ namespace Barotrauma
{
string errorMsg = $"Error while loading structure \"{s.Name}\". Section damage index out of bounds. Index: {index}, section count: {s.SectionCount}.";
DebugConsole.ThrowError(errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Structure.Load:SectionIndexOutOfBounds", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Structure.Load:SectionIndexOutOfBounds", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
}
else
{
@@ -137,6 +137,9 @@ namespace Barotrauma
get { return subBody?.Body; }
}
/// <summary>
/// Extents of the solid items/structures (ones with a physics body) and hulls
/// </summary>
public Rectangle Borders
{
get
@@ -145,6 +148,17 @@ namespace Barotrauma
}
}
/// <summary>
/// Extents of all the visible items/structures/hulls (including ones without a physics body)
/// </summary>
public Rectangle VisibleBorders
{
get
{
return subBody == null ? Rectangle.Empty : subBody.VisibleBorders;
}
}
public override Vector2 Position
{
get { return subBody == null ? Vector2.Zero : subBody.Position - HiddenSubPosition; }
@@ -68,12 +68,24 @@ namespace Barotrauma
}
}
/// <summary>
/// Extents of the solid items/structures (ones with a physics body) and hulls
/// </summary>
public Rectangle Borders
{
get;
private set;
}
/// <summary>
/// Extents of all the visible items/structures/hulls (including ones without a physics body)
/// </summary>
public Rectangle VisibleBorders
{
get;
private set;
}
public Vector2 Velocity
{
get { return Body.LinearVelocity; }
@@ -122,14 +134,21 @@ namespace Barotrauma
HullVertices = convexHull;
Vector2 minExtents = Vector2.Zero, maxExtents = Vector2.Zero;
Vector2 visibleMinExtents = Vector2.Zero, visibleMaxExtents = Vector2.Zero;
farseerBody = GameMain.World.CreateBody();
farseerBody.UserData = this;
foreach (Structure wall in Structure.WallList)
foreach (var mapEntity in MapEntity.mapEntityList)
{
if (wall.Submarine != submarine || wall.IsPlatform) { continue; }
if (mapEntity.Submarine != submarine || !(mapEntity is Structure wall)) { continue; }
Rectangle rect = wall.Rect;
visibleMinExtents.X = Math.Min(rect.X, visibleMinExtents.X);
visibleMinExtents.Y = Math.Min(rect.Y - rect.Height, visibleMinExtents.Y);
visibleMaxExtents.X = Math.Max(rect.Right, visibleMaxExtents.X);
visibleMaxExtents.Y = Math.Max(rect.Y, visibleMaxExtents.Y);
if (!wall.HasBody || wall.IsPlatform || wall.StairDirection != Direction.None) { continue; }
farseerBody.CreateRectangle(
ConvertUnits.ToSimUnits(wall.BodyWidth),
@@ -138,10 +157,10 @@ namespace Barotrauma
-wall.BodyRotation,
ConvertUnits.ToSimUnits(new Vector2(rect.X + rect.Width / 2, rect.Y - rect.Height / 2) + wall.BodyOffset)).UserData = wall;
minExtents.X = Math.Min(rect.X, minExtents.X);
minExtents.Y = Math.Min(rect.Y - rect.Height, minExtents.Y);
maxExtents.X = Math.Max(rect.Right, maxExtents.X);
maxExtents.Y = Math.Max(rect.Y, maxExtents.Y);
minExtents.X = Math.Min(visibleMinExtents.X, minExtents.X);
minExtents.Y = Math.Min(visibleMinExtents.Y, minExtents.Y);
maxExtents.X = Math.Max(visibleMaxExtents.X, maxExtents.X);
maxExtents.Y = Math.Max(visibleMaxExtents.Y, maxExtents.Y);
}
foreach (Hull hull in Hull.hullList)
@@ -155,14 +174,20 @@ namespace Barotrauma
100.0f,
ConvertUnits.ToSimUnits(new Vector2(rect.X + rect.Width / 2, rect.Y - rect.Height / 2))).UserData = hull;
minExtents.X = Math.Min(rect.X, minExtents.X);
minExtents.Y = Math.Min(rect.Y - rect.Height, minExtents.Y);
maxExtents.X = Math.Max(rect.Right, maxExtents.X);
maxExtents.Y = Math.Max(rect.Y, maxExtents.Y);
visibleMinExtents.X = Math.Min(rect.X, visibleMinExtents.X);
visibleMinExtents.Y = Math.Min(rect.Y - rect.Height, visibleMinExtents.Y);
visibleMaxExtents.X = Math.Max(rect.Right, visibleMaxExtents.X);
visibleMaxExtents.Y = Math.Max(rect.Y, visibleMaxExtents.Y);
minExtents.X = Math.Min(visibleMinExtents.X, minExtents.X);
minExtents.Y = Math.Min(visibleMinExtents.Y, minExtents.Y);
maxExtents.X = Math.Max(visibleMaxExtents.X, maxExtents.X);
maxExtents.Y = Math.Max(visibleMaxExtents.Y, maxExtents.Y);
}
foreach (Item item in Item.ItemList)
{
if (item.Submarine != submarine) { continue; }
if (item.StaticBodyConfig == null || item.Submarine != submarine) { continue; }
float radius = item.StaticBodyConfig.GetAttributeFloat("radius", 0.0f) * item.Scale;
@@ -183,43 +208,48 @@ namespace Barotrauma
{
item.StaticFixtures.Add(farseerBody.CreateRectangle(simWidth, simHeight, 5.0f, simPos));
minExtents.X = Math.Min(item.Position.X - width / 2, minExtents.X);
minExtents.Y = Math.Min(item.Position.Y - height / 2, minExtents.Y);
maxExtents.X = Math.Max(item.Position.X + width / 2, maxExtents.X);
maxExtents.Y = Math.Max(item.Position.Y + height / 2, maxExtents.Y);
visibleMinExtents.X = Math.Min(item.Position.X - width / 2, visibleMinExtents.X);
visibleMinExtents.Y = Math.Min(item.Position.Y - height / 2, visibleMinExtents.Y);
visibleMaxExtents.X = Math.Max(item.Position.X + width / 2, visibleMaxExtents.X);
visibleMaxExtents.Y = Math.Max(item.Position.Y + height / 2, visibleMaxExtents.Y);
}
else if (radius > 0.0f && width > 0.0f)
{
item.StaticFixtures.Add(farseerBody.CreateRectangle(simWidth, simRadius * 2, 5.0f, simPos));
item.StaticFixtures.Add(farseerBody.CreateCircle(simRadius, 5.0f, simPos - Vector2.UnitX * simWidth / 2));
item.StaticFixtures.Add(farseerBody.CreateCircle(simRadius, 5.0f, simPos + Vector2.UnitX * simWidth / 2));
minExtents.X = Math.Min(item.Position.X - width / 2 - radius, minExtents.X);
minExtents.Y = Math.Min(item.Position.Y - radius, minExtents.Y);
maxExtents.X = Math.Max(item.Position.X + width / 2 + radius, maxExtents.X);
maxExtents.Y = Math.Max(item.Position.Y + radius, maxExtents.Y);
visibleMinExtents.X = Math.Min(item.Position.X - width / 2 - radius, visibleMinExtents.X);
visibleMinExtents.Y = Math.Min(item.Position.Y - radius, visibleMinExtents.Y);
visibleMaxExtents.X = Math.Max(item.Position.X + width / 2 + radius, visibleMaxExtents.X);
visibleMaxExtents.Y = Math.Max(item.Position.Y + radius, visibleMaxExtents.Y);
}
else if (radius > 0.0f && height > 0.0f)
{
item.StaticFixtures.Add(farseerBody.CreateRectangle(simRadius * 2, height, 5.0f, simPos));
item.StaticFixtures.Add(farseerBody.CreateCircle(simRadius, 5.0f, simPos - Vector2.UnitY * simHeight / 2));
item.StaticFixtures.Add(farseerBody.CreateCircle(simRadius, 5.0f, simPos + Vector2.UnitX * simHeight / 2));
minExtents.X = Math.Min(item.Position.X - radius, minExtents.X);
minExtents.Y = Math.Min(item.Position.Y - height / 2 - radius, minExtents.Y);
maxExtents.X = Math.Max(item.Position.X + radius, maxExtents.X);
maxExtents.Y = Math.Max(item.Position.Y + height / 2 + radius, maxExtents.Y);
visibleMinExtents.X = Math.Min(item.Position.X - radius, visibleMinExtents.X);
visibleMinExtents.Y = Math.Min(item.Position.Y - height / 2 - radius, visibleMinExtents.Y);
visibleMaxExtents.X = Math.Max(item.Position.X + radius, visibleMaxExtents.X);
visibleMaxExtents.Y = Math.Max(item.Position.Y + height / 2 + radius, visibleMaxExtents.Y);
}
else if (radius > 0.0f)
{
item.StaticFixtures.Add(farseerBody.CreateCircle(simRadius, 5.0f, simPos));
minExtents.X = Math.Min(item.Position.X - radius, minExtents.X);
minExtents.Y = Math.Min(item.Position.Y - radius, minExtents.Y);
maxExtents.X = Math.Max(item.Position.X + radius, maxExtents.X);
maxExtents.Y = Math.Max(item.Position.Y + radius, maxExtents.Y);
visibleMinExtents.X = Math.Min(item.Position.X - radius, visibleMinExtents.X);
visibleMinExtents.Y = Math.Min(item.Position.Y - radius, visibleMinExtents.Y);
visibleMaxExtents.X = Math.Max(item.Position.X + radius, visibleMaxExtents.X);
visibleMaxExtents.Y = Math.Max(item.Position.Y + radius, visibleMaxExtents.Y);
}
item.StaticFixtures.ForEach(f => f.UserData = item);
minExtents.X = Math.Min(visibleMinExtents.X, minExtents.X);
minExtents.Y = Math.Min(visibleMinExtents.Y, minExtents.Y);
maxExtents.X = Math.Max(visibleMaxExtents.X, maxExtents.X);
maxExtents.Y = Math.Max(visibleMaxExtents.Y, maxExtents.Y);
}
Borders = new Rectangle((int)minExtents.X, (int)maxExtents.Y, (int)(maxExtents.X - minExtents.X), (int)(maxExtents.Y - minExtents.Y));
VisibleBorders = new Rectangle((int)visibleMinExtents.X, (int)visibleMaxExtents.Y, (int)(visibleMaxExtents.X - visibleMinExtents.X), (int)(visibleMaxExtents.Y - visibleMinExtents.Y));
}
farseerBody.BodyType = BodyType.Dynamic;
@@ -660,7 +690,7 @@ namespace Barotrauma
{
GameAnalyticsManager.AddErrorEventOnce(
"SubmarineBody.HandleLimbCollision:" + submarine.ID,
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
GameAnalyticsManager.ErrorSeverity.Error,
"Invalid velocity change in SubmarineBody.HandleLimbCollision (submarine velocity: " + Body.LinearVelocity
+ ", avgContactNormal: " + avgContactNormal
+ ", contactDot: " + contactDot
@@ -835,7 +865,7 @@ namespace Barotrauma
if (GameSettings.VerboseLogging) DebugConsole.ThrowError(errorMsg);
GameAnalyticsManager.AddErrorEventOnce(
"SubmarineBody.ApplyImpact:InvalidImpulse",
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
GameAnalyticsManager.ErrorSeverity.Error,
errorMsg);
return;
}