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:
metalgearsloth
2024-07-03 22:23:11 +10:00
committed by GitHub
parent 1faa1b5df6
commit a2f99cc69e
103 changed files with 4928 additions and 2627 deletions

View File

@@ -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();
}
}