VGRoid support (#27659)
* Dungeon spawn support for grid spawns * Recursive dungeons working * Mask approach working * zack * More work * Fix recursive dungeons * Heap of work * weh * the cud * rar * Job * weh * weh * weh * Master merges * orch * weh * vgroid most of the work * Tweaks * Tweaks * weh * do do do do do do * Basic layout * Ore spawning working * Big breaking changes * Mob gen working * weh * Finalising * emo * More finalising * reverty * Reduce distance
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
namespace Content.Shared.Procedural;
|
||||
|
||||
/// <summary>
|
||||
/// Procedurally generated dungeon data.
|
||||
/// </summary>
|
||||
public sealed class Dungeon
|
||||
{
|
||||
public readonly List<DungeonRoom> Rooms;
|
||||
public static Dungeon Empty = new Dungeon();
|
||||
|
||||
private List<DungeonRoom> _rooms;
|
||||
private HashSet<Vector2i> _allTiles = new();
|
||||
|
||||
public IReadOnlyList<DungeonRoom> Rooms => _rooms;
|
||||
|
||||
/// <summary>
|
||||
/// Hashset of the tiles across all rooms.
|
||||
@@ -17,18 +25,64 @@ public sealed class Dungeon
|
||||
|
||||
public readonly HashSet<Vector2i> Entrances = new();
|
||||
|
||||
public Dungeon()
|
||||
public IReadOnlySet<Vector2i> AllTiles => _allTiles;
|
||||
|
||||
public Dungeon() : this(new List<DungeonRoom>())
|
||||
{
|
||||
Rooms = new List<DungeonRoom>();
|
||||
}
|
||||
|
||||
public Dungeon(List<DungeonRoom> rooms)
|
||||
{
|
||||
Rooms = rooms;
|
||||
// This reftype is mine now.
|
||||
_rooms = rooms;
|
||||
|
||||
foreach (var room in Rooms)
|
||||
foreach (var room in _rooms)
|
||||
{
|
||||
Entrances.UnionWith(room.Entrances);
|
||||
InternalAddRoom(room);
|
||||
}
|
||||
|
||||
RefreshAllTiles();
|
||||
}
|
||||
|
||||
public void RefreshAllTiles()
|
||||
{
|
||||
_allTiles.Clear();
|
||||
_allTiles.UnionWith(RoomTiles);
|
||||
_allTiles.UnionWith(RoomExteriorTiles);
|
||||
_allTiles.UnionWith(CorridorTiles);
|
||||
_allTiles.UnionWith(CorridorExteriorTiles);
|
||||
_allTiles.UnionWith(Entrances);
|
||||
}
|
||||
|
||||
public void Rebuild()
|
||||
{
|
||||
_allTiles.Clear();
|
||||
|
||||
RoomTiles.Clear();
|
||||
RoomExteriorTiles.Clear();
|
||||
Entrances.Clear();
|
||||
|
||||
foreach (var room in _rooms)
|
||||
{
|
||||
InternalAddRoom(room, false);
|
||||
}
|
||||
|
||||
RefreshAllTiles();
|
||||
}
|
||||
|
||||
public void AddRoom(DungeonRoom room)
|
||||
{
|
||||
_rooms.Add(room);
|
||||
InternalAddRoom(room);
|
||||
}
|
||||
|
||||
private void InternalAddRoom(DungeonRoom room, bool refreshAll = true)
|
||||
{
|
||||
Entrances.UnionWith(room.Entrances);
|
||||
RoomTiles.UnionWith(room.Tiles);
|
||||
RoomExteriorTiles.UnionWith(room.Exterior);
|
||||
|
||||
if (refreshAll)
|
||||
RefreshAllTiles();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user