Class 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().
Inherited Members
Namespace: Scylla.Core.Util.ProceduralMapGen
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaProceduralMapInstantiator
Remarks
The instantiator only emits structural geometry; gameplay objects (markers, decor, NPCs) and game-specific orchestration (theme/algorithm dispatch, spawn / teleporter selection) remain the caller's responsibility. Door cells are detected via the 1-cell-opening + room-mouth heuristic shared with DroidShip's FloorBuilder (collapsed runs along the passage axis), and the spawned door leaves are returned in Doors so the caller can attach sliding / sight-blocking behaviour after build.
Cell coordinates map to world positions using the convention from
DeckGeometry.CellToWorld: cell (col, row) centre is at local
position ((col + 0.5) * CellSize, 0, (row + 0.5) * CellSize). The grid
extends from (0, 0) to (Width * CellSize, Height * CellSize); the
caller positions the root transform passed to WithRoot(Transform) for absolute
placement.
Walkable cells (Floor, Corridor, Door, Spawn) receive a floor quad; non-walkable cells that equal Wall receive a wall cube. Other values (e.g. Empty or custom game-specific encodings) are skipped entirely.
Constructors
ScyllaProceduralMapInstantiator(MapGenResult<SquareCoord>, ScyllaSquareGrid<int>, float)
Initializes a new instantiator bound to the given mapGen
metadata and grid. Both references are stored (no copy); the
instantiator does not mutate the grid. cellSize is the world
width of one grid cell.
Declaration
public ScyllaProceduralMapInstantiator(MapGenResult<SquareCoord> mapGen, ScyllaSquareGrid<int> grid, float cellSize = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| MapGenResult<SquareCoord> | mapGen | Result from ProceduralMapGenerator. Used for room metadata in WithCellToRoomMap(); not required by other stages. |
| ScyllaSquareGrid<int> | grid | The populated grid (after generation + post-processing). |
| float | cellSize | World width of one grid cell. Defaults to 1. |
Methods
Build()
Executes all configured stages in fixed order (floor -> ceiling -> walls
-> doors -> cell-to-room map) and returns an InstantiationResult
with handles to every spawned GameObject. Stages that were not configured via the
matching WithX call are skipped; the corresponding result fields are
null or empty.
Declaration
public InstantiationResult Build()
Returns
| Type | Description |
|---|---|
| InstantiationResult | The instantiation result. Caller owns all spawned GameObjects. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when WithRoot(Transform) was not called before Build(). |
WithCeiling(Color, float, float)
Configures the ceiling stage to emit a single ScyllaPlaneShape covering the entire grid bounds, rotated 180 degrees around X so the visible side faces down toward the floor.
Declaration
public ScyllaProceduralMapInstantiator WithCeiling(Color tint, float wallHeight, float yLift = 0.01)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | tint | Ceiling tint applied via |
| float | wallHeight | Wall height; the ceiling plane sits at |
| float | yLift | Small positive offset so the ceiling sits just above the wall tops without Z-fighting at the junction. Defaults to 1 cm. |
Returns
| Type | Description |
|---|---|
| ScyllaProceduralMapInstantiator |
WithCellToRoomMap()
Enables the cell-to-room-ID map output (CellToRoom). The map is built from Rooms; cells not assigned to any room (corridors, walls) are absent. Useful for fog-of-war and other room-scoped gameplay queries.
Declaration
public ScyllaProceduralMapInstantiator WithCellToRoomMap()
Returns
| Type | Description |
|---|---|
| ScyllaProceduralMapInstantiator |
WithCheckeredFloor(Color, Color, float, float, bool)
Configures the floor stage to emit a checkerboard variant: cells whose
(col + row) is even use tintEven, cells with odd parity
use tintOdd. The two-tint mesh ships as a single merged mesh
with per-quad vertex colours.
Declaration
public ScyllaProceduralMapInstantiator WithCheckeredFloor(Color tintEven, Color tintOdd, float tileGap = 0.01, float yOffset = -0.02, bool doubleSided = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | tintEven | |
| Color | tintOdd | |
| float | tileGap | |
| float | yOffset | |
| bool | doubleSided |
Returns
| Type | Description |
|---|---|
| ScyllaProceduralMapInstantiator |
WithDoors(float, IRandomSource, DoorShapeConfig?)
Configures the door stage. When invoked, Build() detects all 1-cell
wall openings adjacent to a room mouth (collapsed along the passage axis) and
returns them in Doors. When
shape is supplied, a thin cube leaf is also spawned at each
detected cell. When coverage < 1, the
rng shuffles the detected list and the first floor(count *
coverage) entries are kept.
Declaration
public ScyllaProceduralMapInstantiator WithDoors(float coverage = 1, IRandomSource rng = null, DoorShapeConfig? shape = null)
Parameters
| Type | Name | Description |
|---|---|---|
| float | coverage | Fraction of detected door cells to keep, in |
| IRandomSource | rng | RNG for the coverage shuffle. Required when |
| DoorShapeConfig? | shape | Optional leaf geometry. |
Returns
| Type | Description |
|---|---|
| ScyllaProceduralMapInstantiator |
WithFloor(Color, float, float, bool)
Configures the floor stage to emit a single merged-mesh GameObject containing one
quad per walkable cell, all tinted tint.
Declaration
public ScyllaProceduralMapInstantiator WithFloor(Color tint, float tileGap = 0.01, float yOffset = -0.02, bool doubleSided = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | tint | Floor tile tint applied via |
| float | tileGap | Gap left around each tile so the underlying void is visible as grid lines. Defaults to 1 cm. |
| float | yOffset | World Y offset of the tile plane (typically a small negative so the tiles sit just below the wall bases). |
| bool | doubleSided | If |
Returns
| Type | Description |
|---|---|
| ScyllaProceduralMapInstantiator |
WithRoot(Transform)
Sets the parent transform under which all spawned GameObjects are placed. Required before calling Build().
Declaration
public ScyllaProceduralMapInstantiator WithRoot(Transform parent)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | parent |
Returns
| Type | Description |
|---|---|
| ScyllaProceduralMapInstantiator |
WithWalls(Color, float, float)
Configures the wall stage to emit one CreateCube(Transform, string, Vector3?, Quaternion?, Vector3?, Color?, Material, ColliderMode, float) per
Wall cell, scaled to (cellSize - inset) x height x
(cellSize - inset).
Declaration
public ScyllaProceduralMapInstantiator WithWalls(Color tint, float height, float inset = 0.01)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | tint | Wall tint applied via |
| float | height | Wall height (full world units; cube Y centre is set to |
| float | inset | Inset on X / Z so adjacent cubes don't share a face (avoids Z-fighting on the inner wall surfaces). Defaults to 1 cm. |
Returns
| Type | Description |
|---|---|
| ScyllaProceduralMapInstantiator |