- RepairTools work for structures that are outside the submarine
- Ruins are visible in sonar - Fixed ruin generation algorithm occasionally creating too narrow rooms and placing corridors so that they're blocked by corners of a room - Fix for wall textures being misaligned for map cells with no physics body
This commit is contained in:
@@ -440,11 +440,11 @@ namespace Barotrauma
|
||||
|
||||
foreach (VoronoiCell cell in cells)
|
||||
{
|
||||
if (cell.body == null) continue;
|
||||
//if (cell.body == null) continue;
|
||||
foreach (GraphEdge edge in cell.edges)
|
||||
{
|
||||
if (edge.cell1 != null && edge.cell1.body == null) edge.cell1 = null;
|
||||
if (edge.cell2 != null && edge.cell2.body == null) edge.cell2 = null;
|
||||
if (edge.cell1 != null && edge.cell1.body == null && edge.cell1.CellType != CellType.Empty) edge.cell1 = null;
|
||||
if (edge.cell2 != null && edge.cell2.body == null && edge.cell2.CellType != CellType.Empty) edge.cell2 = null;
|
||||
|
||||
CompareCCW compare = new CompareCCW(cell.Center);
|
||||
if (compare.Compare(edge.point1, edge.point2) == -1)
|
||||
@@ -463,22 +463,9 @@ namespace Barotrauma
|
||||
{
|
||||
if (!edge.isSolid) continue;
|
||||
|
||||
GraphEdge leftEdge = null, rightEdge = null;
|
||||
|
||||
foreach (GraphEdge edge2 in cell.edges)
|
||||
{
|
||||
if (edge == edge2) continue;
|
||||
if (edge.point1 == edge2.point1 ||
|
||||
edge.point1 == edge2.point2)
|
||||
{
|
||||
leftEdge = edge2;
|
||||
}
|
||||
else if (edge.point2 == edge2.point2 || edge.point2 == edge2.point1)
|
||||
{
|
||||
rightEdge = edge2;
|
||||
}
|
||||
}
|
||||
|
||||
GraphEdge leftEdge = cell.edges.Find(e => e != edge && (edge.point1 == e.point1 || edge.point1 == e.point2));
|
||||
GraphEdge rightEdge = cell.edges.Find(e => e != edge && (edge.point2 == e.point1 || edge.point2 == e.point2));
|
||||
|
||||
Vector2 leftNormal = Vector2.Zero, rightNormal = Vector2.Zero;
|
||||
|
||||
if (leftEdge == null)
|
||||
@@ -498,8 +485,11 @@ namespace Barotrauma
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Invalid right normal");
|
||||
#endif
|
||||
if (cell.body != null) GameMain.World.RemoveBody(cell.body);
|
||||
cell.body = null;
|
||||
if (cell.body != null)
|
||||
{
|
||||
GameMain.World.RemoveBody(cell.body);
|
||||
cell.body = null;
|
||||
}
|
||||
leftNormal = Vector2.UnitX;
|
||||
break;
|
||||
}
|
||||
@@ -521,15 +511,15 @@ namespace Barotrauma
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Invalid right normal");
|
||||
#endif
|
||||
if (cell.body != null) GameMain.World.RemoveBody(cell.body);
|
||||
cell.body = null;
|
||||
if (cell.body != null)
|
||||
{
|
||||
GameMain.World.RemoveBody(cell.body);
|
||||
cell.body = null;
|
||||
}
|
||||
rightNormal = Vector2.UnitX;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Vector2[] verts = new Vector2[3];
|
||||
|
||||
@@ -42,11 +42,12 @@ namespace Barotrauma.RuinGeneration
|
||||
this.rect = rect;
|
||||
}
|
||||
|
||||
public void Split(float minDivRatio, float verticalProbability = 0.5f)
|
||||
public void Split(float minDivRatio, float verticalProbability = 0.5f, int minWidth = 200)
|
||||
{
|
||||
subRooms = new BTRoom[2];
|
||||
|
||||
if (Rand.Range(0.0f, 1.0f, false) < verticalProbability)
|
||||
if (Rand.Range(0.0f, 1.0f, false) < verticalProbability &&
|
||||
rect.Width * minDivRatio >= minWidth)
|
||||
{
|
||||
SplitVertical(minDivRatio);
|
||||
}
|
||||
|
||||
@@ -163,16 +163,16 @@ namespace Barotrauma.RuinGeneration
|
||||
//if (Math.Min(leaves1[i].Rect.Bottom, leaves2[i].Rect.Bottom) - Math.Max(leaves1[i].Rect.Y, leaves2[j].Rect.Y) < width) continue;
|
||||
|
||||
|
||||
if (leaves1[i].Rect.Y > leaves2[j].Rect.Bottom) continue;
|
||||
if (leaves1[i].Rect.Bottom < leaves2[j].Rect.Y) continue;
|
||||
if (leaves1[i].Rect.Y > leaves2[j].Rect.Bottom-width) continue;
|
||||
if (leaves1[i].Rect.Bottom < leaves2[j].Rect.Y+width) continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (Math.Min(leaves1[i].Rect.Right, leaves2[i].Rect.Right) - Math.Max(leaves1[i].Rect.X, leaves2[j].Rect.X) < width) continue;
|
||||
|
||||
|
||||
if (leaves1[i].Rect.X > leaves2[j].Rect.Right) continue;
|
||||
if (leaves1[i].Rect.Right < leaves2[j].Rect.X) continue;
|
||||
if (leaves1[i].Rect.X > leaves2[j].Rect.Right-width) continue;
|
||||
if (leaves1[i].Rect.Right < leaves2[j].Rect.X+width) continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace Barotrauma.RuinGeneration
|
||||
protected set;
|
||||
}
|
||||
|
||||
public Vector2 Center
|
||||
{
|
||||
get { return rect.Center.ToVector2(); }
|
||||
}
|
||||
|
||||
public List<Line> Walls;
|
||||
|
||||
public virtual void CreateWalls() { }
|
||||
@@ -170,6 +175,11 @@ namespace Barotrauma.RuinGeneration
|
||||
get { return allShapes; }
|
||||
}
|
||||
|
||||
public List<Line> Walls
|
||||
{
|
||||
get { return walls; }
|
||||
}
|
||||
|
||||
public Rectangle Area
|
||||
{
|
||||
get;
|
||||
@@ -207,7 +217,7 @@ namespace Barotrauma.RuinGeneration
|
||||
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
rooms.ForEach(l => l.Split(0.3f, verticalProbability));
|
||||
rooms.ForEach(l => l.Split(0.3f, verticalProbability, 300));
|
||||
|
||||
rooms = baseRoom.GetLeaves();
|
||||
}
|
||||
@@ -340,6 +350,11 @@ namespace Barotrauma.RuinGeneration
|
||||
(int)((wall.B.X - wall.A.X) + radius*2.0f),
|
||||
(int)((wall.B.Y - wall.A.Y) + radius*2.0f));
|
||||
|
||||
if (wall.A.Y == wall.B.Y)
|
||||
{
|
||||
rect.Inflate(-32, 0);
|
||||
}
|
||||
|
||||
var structure = new Structure(rect, structurePrefab.Prefab as StructurePrefab, null);
|
||||
structure.MoveWithLevel = true;
|
||||
structure.SetCollisionCategory(Physics.CollisionLevel);
|
||||
|
||||
Reference in New Issue
Block a user