Struct MapRoom<TCoord>
Represents a single room (contiguous floor region) detected in a procedurally generated
map. Rooms are produced during the post-processing flood-fill pass when
DetectRooms is true, and are collected in
Rooms.
For BSP and Room-and-Corridor algorithms, rooms correspond directly to the rectangular areas carved by the algorithm. For organic algorithms (Drunkard's Walk, Cellular Automata, Noise Threshold, Voronoi, Maze), rooms represent the connected components identified by the flood-fill pass and may have irregular shapes.
Room IDs are sequential integers assigned in flood-fill discovery order starting from
0, so Rooms[n].ID == n always holds for results produced by
ProceduralMapGenerator. This makes it safe to reference rooms from
MapCorridor<TCoord> by index into the
Rooms list.
Inherited Members
Namespace: Scylla.Core.Util.ProceduralMapGen
Assembly: ScyllaCore.dll
Syntax
public readonly struct MapRoom<TCoord> where TCoord : struct, IEquatable<TCoord>
Type Parameters
| Name | Description |
|---|---|
| TCoord | The grid coordinate type used by the map. Must be a value type implementing
IEquatable<T>. Common choices are |
Constructors
MapRoom(int, TCoord, TCoord, TCoord, List<TCoord>)
Initializes a new MapRoom<TCoord> with the specified metadata. This constructor is called internally by ProceduralMapGenerator algorithms and is generally not needed in consumer code.
Declaration
public MapRoom(int id, TCoord min, TCoord max, TCoord center, List<TCoord> cells)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The unique room identifier. Should match the index of this room in Rooms. |
| TCoord | min | The minimum bounding box coordinate, encompassing the axially smallest values across all room cells. |
| TCoord | max | The maximum bounding box coordinate, encompassing the axially largest values across all room cells. |
| TCoord | center | The approximate center coordinate, closest to the geometric midpoint of the bounding box. |
| List<TCoord> | cells | All grid coordinates belonging to this room. Must not be |
Fields
Cells
The complete list of all grid coordinates belonging to this room, in flood-fill discovery order. Every coordinate in this list has been written to the map grid with a value matching FloorValue (or CorridorValue for corridor cells that are part of a merged floor component) at the time the result is returned.
The list will never be null for rooms produced by ProceduralMapGenerator,
and will contain at least one cell. The count of this list equals the area (in cells)
of this room, which can be used for filtering out small rooms or computing fill ratios.
Declaration
public readonly List<TCoord> Cells
Field Value
| Type | Description |
|---|---|
| List<TCoord> |
Center
The approximate center of this room, computed as the cell whose coordinate is closest to the geometric midpoint of the bounding box defined by Min and Max. Because rooms may have irregular shapes, the center cell is not guaranteed to belong to Cells - it is the closest grid-aligned coordinate to the mathematical center, not necessarily a passable floor cell.
For rectangular rooms produced by BSP or Room-and-Corridor algorithms, the center will reliably fall inside the room. For organic rooms from cave generators, verify membership via Cells if a guaranteed passable center is required.
Corridor carving algorithms use room center coordinates as the start and end points when computing corridor paths between rooms.
Declaration
public readonly TCoord Center
Field Value
| Type | Description |
|---|---|
| TCoord |
ID
The unique integer identifier for this room within its containing
MapGenResult<TCoord>. IDs are assigned sequentially starting from
0 in flood-fill discovery order, so this value is also a valid index into
Rooms. MapCorridor<TCoord>
references use this ID to identify which rooms a corridor connects.
Declaration
public readonly int ID
Field Value
| Type | Description |
|---|---|
| int |
Max
The maximum (top-right for square grids, or axially largest for hex/tri grids) bounding box coordinate of this room. Together with Min, this defines an axis-aligned bounding box that encloses all cells in Cells.
For square grids, Max is the coordinate with the largest column and row values in the cell set. For hex and triangle grids, each axis component of Max holds the maximum value along that axis across all room cells.
Declaration
public readonly TCoord Max
Field Value
| Type | Description |
|---|---|
| TCoord |
Min
The minimum (bottom-left for square grids, or axially smallest for hex/tri grids) bounding box coordinate of this room. Together with Max, this defines an axis-aligned bounding box that encloses all cells in Cells.
For square grids, Min is the coordinate with the smallest column and row values in the cell set. For hex and triangle grids, each axis component of Min holds the minimum value along that axis across all room cells.
Rooms with irregular (non-rectangular) shapes may have bounding boxes that include cells not belonging to the room. Use Cells for precise membership testing.
Declaration
public readonly TCoord Min
Field Value
| Type | Description |
|---|---|
| TCoord |
Methods
ToString()
Returns a human-readable string representation of this room for debugging purposes, including its ID, approximate center coordinate, and total cell count.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string of the form |