RoomSpawner mask (#33110)
* RoolFill can now spaw rooms with any size * tile ignoring * upgrade interior * simplify * Update DungeonSystem.Rooms.cs * center rooms * Update RoomFillComponent.cs * Update RoomFillComponent.cs * Update DungeonSystem.Rooms.cs * Remove roomfillcoponent from integration test * Update EntityTest.cs * remove nullable size, replaced with minsize and maxsize * clear existing logic refactor * delete this one
This commit is contained in:
@@ -17,9 +17,20 @@ public sealed partial class DungeonSystem
|
||||
private readonly List<DungeonRoomPrototype> _availableRooms = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a random dungeon room matching the specified area and whitelist.
|
||||
/// Gets a random dungeon room matching the specified area, whitelist and size.
|
||||
/// </summary>
|
||||
public DungeonRoomPrototype? GetRoomPrototype(Vector2i size, Random random, EntityWhitelist? whitelist = null)
|
||||
{
|
||||
return GetRoomPrototype(random, whitelist, minSize: size, maxSize: size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a random dungeon room matching the specified area and whitelist and size range
|
||||
/// </summary>
|
||||
public DungeonRoomPrototype? GetRoomPrototype(Random random,
|
||||
EntityWhitelist? whitelist = null,
|
||||
Vector2i? minSize = null,
|
||||
Vector2i? maxSize = null)
|
||||
{
|
||||
// Can never be true.
|
||||
if (whitelist is { Tags: null })
|
||||
@@ -31,7 +42,10 @@ public sealed partial class DungeonSystem
|
||||
|
||||
foreach (var proto in _prototype.EnumeratePrototypes<DungeonRoomPrototype>())
|
||||
{
|
||||
if (proto.Size != size)
|
||||
if (minSize is not null && (proto.Size.X < minSize.Value.X || proto.Size.Y < minSize.Value.Y))
|
||||
continue;
|
||||
|
||||
if (maxSize is not null && (proto.Size.X > maxSize.Value.X || proto.Size.Y > maxSize.Value.Y))
|
||||
continue;
|
||||
|
||||
if (whitelist == null)
|
||||
@@ -115,29 +129,6 @@ public sealed partial class DungeonSystem
|
||||
|
||||
var finalRoomRotation = roomTransform.Rotation();
|
||||
|
||||
// go BRRNNTTT on existing stuff
|
||||
if (clearExisting)
|
||||
{
|
||||
var gridBounds = new Box2(Vector2.Transform(-room.Size/2, roomTransform), Vector2.Transform(room.Size/2, roomTransform));
|
||||
_entitySet.Clear();
|
||||
// Polygon skin moment
|
||||
gridBounds = gridBounds.Enlarged(-0.05f);
|
||||
_lookup.GetLocalEntitiesIntersecting(gridUid, gridBounds, _entitySet, LookupFlags.Uncontained);
|
||||
|
||||
foreach (var templateEnt in _entitySet)
|
||||
{
|
||||
Del(templateEnt);
|
||||
}
|
||||
|
||||
if (TryComp(gridUid, out DecalGridComponent? decalGrid))
|
||||
{
|
||||
foreach (var decal in _decals.GetDecalsIntersecting(gridUid, gridBounds, decalGrid))
|
||||
{
|
||||
_decals.RemoveDecal(gridUid, decal.Index, decalGrid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var roomCenter = (room.Offset + room.Size / 2f) * grid.TileSize;
|
||||
var tileOffset = -roomCenter + grid.TileSizeHalfVector;
|
||||
_tiles.Clear();
|
||||
@@ -156,7 +147,22 @@ public sealed partial class DungeonSystem
|
||||
if (!clearExisting && reservedTiles?.Contains(rounded) == true)
|
||||
continue;
|
||||
|
||||
if (room.IgnoreTile is not null)
|
||||
{
|
||||
if (_maps.TryGetTileDef(templateGrid, indices, out var tileDef) && room.IgnoreTile == tileDef.ID)
|
||||
continue;
|
||||
}
|
||||
|
||||
_tiles.Add((rounded, tileRef.Tile));
|
||||
|
||||
if (clearExisting)
|
||||
{
|
||||
var anchored = _maps.GetAnchoredEntities((gridUid, grid), rounded);
|
||||
foreach (var ent in anchored)
|
||||
{
|
||||
QueueDel(ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user