Struct MapGenSettings
Common settings shared by all map generation algorithms in ProceduralMapGenerator. Governs the integer cell values written to the output grid, which optional post-processing passes to execute after the primary algorithm finishes, and how spawn points are discovered.
Inherited Members
Namespace: Scylla.Core.Util.ProceduralMapGen
Assembly: ScyllaCore.dll
Syntax
public readonly struct MapGenSettings
Remarks
Every ProceduralMapGenerator overload accepts a MapGenSettings alongside
its algorithm-specific settings struct. The cell value fields (WallValue,
FloorValue, CorridorValue, DoorValue) allow
callers to map generation output to any integer encoding they require; the defaults are the
cast values of MapCellType.
Post-processing flags control optional passes that run after the primary algorithm completes:
- EnsureConnectivity - flood-fills the grid and tunnels between disconnected floor regions so the entire traversable area is reachable from any floor cell.
- RemoveDeadEnds - iteratively removes floor cells that have only a single floor neighbor, pruning corridor dead-ends until no more exist.
- DetectRooms - runs a flood-fill room-detection pass and populates Rooms in the returned result.
- FindSpawns - selects SpawnCount floor cells spread across the map and records them in SpawnPoints.
Use the provided static presets (Default, Dungeon,
Cave) as starting points, or construct a custom instance via the
primary constructor. All fields are readonly; use Lerp(MapGenSettings, MapGenSettings, float) to
smoothly transition between two configurations at runtime.
Constructors
MapGenSettings(int, int, int, int, bool, bool, bool, bool, int)
Initializes a new MapGenSettings with fully explicit control over all cell values and post-processing flags.
Declaration
public MapGenSettings(int wallValue = 1, int floorValue = 2, int corridorValue = 3, int doorValue = 4, bool ensureConnectivity = true, bool removeDeadEnds = false, bool detectRooms = true, bool findSpawns = false, int spawnCount = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | wallValue | Integer value written to impassable wall cells. Defaults to
|
| int | floorValue | Integer value written to walkable floor cells inside rooms. Defaults to
|
| int | corridorValue | Integer value written to carved corridor cells connecting rooms. Defaults to
|
| int | doorValue | Integer value written to door cells between rooms and corridors. Defaults to
|
| bool | ensureConnectivity | When |
| bool | removeDeadEnds | When |
| bool | detectRooms | When |
| bool | findSpawns | When |
| int | spawnCount | Number of spawn points to find when |
Fields
Cave
A preset tuned for organic cave-style layouts generated by Cellular Automata or Drunkard's Walk algorithms. Connectivity is ensured and rooms are detected, but dead-end removal and spawn placement are disabled because caves typically lack narrow corridor fingers that benefit from pruning.
Declaration
public static readonly MapGenSettings Cave
Field Value
| Type | Description |
|---|---|
| MapGenSettings |
Remarks
Specific values: WallValue=1, FloorValue=2, CorridorValue=3, DoorValue=4,
EnsureConnectivity=true, RemoveDeadEnds=false, DetectRooms=true,
FindSpawns=false, SpawnCount=1.
CorridorValue
The integer value written to grid cells that represent carved corridors connecting
rooms. Defaults to (int)Corridor (3).
Some algorithms (e.g. Drunkard's Walk) do not distinguish corridors from floors;
in those cases all carved cells receive FloorValue.
Declaration
public readonly int CorridorValue
Field Value
| Type | Description |
|---|---|
| int |
Default
A balanced preset suitable as a general-purpose starting configuration. Enables connectivity repair and room detection; disables dead-end removal and spawn placement. Cell values match the defaults of MapCellType.
Declaration
public static readonly MapGenSettings Default
Field Value
| Type | Description |
|---|---|
| MapGenSettings |
Remarks
Specific values: WallValue=1, FloorValue=2, CorridorValue=3, DoorValue=4,
EnsureConnectivity=true, RemoveDeadEnds=false, DetectRooms=true,
FindSpawns=false, SpawnCount=1.
DetectRooms
When true, a room-detection pass runs as the last post-processing step.
The pass performs a flood-fill scan over all floor cells, groups contiguous
floor regions into MapRoom<TCoord> instances, and populates
Rooms in the returned result.
Set to false if room metadata is not needed and generation time is
a concern on large grids.
Declaration
public readonly bool DetectRooms
Field Value
| Type | Description |
|---|---|
| bool |
DoorValue
The integer value written to grid cells that represent door positions between rooms
and corridors. Defaults to (int)Door (4).
Door placement is handled by a dedicated post-processing step and requires
DoorPlacementSettings (reserved for future use).
Declaration
public readonly int DoorValue
Field Value
| Type | Description |
|---|---|
| int |
Dungeon
A preset tuned for dungeon-style layouts with room-and-corridor structure. Enables connectivity repair, dead-end removal, room detection, and spawn placement (one spawn point). Dead-end removal prunes finger corridors that characterise BSP and Maze levels.
Declaration
public static readonly MapGenSettings Dungeon
Field Value
| Type | Description |
|---|---|
| MapGenSettings |
Remarks
Specific values: WallValue=1, FloorValue=2, CorridorValue=3, DoorValue=4,
EnsureConnectivity=true, RemoveDeadEnds=true, DetectRooms=true,
FindSpawns=true, SpawnCount=1.
EnsureConnectivity
When true, a connectivity-repair pass runs after the primary algorithm.
The pass flood-fills from the largest floor region and carves tunnels to any
disconnected floor islands, guaranteeing that every floor cell is reachable from
every other floor cell. Setting this to false may produce disconnected
regions; use ConnectedComponentCount to
verify the result.
Declaration
public readonly bool EnsureConnectivity
Field Value
| Type | Description |
|---|---|
| bool |
FindSpawns
When true, a spawn-point selection pass runs after all other post-processing.
The pass selects SpawnCount floor cells that are well-distributed
across the map and records them in
SpawnPoints. Has no effect if
SpawnCount is less than or equal to zero.
Declaration
public readonly bool FindSpawns
Field Value
| Type | Description |
|---|---|
| bool |
FloorValue
The integer value written to grid cells that represent open, walkable floor areas
inside rooms. Defaults to (int)Floor (2).
Declaration
public readonly int FloorValue
Field Value
| Type | Description |
|---|---|
| int |
RemoveDeadEnds
When true, a dead-end pruning pass runs after the primary algorithm (and
after connectivity repair if both flags are set). The pass iteratively converts
floor cells that have exactly one floor neighbor back to walls until no such cells
remain. This is especially effective for mazes and Drunkard's Walk levels where
long, dead corridor fingers are undesirable.
Declaration
public readonly bool RemoveDeadEnds
Field Value
| Type | Description |
|---|---|
| bool |
SpawnCount
The number of spawn points to find when FindSpawns is true.
The algorithm attempts to distribute spawn points evenly across the traversable
area. If fewer than SpawnCount suitable floor cells exist the list will
contain as many as were found. Must be greater than zero for any spawns to be
placed; ignored when FindSpawns is false.
Declaration
public readonly int SpawnCount
Field Value
| Type | Description |
|---|---|
| int |
WallValue
The integer value written to grid cells that represent impassable walls.
Defaults to (int)Wall (1).
Change this when your grid uses a different integer encoding for walls.
Declaration
public readonly int WallValue
Field Value
| Type | Description |
|---|---|
| int |
Methods
Lerp(MapGenSettings, MapGenSettings, float)
Linearly interpolates between two MapGenSettings instances and returns the blended result.
Declaration
public static MapGenSettings Lerp(MapGenSettings a, MapGenSettings b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| MapGenSettings | a | The start settings returned when |
| MapGenSettings | b | The end settings returned when |
| float | t | Interpolation factor in the range |
Returns
| Type | Description |
|---|---|
| MapGenSettings | A new MapGenSettings whose fields are blended between
|
Remarks
Because most fields are discrete (integer cell values, booleans), true continuous interpolation is not possible. The following rules are applied:
-
Integer cell values (WallValue, FloorValue,
CorridorValue, DoorValue): the value from
ais used whentis less than0.5; the value frombis used otherwise. -
Boolean flags (EnsureConnectivity,
RemoveDeadEnds, DetectRooms,
FindSpawns): switch from
atobatt=0.5. - SpawnCount: linearly interpolated and rounded to the nearest integer.
t is clamped to the range [0, 1] before any
calculation.