Fixed ruin props being placed on ruin doors, which occasionally caused artifact holders and artifacts to appear inside the doors.
Closes #72
This commit is contained in:
@@ -344,51 +344,9 @@ namespace Barotrauma.RuinGeneration
|
|||||||
Rectangle backgroundRect = new Rectangle(leaf.Rect.X, leaf.Rect.Y + leaf.Rect.Height, leaf.Rect.Width, leaf.Rect.Height);
|
Rectangle backgroundRect = new Rectangle(leaf.Rect.X, leaf.Rect.Y + leaf.Rect.Height, leaf.Rect.Width, leaf.Rect.Height);
|
||||||
|
|
||||||
new Structure(backgroundRect, (background.Prefab as StructurePrefab), null).MoveWithLevel = true;
|
new Structure(backgroundRect, (background.Prefab as StructurePrefab), null).MoveWithLevel = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//generate props --------------------------------------------------------------
|
List<RuinShape> doorlessRooms = new List<RuinShape>(shapes);
|
||||||
for (int i = 0; i < shapes.Count*2; i++ )
|
|
||||||
{
|
|
||||||
Alignment[] alignments = new Alignment[] { Alignment.Top, Alignment.Bottom, Alignment.Right, Alignment.Left, Alignment.Center };
|
|
||||||
|
|
||||||
var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, Rand.RandSync.Server)]);
|
|
||||||
|
|
||||||
Vector2 size = (prop.Prefab is StructurePrefab) ? ((StructurePrefab)prop.Prefab).Size : Vector2.Zero;
|
|
||||||
|
|
||||||
var shape = shapes[Rand.Int(shapes.Count, Rand.RandSync.Server)];
|
|
||||||
|
|
||||||
Vector2 position = shape.Rect.Center.ToVector2();
|
|
||||||
if (prop.Alignment.HasFlag(Alignment.Top))
|
|
||||||
{
|
|
||||||
position = new Vector2(Rand.Range(shape.Rect.X+size.X, shape.Rect.Right - size.X, Rand.RandSync.Server), shape.Rect.Bottom - 64);
|
|
||||||
}
|
|
||||||
else if (prop.Alignment.HasFlag(Alignment.Bottom))
|
|
||||||
{
|
|
||||||
position = new Vector2(Rand.Range(shape.Rect.X + size.X, shape.Rect.Right - size.X, Rand.RandSync.Server), shape.Rect.Top + 64);
|
|
||||||
}
|
|
||||||
else if (prop.Alignment.HasFlag(Alignment.Right))
|
|
||||||
{
|
|
||||||
position = new Vector2(shape.Rect.Right - 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, Rand.RandSync.Server));
|
|
||||||
}
|
|
||||||
else if (prop.Alignment.HasFlag(Alignment.Left))
|
|
||||||
{
|
|
||||||
position = new Vector2(shape.Rect.X + 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, Rand.RandSync.Server));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prop.Prefab is ItemPrefab)
|
|
||||||
{
|
|
||||||
var item = new Item((ItemPrefab)prop.Prefab, position, null);
|
|
||||||
item.MoveWithLevel = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
new Structure(new Rectangle(
|
|
||||||
(int)(position.X - size.X/2.0f), (int)(position.Y + size.Y/2.0f),
|
|
||||||
(int)size.X, (int)size.Y),
|
|
||||||
prop.Prefab as StructurePrefab, null).MoveWithLevel = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//generate doors & sensors that close them -------------------------------------------------------------
|
//generate doors & sensors that close them -------------------------------------------------------------
|
||||||
|
|
||||||
@@ -406,6 +364,7 @@ namespace Barotrauma.RuinGeneration
|
|||||||
|
|
||||||
if (!suitableWalls.Any()) continue;
|
if (!suitableWalls.Any()) continue;
|
||||||
|
|
||||||
|
doorlessRooms.Remove(corridor);
|
||||||
Vector2 doorPos = corridor.Center;
|
Vector2 doorPos = corridor.Center;
|
||||||
|
|
||||||
//choose a random wall to place the door next to
|
//choose a random wall to place the door next to
|
||||||
@@ -446,6 +405,53 @@ namespace Barotrauma.RuinGeneration
|
|||||||
wire.Connect(conn2, false);
|
wire.Connect(conn2, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//generate props --------------------------------------------------------------
|
||||||
|
for (int i = 0; i < shapes.Count*2; i++ )
|
||||||
|
{
|
||||||
|
Alignment[] alignments = new Alignment[] { Alignment.Top, Alignment.Bottom, Alignment.Right, Alignment.Left, Alignment.Center };
|
||||||
|
|
||||||
|
var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, Rand.RandSync.Server)]);
|
||||||
|
|
||||||
|
Vector2 size = (prop.Prefab is StructurePrefab) ? ((StructurePrefab)prop.Prefab).Size : Vector2.Zero;
|
||||||
|
|
||||||
|
//if the prop is placed at the center of the room, we have to use a room without a door (because they're also placed at the center)
|
||||||
|
var shape = prop.Alignment.HasFlag(Alignment.Center) ?
|
||||||
|
doorlessRooms[Rand.Int(doorlessRooms.Count, Rand.RandSync.Server)] :
|
||||||
|
shapes[Rand.Int(shapes.Count, Rand.RandSync.Server)];
|
||||||
|
|
||||||
|
Vector2 position = shape.Rect.Center.ToVector2();
|
||||||
|
if (prop.Alignment.HasFlag(Alignment.Top))
|
||||||
|
{
|
||||||
|
position = new Vector2(Rand.Range(shape.Rect.X+size.X, shape.Rect.Right - size.X, Rand.RandSync.Server), shape.Rect.Bottom - 64);
|
||||||
|
}
|
||||||
|
else if (prop.Alignment.HasFlag(Alignment.Bottom))
|
||||||
|
{
|
||||||
|
position = new Vector2(Rand.Range(shape.Rect.X + size.X, shape.Rect.Right - size.X, Rand.RandSync.Server), shape.Rect.Top + 64);
|
||||||
|
}
|
||||||
|
else if (prop.Alignment.HasFlag(Alignment.Right))
|
||||||
|
{
|
||||||
|
position = new Vector2(shape.Rect.Right - 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, Rand.RandSync.Server));
|
||||||
|
}
|
||||||
|
else if (prop.Alignment.HasFlag(Alignment.Left))
|
||||||
|
{
|
||||||
|
position = new Vector2(shape.Rect.X + 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, Rand.RandSync.Server));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop.Prefab is ItemPrefab)
|
||||||
|
{
|
||||||
|
var item = new Item((ItemPrefab)prop.Prefab, position, null);
|
||||||
|
item.MoveWithLevel = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new Structure(new Rectangle(
|
||||||
|
(int)(position.X - size.X/2.0f), (int)(position.Y + size.Y/2.0f),
|
||||||
|
(int)size.X, (int)size.Y),
|
||||||
|
prop.Prefab as StructurePrefab, null).MoveWithLevel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return shapes;
|
return shapes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user