Namespace Scylla.Core.Util.ProceduralMapGen
Classes
ProceduralMapGenerator
Main public API for procedural grid-based map generation. Provides eight distinct algorithms that operate in-place on ScyllaSquareGrid<TCell>, ScyllaHexGrid<TCell>, or ScyllaTriGrid<TCell> instances and return a MapGenResult<TCoord> containing rooms, corridors, connected-component counts, and suggested spawn points.
ProceduralMapOverlay
Overlay utilities for adding secondary visual detail to already-generated maps. Provides three overlay categories: noise-based, geometric pattern, and random scatter. Overlays modify cells in an existing grid - they do not generate levels from scratch and should always be applied after a ProceduralMapGenerator algorithm has run.
ProceduralMapPostProcessor
Post-processing utilities for procedurally generated maps. Provides connectivity repair, dead-end removal, room detection, door placement, region grid construction, and spawn point selection. All methods operate in-place on existing grids or are non-destructive queries, and can be called independently after any ProceduralMapGenerator algorithm or combined automatically via the flags in MapGenSettings.
ScyllaProceduralMapInstantiator
Reusable orchestrator that turns a MapGenResult<TCoord> + companion
ScyllaSquareGrid<TCell> into a Unity scene hierarchy of floor tiles,
ceiling, wall cubes, and door leaves via the ScyllaShapes factory.
Configure stages by calling the WithX methods, then invoke Build().
Structs
BSPSettings
Settings for the Binary Space Partitioning (BSP) map generation algorithm, invoked via ProceduralMapGenerator. Controls how the grid is recursively subdivided into partitions, how rooms are sized and padded within each partition, the width and style of the corridors that connect sibling rooms, and the random split ratio used when dividing partitions. Operates on square grids only.
CellularAutomataSettings
Settings for the Cellular Automata (CA) map generation algorithm, invoked via ProceduralMapGenerator. Controls the initial random wall fill, the number of simulation iterations, and the birth/death neighbour thresholds that govern how cells transition between wall and floor states.
DoorPlacement
A single detected door cell, returned in
Doors. Each placement carries the grid cell the
door occupies, the passage axis (which determines the leaf's slide direction), and
the spawned leaf GameObject (or null if door detection ran without an
attached DoorShapeConfig).
DoorPlacementSettings
Immutable settings for the door placement post-processor.
DoorShapeConfig
Per-door cube geometry parameters consumed by WithDoors(float, IRandomSource, DoorShapeConfig?). The instantiator spawns one thin cube per detected door cell with these dimensions; the cube acts as the door leaf and is the GameObject the caller wires up with sliding / sight-blocking behaviour after Build() returns.
DrunkardWalkSettings
Settings for the Drunkard's Walk map generation algorithm, invoked via ProceduralMapGenerator. Controls the walker population, fill target, individual step behaviour, and the random events that spawn or destroy walkers during the walk.
FloorplanSettings
Settings for the Squarified Treemap floorplan map generation algorithm, invoked via Floorplan(ScyllaSquareGrid<int>, FloorplanSettings, MapGenSettings, IRandomSource). Produces building-style layouts where tightly-packed rooms fill the entire interior with no large wasted voids, separated by thin shared walls and connected by door openings with short L-shaped corridors only when needed.
InstantiationResult
The collected output of a Build() call.
Every reference is null or empty when the corresponding stage was not enabled
via the matching WithX configuration call on the instantiator. Callers use
this struct to attach gameplay components (door behaviour, room fog-of-war, etc.) to
the spawned GameObjects.
MapCorridor<TCoord>
Represents a single corridor segment that was carved between two rooms during procedural map generation. Corridors are produced by the BSP and Room-and-Corridor algorithms and are collected in Corridors.
Each corridor references exactly two rooms by their ID values. The IDs correspond to indices into Rooms, making it straightforward to look up room metadata from a corridor reference.
The Cells list contains every grid coordinate carved as part of the corridor path, in traversal order from the first room toward the second. For L-shaped corridors this is a single continuous path with one bend; for winding corridors the path may include multiple jog segments. All cells in Cells have been written to the grid with the CorridorValue cell value at the time the result is returned.
MapGenResult<TCoord>
Contains the full metadata produced by a ProceduralMapGenerator algorithm after it
has finished carving and post-processing a map grid. Every public ProceduralMapGenerator
method returns one of these alongside the in-place modified grid.
The metadata is stratified by the post-processing flags set in MapGenSettings:
-
Rooms is populated only when
DetectRooms is
true; otherwise it is an empty list. - Corridors is populated only for algorithms that carve explicit corridors (BSP and Room-and-Corridor); cave or noise-based algorithms return an empty list.
-
SpawnPoints is populated only when
FindSpawns is
true; otherwise it is an empty list. - ConnectedComponentCount is always computed after generation and reflects the state of the grid after any connectivity-repair post-processing (see EnsureConnectivity).
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.
MapOverlaySettings
Immutable settings for map overlay operations applied by ProceduralMapOverlay.
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.
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.
MazeSettings
Settings for the Recursive Backtracker maze generation algorithm, invoked via ProceduralMapGenerator. Controls two optional post-generation passes - dead-end removal and loop creation - that transform a perfect maze into a more game-friendly layout. Operates on square grids only.
NoiseThresholdSettings
Immutable settings for the Noise-Threshold map generation algorithm.
RoomCorridorSettings
Immutable settings for the Room-and-Corridor map generation algorithm.
RoomGroup
Describes a group of rooms that share the same size constraints for placement into a maze-based map. A RoomGroup specifies how many rooms to attempt to place and the minimum/maximum dimensions those rooms may have.
VoronoiRegionSettings
Immutable settings for the Voronoi Regions map generation algorithm.
WindingCorridorSettings
Immutable settings that control the shape of winding corridors generated by BSP and Room-and-Corridor algorithms.
Enums
CorridorStyle
Defines the corridor carving style used by the BSP and Room-and-Corridor map generation algorithms when connecting rooms with passable floor cells.
The style is configured via CorridorStyle or CorridorStyle and affects both the visual appearance of the generated map and the contents of Cells in the resulting MapGenResult<TCoord>.
When using Winding, additional settings must be provided via
WindingSettings or
WindingSettings to control jog frequency and
maximum deviation. Pass Default for sensible
defaults; using the C# default keyword (zero-initialization) will still fall back
to safe internal defaults.
DoorAxis
The world-axis along which a detected door cell connects two walkable cells through a 1-cell wall opening. The two flanking walls of a door run perpendicular to this axis.
MapCellType
Predefined integer-backed cell type constants used by the map generation utility to classify individual grid cells produced by ProceduralMapGenerator algorithms.
Because the enum is backed by int, its values can be stored directly in an
ScyllaSquareGrid<int> or ScyllaHexGrid<int> without any
cast overhead at read-back time. Cast to int when writing:
<pre><code class="lang-csharp">grid[coord] = (int)MapCellType.Floor;</code></pre>
Cast back to <code>MapCellType</code> when reading:
<pre><code class="lang-csharp">var type = (MapCellType)grid[coord];</code></pre>
The map generation algorithms only distinguish between two semantic roles during generation: walls (stored as WallValue) and floors (stored as FloorValue). The remaining values (Corridor, Door, Spawn) are written during post-processing steps or can be applied manually after generation.
Custom integer values outside this enum are fully supported. Only WallValue and FloorValue need to correspond to meaningful cell types; all other values are transparent to the algorithms and can encode game-specific tile categories (e.g. water, lava, stairs).
MapPatternType
Geometric pattern types that can be stamped onto an existing grid by ApplyPatternOverlay(ScyllaSquareGrid<int>, int, int, MapOverlaySettings) to add repeating visual detail on top of already-generated floor cells.
Pattern overlays do not generate new map structure; they only reclassify cells that
already exist in the grid according to a deterministic geometric rule. When
OnlyAffectFloors is true, only cells
whose current value matches the specified floor value are candidates for modification.
This prevents the overlay from overwriting walls or corridor cells.
Patterns are evaluated using the column and row indices of each cell relative to the grid origin. The same pattern applied to different grid sizes will tile consistently because the matching rules depend only on the local column/row modulus, not on the absolute grid dimensions (except Border, which is perimeter-relative).