Struct MazeRoomSettings
Settings for the Maze-with-Rooms composite map generation algorithm, invoked via ProceduralMapGenerator. Generates a maze backbone first using MazeSettings and then carves rectangular rooms into the grid. Multiple RoomGroup entries allow mixing different room sizes in a single generation pass; all groups share a global overlap-check list so rooms never overlap. A post-processing step connects every carved room back to the maze passage network.
Inherited Members
Namespace: Scylla.Core.Util.ProceduralMapGen
Assembly: ScyllaCore.dll
Syntax
public readonly struct MazeRoomSettings
Remarks
The algorithm proceeds in three phases:
- Maze generation - a perfect maze is generated using the Recursive Backtracker algorithm and then optionally modified by the dead-end removal and loop creation passes configured in MazeSettings.
- Room placement - for each RoomGroup in RoomGroups, the algorithm attempts to place Count rooms of random size within the group's [MinWidth-MaxWidth] × [MinHeight-MaxHeight] range. Each room is placed at a random position; if it would overlap an existing room (respecting MinRoomSpacing) the attempt is discarded and retried up to MaxPlacementAttempts times.
- Room connection - each successfully placed room is connected to the nearest maze passage by carving a short tunnel from the room boundary.
Use the static presets (Default, ManySmall,
FewLarge, Mixed) as starting points. All fields
are readonly; use Lerp(MazeRoomSettings, MazeRoomSettings, float) to smoothly transition between
configurations.
Constructors
MazeRoomSettings(MazeSettings, RoomGroup[], int, int)
Initializes a new MazeRoomSettings with explicit control over all maze backbone, room group, spacing, and attempt limit parameters.
Declaration
public MazeRoomSettings(MazeSettings mazeSettings, RoomGroup[] roomGroups, int minRoomSpacing = 1, int maxPlacementAttempts = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| MazeSettings | mazeSettings | Maze backbone settings controlling dead-end removal and loop creation. |
| RoomGroup[] | roomGroups | Array of room groups defining the count and size range for each category of rooms
to place. May be |
| int | minRoomSpacing | Minimum number of wall cells required between any two room edges to prevent
overlap. Defaults to |
| int | maxPlacementAttempts | Maximum number of random placement attempts per individual room before it is
skipped. Defaults to |
Fields
Default
A balanced preset that places four medium rooms (5-9 cells wide and tall) into an imperfect maze with some dead-end removal and a few loops.
Declaration
public static readonly MazeRoomSettings Default
Field Value
| Type | Description |
|---|---|
| MazeRoomSettings |
Remarks
Specific values: MazeSettings=MazeSettings.Imperfect,
RoomGroups=[RoomGroup(4, 5, 5, 9, 9)],
MinRoomSpacing=1, MaxPlacementAttempts=100.
FewLarge
Places a small number of large rooms (7-11 cells wide and tall) into an open, heavily modified maze with many loops. Produces spacious chambers interconnected by a well-connected network of passages.
Declaration
public static readonly MazeRoomSettings FewLarge
Field Value
| Type | Description |
|---|---|
| MazeRoomSettings |
Remarks
Specific values: MazeSettings=MazeSettings.Open,
RoomGroups=[RoomGroup(3, 7, 7, 11, 11)],
MinRoomSpacing=2, MaxPlacementAttempts=200.
ManySmall
Places many small rooms (3-5 cells wide and tall) into a lightly modified maze. Produces a tight, labyrinthine dungeon filled with small chambers connected by narrow passages.
Declaration
public static readonly MazeRoomSettings ManySmall
Field Value
| Type | Description |
|---|---|
| MazeRoomSettings |
Remarks
Specific values: MazeSettings=(0.2, 0.1),
RoomGroups=[RoomGroup(8, 3, 3, 5, 5)],
MinRoomSpacing=1, MaxPlacementAttempts=150.
MaxPlacementAttempts
The maximum number of random placement attempts made for each individual room
before giving up on that room and moving to the next one. Higher values increase
the likelihood that all rooms are successfully placed on dense or large grids, at
the cost of additional computation. A value of 100-200 is adequate
for most grid sizes and room counts.
Declaration
public readonly int MaxPlacementAttempts
Field Value
| Type | Description |
|---|---|
| int |
MazeSettings
Settings for the maze backbone generated before rooms are placed. Controls dead-end removal and loop creation passes that transform the initial perfect maze into a more game-friendly layout. See MazeSettings for details.
Declaration
public readonly MazeSettings MazeSettings
Field Value
| Type | Description |
|---|---|
| MazeSettings |
MinRoomSpacing
The minimum number of wall cells that must separate the edges of any two rooms.
A value of 0 allows rooms to be placed immediately adjacent to each other;
a value of 1 ensures at least one wall cell of space between them, which
preserves the maze passage network between rooms.
Declaration
public readonly int MinRoomSpacing
Field Value
| Type | Description |
|---|---|
| int |
Mixed
Places a mix of two large rooms (9-13 cells wide and tall) and six small rooms (3-5 cells) into a moderately modified maze. Creates variety in room scale, suitable for dungeons with distinct area types such as boss rooms and side chambers.
Declaration
public static readonly MazeRoomSettings Mixed
Field Value
| Type | Description |
|---|---|
| MazeRoomSettings |
Remarks
Specific values: MazeSettings=(0.3, 0.15),
RoomGroups=[RoomGroup(2, 9, 9, 13, 13), RoomGroup(6, 3, 3, 5, 5)],
MinRoomSpacing=1, MaxPlacementAttempts=150.
RoomGroups
An array of room groups defining the categories of rooms to attempt to place.
Groups are processed in array order; each group specifies a count and a size
range. A null or empty array results in no rooms being placed and the
output being a plain maze.
Declaration
public readonly RoomGroup[] RoomGroups
Field Value
| Type | Description |
|---|---|
| RoomGroup[] |
See Also
Methods
Lerp(MazeRoomSettings, MazeRoomSettings, float)
Linearly interpolates between two MazeRoomSettings instances and returns the blended result.
Declaration
public static MazeRoomSettings Lerp(MazeRoomSettings a, MazeRoomSettings b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| MazeRoomSettings | a | The start settings returned when |
| MazeRoomSettings | b | The end settings returned when |
| float | t | Interpolation factor in the range |
Returns
| Type | Description |
|---|---|
| MazeRoomSettings | A new MazeRoomSettings whose fields are blended between
|
Remarks
MazeSettings is delegated to Lerp(MazeSettings, MazeSettings, float). Integer fields (MinRoomSpacing, MaxPlacementAttempts) are interpolated and rounded to the nearest integer.
Room group array interpolation follows these rules:
-
When both arrays are non-
nulland have the same length, each pair of groups is interpolated pairwise via Lerp(RoomGroup, RoomGroup, float). -
When the arrays have different lengths or one is
null, the array fromais used whentis less than0.5and the array frombis used otherwise. A defensive copy is made to prevent aliasing.
t is clamped to [0, 1] before any calculation.