Level generation fix: voronoiCell collision is disabled if any of it's edges intersects with any part of an alien ruin
+ SalvageMission attempts to place artifacts in artifact holders
This commit is contained in:
@@ -54,6 +54,24 @@ namespace Barotrauma
|
|||||||
item = new Item(itemPrefab, position, null);
|
item = new Item(itemPrefab, position, null);
|
||||||
item.MoveWithLevel = true;
|
item.MoveWithLevel = true;
|
||||||
item.body.FarseerBody.IsKinematic = true;
|
item.body.FarseerBody.IsKinematic = true;
|
||||||
|
|
||||||
|
if (item.HasTag("alien"))
|
||||||
|
{
|
||||||
|
//try to find a nearby artifact holder (or any alien itemcontainer) and place the artifact inside it
|
||||||
|
foreach (Item it in Item.ItemList)
|
||||||
|
{
|
||||||
|
if (it.Submarine != null || !it.HasTag("alien")) continue;
|
||||||
|
|
||||||
|
if (Math.Abs(item.WorldPosition.X - it.WorldPosition.X) > 2000.0f) continue;
|
||||||
|
if (Math.Abs(item.WorldPosition.Y - it.WorldPosition.Y) > 2000.0f) continue;
|
||||||
|
|
||||||
|
var itemContainer = it.GetComponent<Items.Components.ItemContainer>();
|
||||||
|
if (itemContainer == null) continue;
|
||||||
|
|
||||||
|
itemContainer.Combine(item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float deltaTime)
|
public override void Update(float deltaTime)
|
||||||
|
|||||||
@@ -743,10 +743,18 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
var tooClose = GetTooCloseCells(ruinShape.Rect.Center.ToVector2(), Math.Max(ruinShape.Rect.Width, ruinShape.Rect.Height));
|
var tooClose = GetTooCloseCells(ruinShape.Rect.Center.ToVector2(), Math.Max(ruinShape.Rect.Width, ruinShape.Rect.Height));
|
||||||
|
|
||||||
tooClose.ForEach(c =>
|
foreach (VoronoiCell cell in tooClose)
|
||||||
{
|
{
|
||||||
if (c.edges.Any(e => ruinShape.Rect.Contains(e.point1) || ruinShape.Rect.Contains(e.point2))) c.CellType = CellType.Empty;
|
if (cell.CellType == CellType.Empty) continue;
|
||||||
});
|
foreach (GraphEdge e in cell.edges)
|
||||||
|
{
|
||||||
|
if (MathUtils.GetLineRectangleIntersection(e.point1, e.point2, ruinShape.Rect) != null)
|
||||||
|
{
|
||||||
|
cell.CellType = CellType.Empty;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,12 +165,12 @@ namespace Barotrauma
|
|||||||
GUI.DrawLine(spriteBatch,
|
GUI.DrawLine(spriteBatch,
|
||||||
new Vector2(cell.edges[0].point1.X, -cell.edges[0].point1.Y),
|
new Vector2(cell.edges[0].point1.X, -cell.edges[0].point1.Y),
|
||||||
new Vector2(cell.Center.X, -cell.Center.Y),
|
new Vector2(cell.Center.X, -cell.Center.Y),
|
||||||
Color.White);
|
Color.Blue*0.5f);
|
||||||
|
|
||||||
foreach (GraphEdge edge in cell.edges)
|
foreach (GraphEdge edge in cell.edges)
|
||||||
{
|
{
|
||||||
GUI.DrawLine(spriteBatch, new Vector2(edge.point1.X, -edge.point1.Y),
|
GUI.DrawLine(spriteBatch, new Vector2(edge.point1.X, -edge.point1.Y),
|
||||||
new Vector2(edge.point2.X, -edge.point2.Y), cell.body==null ? Color.Gray : Color.White);
|
new Vector2(edge.point2.X, -edge.point2.Y), cell.body==null ? Color.Cyan*0.5f : Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Vector2 point in cell.bodyVertices)
|
foreach (Vector2 point in cell.bodyVertices)
|
||||||
|
|||||||
Reference in New Issue
Block a user