Struct 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.
Inherited Members
Namespace: Scylla.Core.Util.ProceduralMapGen
Assembly: ScyllaCore.dll
Syntax
public readonly struct FloorplanSettings
Remarks
The Floorplan algorithm works in three phases:
- Area distribution - a target room count is derived from the interior area divided by CellsPerRoom, then room areas are generated with a deliberate size mix (controlled by LargeRoomWeight, MediumRoomWeight, SmallRoomWeight) summing to the full interior area so the layout covers the space completely.
- Squarified treemap layout - the target areas are packed into the interior rectangle using the squarify heuristic: areas are placed in rows, with each row choosing a split orientation that keeps aspect ratios as close to 1 as possible. Result: a set of non-overlapping rectangles that tile the interior with no gaps.
- Connectivity - rooms whose rectangles share a wall segment long enough for a doorway are wall-adjacent. Each room's right and bottom edges independently receive an extra 1-cell inset with probability ThickWallChance, so shared walls vary between 1 and 2 cells. An MST over the adjacency graph ensures all rooms are reachable via doors that span the actual gap width. Extra doors beyond the MST are added per DoorLoopRatio to create loops. Rooms that are not wall-adjacent (rare for a treemap layout that tiles the space) are connected by short L-shaped Corridor passages.
Use the static presets (Default, Apartments,
OpenPlan) as starting points. All fields are readonly;
use Lerp(FloorplanSettings, FloorplanSettings, float) to smoothly transition between configurations.
Constructors
FloorplanSettings(int, int, int, float, float, float, float, float, int, float)
Initializes a new FloorplanSettings with explicit control over all room density, wall thickness, size-mix, connectivity, and wall-variation parameters.
Declaration
public FloorplanSettings(int cellsPerRoom = 60, int minRoomArea = 4, int wallThickness = 1, float largeRoomWeight = 1, float mediumRoomWeight = 2, float smallRoomWeight = 2, float doorLoopRatio = 0.25, float aspectRatioTarget = 1.5, int maxDoorAttempts = 8, float thickWallChance = 0.35)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellsPerRoom | Approximate cells per room used to derive the room count from the grid area.
Must be at least |
| int | minRoomArea | Minimum carved floor area per room in cells. Must be at least |
| int | wallThickness | Base shared wall thickness in cells between adjacent rooms. Clamped to [1, 2].
Defaults to |
| float | largeRoomWeight | Relative weight for large rooms (area ~3x average). Must be non-negative.
Defaults to |
| float | mediumRoomWeight | Relative weight for medium rooms (area ~1x average). Must be non-negative.
Defaults to |
| float | smallRoomWeight | Relative weight for small rooms (area ~0.35x average). Must be non-negative.
Defaults to |
| float | doorLoopRatio | Fraction of extra door connections beyond the MST. |
| float | aspectRatioTarget | Target aspect ratio for squarified row orientation selection. Must be > 0.
Defaults to |
| int | maxDoorAttempts | Maximum attempts to find a valid door cell on a shared wall segment before
falling back to a short corridor. Must be at least |
| float | thickWallChance | Probability [0, 1] that a room's right or bottom edge adds an extra 1-cell inset,
making the shared wall on that side 2 cells thick instead of the base
WallThickness. A value of |
Fields
Apartments
A preset that generates many small, densely-packed apartment-style rooms with a mix of 1-cell and 2-cell shared walls (25% thick) and high loop density, resembling residential floor plans.
Declaration
public static readonly FloorplanSettings Apartments
Field Value
| Type | Description |
|---|---|
| FloorplanSettings |
Remarks
Specific values: CellsPerRoom=30, MinRoomArea=3, WallThickness=1,
LargeRoomWeight=0.5, MediumRoomWeight=2, SmallRoomWeight=4,
DoorLoopRatio=0.4, AspectRatioTarget=1.8, MaxDoorAttempts=10,
ThickWallChance=0.25.
AspectRatioTarget
Target aspect ratio for squarified row selection. The squarify step chooses
whether to lay a new row horizontally or vertically by picking whichever
orientation keeps the worst-case aspect ratio of the cells in the current row
closest to this value. A value of 1.0 targets square rooms. Values
above 1.0 allow more elongated rooms. Must be greater than 0.
Declaration
public readonly float AspectRatioTarget
Field Value
| Type | Description |
|---|---|
| float |
CellsPerRoom
Approximate number of cells per room used to derive the target room count from
the interior area. A smaller value produces more, smaller rooms; a larger value
produces fewer, larger rooms. Must be at least 4 to avoid degenerate
zero-cell rooms. The actual room count is clamped to a reasonable range.
Declaration
public readonly int CellsPerRoom
Field Value
| Type | Description |
|---|---|
| int |
Default
A balanced preset suitable as a general-purpose floorplan configuration. Produces an even mix of large, medium, and small rooms with a natural mix of 1-cell and 2-cell shared walls (35% thick) and a moderate loop ratio of 25%.
Declaration
public static readonly FloorplanSettings Default
Field Value
| Type | Description |
|---|---|
| FloorplanSettings |
Remarks
Specific values: CellsPerRoom=60, MinRoomArea=4, WallThickness=1,
LargeRoomWeight=1, MediumRoomWeight=2, SmallRoomWeight=2,
DoorLoopRatio=0.25, AspectRatioTarget=1.5, MaxDoorAttempts=8,
ThickWallChance=0.35.
DoorLoopRatio
Fraction of extra door connections to add beyond the minimum spanning tree that
guarantees full connectivity. A value of 0.0 produces a pure tree (no
loops). A value of 0.3 adds roughly 30% more connections for loops.
Typical useful range is 0.0-0.6.
Declaration
public readonly float DoorLoopRatio
Field Value
| Type | Description |
|---|---|
| float |
LargeRoomWeight
Relative weight given to large rooms when distributing room areas. Large rooms
have an area of approximately 3 * averageRoomArea. Higher values increase
the proportion of spacious rooms in the layout. Must be non-negative.
Declaration
public readonly float LargeRoomWeight
Field Value
| Type | Description |
|---|---|
| float |
MaxDoorAttempts
Maximum number of attempts to place a door on a shared wall segment. If no
valid door position is found within this budget (e.g. the shared segment is
too short for a clear doorway), the connection falls back to a short L-shaped
corridor. Must be at least 1.
Declaration
public readonly int MaxDoorAttempts
Field Value
| Type | Description |
|---|---|
| int |
MediumRoomWeight
Relative weight given to medium rooms when distributing room areas. Medium rooms
have an area of approximately 1 * averageRoomArea. Higher values increase
the proportion of average-sized rooms. Must be non-negative.
Declaration
public readonly float MediumRoomWeight
Field Value
| Type | Description |
|---|---|
| float |
MinRoomArea
Minimum floor area in cells that a carved room interior must have after inset by
WallThickness. Treemap rectangles whose carved area falls below
this threshold are still carved (to maintain full coverage) but their floor area
may be very small. Must be at least 1.
Declaration
public readonly int MinRoomArea
Field Value
| Type | Description |
|---|---|
| int |
OpenPlan
A preset that generates fewer, larger rooms with wide-open connections, minimal loop corridors, and moderately frequent thick walls (45%), resembling an open-plan office or command centre layout.
Declaration
public static readonly FloorplanSettings OpenPlan
Field Value
| Type | Description |
|---|---|
| FloorplanSettings |
Remarks
Specific values: CellsPerRoom=120, MinRoomArea=8, WallThickness=1,
LargeRoomWeight=3, MediumRoomWeight=2, SmallRoomWeight=1,
DoorLoopRatio=0.15, AspectRatioTarget=1.3, MaxDoorAttempts=6,
ThickWallChance=0.45.
SmallRoomWeight
Relative weight given to small rooms when distributing room areas. Small rooms
have an area of approximately 0.35 * averageRoomArea. Higher values
increase the proportion of compact rooms, adding density. Must be non-negative.
Declaration
public readonly float SmallRoomWeight
Field Value
| Type | Description |
|---|---|
| float |
ThickWallChance
Probability in [0, 1] that a room's right or bottom edge uses an extra 1-cell
inset, producing a 2-cell-thick shared wall on that side instead of the base
WallThickness. A value of 0 makes every shared wall exactly
WallThickness cells thick. A value of 1 makes every shared
wall 2 cells thick (capped regardless of WallThickness). The default
of 0.35 yields roughly 35% thick walls and 65% thin walls, giving a natural
varied look. Must be in [0, 1].
Declaration
public readonly float ThickWallChance
Field Value
| Type | Description |
|---|---|
| float |
WallThickness
Thickness in cells of the shared walls between adjacent rooms. A value of
1 means rooms are separated by exactly one wall cell; a value of
2 adds a second wall cell between rooms. Valid range: 1-2.
Larger values leave less interior floor per room on small grids.
Declaration
public readonly int WallThickness
Field Value
| Type | Description |
|---|---|
| int |
Methods
Lerp(FloorplanSettings, FloorplanSettings, float)
Linearly interpolates between two FloorplanSettings instances and returns the blended result.
Declaration
public static FloorplanSettings Lerp(FloorplanSettings a, FloorplanSettings b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| FloorplanSettings | a | The start settings returned when |
| FloorplanSettings | b | The end settings returned when |
| float | t | Interpolation factor in the range |
Returns
| Type | Description |
|---|---|
| FloorplanSettings | A new FloorplanSettings whose fields are blended between
|
Remarks
Integer fields are interpolated with Math.Round; float fields are
interpolated continuously. t is clamped to [0, 1]
before any calculation.