Room Detection & Classification¶
The room system has two separate stages:
- detect a physically enclosed region of grid cells;
- classify the region semantically from the objects inside it.
This separation allows the same runtime code to support space stations, medieval buildings, colony bases, management games, and other modular environments.
Enclosed-space detection¶
Each StationGridCell represents one structural 1×1 location. A cell participates in room detection when it has a logical floor and ceiling.
StationRoomGrid performs a four-direction flood fill:
- an adjacent valid cell is connected when no sealing boundary separates it;
- a wall blocks connectivity;
- a closed door or airlock seals the region;
- an open portal connects the two sides;
- a missing exterior neighbor without a sealing boundary marks the region as open.
If any edge leaks into missing space, the entire connected region is rejected. If every exterior edge is sealed, the region becomes a logical room.
W W W W W
W . . . W . = floor cell
W . . . D W = wall
W . . . W D = closed door
W W W W W
The example produces one nine-cell room.
Stable room reuse¶
Detected cells are sorted into a topology signature. When the same region still exists after a rebuild, its generated RoomModule is reused. Stale rooms are removed, new rooms are created, and all cells and placeables are reassigned.
Room rebuilds occur after relevant construction changes and portal state changes.
Content-driven classification¶
Every placed object can reference a StationObjectDefinition. Its room-tag contributions are added to the room total.
Example:
Bed → Rest +1
Locker → Crew +1, Storage +1
Window → Window +1
Decoration→ Decoration +1
RoomTypeDefinition assets describe the required and optional scores for a semantic room type.
Crew Quarters requires:
Rest >= 1
Crew >= 1
Therefore an empty enclosed room remains Generic, a Bed alone remains Generic, and a Bed plus Locker becomes Crew Quarters.
Candidate selection¶
Every registered room type whose required scores are satisfied becomes a candidate. The winner uses:
classification score = priority × 1000 + optional tag score
Priority resolves conflicting identities. Optional tags refine candidates and contribute to level rules.
For example, a room meeting both Storage and Crew requirements becomes Crew Quarters when Crew has the higher classification priority.
Room levels¶
Level rules combine required tag thresholds with a minimum optional score. A Crew Quarters can require Rest and Crew for Level 1, then use Comfort, Storage, Decoration, and Window contributions to reach higher levels.
Room levels are data, not hard-coded branches. A medieval Bedroom, Blacksmith, Alchemy Room, or Throne Room can use the same scoring system.
Local versus station-wide state¶
A RoomModule owns local state:
- oxygen quantity and capacity;
- pressure and temperature;
- placeables and tag totals;
- type and level;
- device and operational state summaries.
The StationResourceGrid aggregates station-wide headline power and production rates. Atmosphere remains local unless rooms are connected by an active vent.
Portals and worker paths¶
Closed portals seal and separate room detection. Worker pathfinding treats Door and Airlock boundaries as usable passage points and never crosses a Wall boundary. This represents an implicit door interaction; animated door opening can be layered onto the portal API later.