BuildingRooms
A class in Root.Township, Alta.PAGaC.
PAGaC generation step that lays out random rooms in the tag grid, then carves doors, stairs and windows between them. Probably an editor or prototype tool; nothing outside PAGaC uses it.
- Listed in World generation
- Inherits or implements
GenerationStep - Nested types
NodeRange,Room,RoomNode,RoomPath
Constructors
| Member | What it is |
|---|---|
BuildingRooms() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
26 private and internal fields
| Member | What it is |
|---|---|
private Tag air | The empty tag, taken from the GenerationBase. |
private Tag door | Tag used for door cells. |
private Tag floor | Tag used for floor cells. |
private int floorHeight | Cells per storey. |
private GenerationBase generationBase | The base passed to the current Run. |
private Generator generator | The tag grid being written to. |
private float loopChance | Chance of also connecting to an already used neighbour on the same floor, making loops. |
private int maximumAreaXZ | Largest allowed floor area for a room, in coarse cells; rooms outside the range are rerolled. |
private int maximumRooms | Upper bound for the random room count (exclusive). |
private int maximumSizeHorizontal | Upper bound for a room's horizontal size in coarse cells. |
private int maximumSizeVertical | Upper bound for a room's vertical size. |
private int minimumAreaXZ | Smallest allowed floor area for a room, in coarse cells. |
private int minimumRooms | Lower bound for the random room count. |
private int minimumSizeHorizontal | Lower bound for a room's horizontal size in coarse cells. |
private int minimumSizeVertical | Lower bound for a room's vertical size. |
private List<BuildingRooms.RoomNode> nodes | All room nodes in the graph. |
private float pathRandomElement | Serialized but not read anywhere in this build. |
private float pathRandomWeighting | Chance GetNext picks a random node. Never assigned, so always 0. |
private int resolutionMultiplier | Grid cells per coarse room cell horizontally. |
private List<BuildingRooms.Room> rooms | Rooms generated in the current run. |
private Tag stair | Tag used for stair cells. |
private int stairBuffer | Clear cells kept before and after a staircase. |
private List<BuildingRooms.RoomNode> usedNodes | Nodes reached so far that may still branch. |
private Tag wall | Tag used for wall cells. |
private Tag window | Tag used for window cells. |
private float windowChance | Chance of placing a window at each possible spot. |
Properties
| Member | What it is |
|---|---|
int SizeX { get; } | Width of the generation grid. |
int SizeY { get; } | Height of the generation grid. |
int SizeZ { get; } | Depth of the generation grid. |
Methods
| Member | What it is |
|---|---|
override void Run(GenerationBase generationBase) | Generates the rooms, tags walls, air and floors into the grid, then traverses the graph to add connections and windows. |
12 private and internal methods
| Member | What it is |
|---|---|
private BuildingRooms.RoomNode Carve(BuildingRooms.RoomNode current) | From one room node, picks a random unused (or, by loopChance, looping) neighbour and connects it; returns the next node or null. |
private bool CreateConnection(BuildingRooms.RoomPath path) | Connects two room nodes with a door if they are on the same floor, otherwise with stairs. |
private bool CreateDoor(BuildingRooms.RoomPath path) | Tries to tag a door cell in a random stretch of shared wall; fails if the cells around it aren't clear. |
private BuildingRooms.RoomNode CreateRoom(bool isFloored, bool isExternal, int floor) | Makes a room node for a floor and adds it to nodes. |
private void CreateRoomNodes(int workingSizeX, int workingSizeY, int workingSizeZ) | Builds the node graph: one external node per floor, plus one per floor of each room, with their grid extents. |
private bool CreateStairs(BuildingRooms.RoomPath path) | Tries to fit a staircase along a shared wall between two floors, avoiding existing stairs and doors. |
private bool CreateWindow(BuildingRooms.RoomPath path) | Tags window cells at random (by windowChance) along wall between an external node and a room on the same floor. |
private BuildingRooms.RoomNode GetNext() | Picks the next node to carve from: the most recently used, or rarely a random one. |
private List<BuildingRooms.NodeRange> GetWalls(IEnumerable<Node> overlap, int minimumWall, Predicate<Node> predicate, int startResolution = 1, int startResolutionOffset = 0) | Finds straight runs of overlap cells at least a given length, optionally filtered and aligned to a step. |
private void OnDrawGizmos() | Draws each room node's bounds as a wire box. |
private void StartTraverse() | Seeds traversal with the ground floor's external node and runs Traverse. |
private void Traverse() | Repeatedly carves paths out from used nodes until every reachable node has been visited. |