Class BuildingBuilder
Fluent builder for constructing buildings with a clean, chainable API. Delegates to specialized builders (WallBuilder, FurnitureBuilder, etc.).
public sealed class BuildingBuilder
- Inheritance
-
BuildingBuilder
- Inherited Members
Examples
var building = new BuildingBuilder("MyShop") .WithConfig(BuildingConfig.Dispensary) .AddFloor() .AddCeiling() .AddWalls(southDoor: true, eastDoor: true, westWindow: true) .AddLights() .AddFurniture(FurnitureType.Counter, "north") .Build();
Constructors
BuildingBuilder(string)
Create a new building builder.
public BuildingBuilder(string name)
Parameters
namestringName for the building GameObject
Properties
Config
Get the current configuration.
public BuildingConfig Config { get; }
Property Value
GridCellSize
Grid cell size computed from room dimensions. Furniture placement and interior pathfinding both use this value so the two grids are always aligned.
public float GridCellSize { get; }
Property Value
InteriorDoorways
Doorway positions recorded from all interior walls. Each entry provides center, dimensions, and orientation for future NavMesh link generation.
public IReadOnlyList<DoorwayInfo> InteriorDoorways { get; }
Property Value
Registry
Post-build registry for targeting specific building parts (walls, floor, trim, etc.).
public BuildingPartRegistry Registry { get; }
Property Value
RoomSize
Get the current room size.
public Vector3 RoomSize { get; }
Property Value
- Vector3
Root
Get the root GameObject before Build() is called.
public GameObject Root { get; }
Property Value
- GameObject
Methods
AddAmbientLighting(float)
Add ambient fill lighting.
public BuildingBuilder AddAmbientLighting(float intensity = 0.3)
Parameters
intensityfloatAmbient light intensity
Returns
- BuildingBuilder
This builder for chaining
AddBaseMolding(float, float, Material?, IEnumerable<WallSide>?)
Add base molding around the bottom of the building.
public BuildingBuilder AddBaseMolding(float height = 0.3, float depth = 0.1, Material? material = null, IEnumerable<WallSide>? skipWalls = null)
Parameters
heightfloatMolding height in meters
depthfloatMolding depth in meters
materialMaterialOptional material override
skipWallsIEnumerable<WallSide>Wall sides to omit molding from (null = include all walls)
Returns
- BuildingBuilder
This builder for chaining
AddCeiling(Color?, Material?)
Add ceiling to the room.
public BuildingBuilder AddCeiling(Color? color = null, Material? material = null)
Parameters
colorColor?Optional color override
materialMaterialOptional material override
Returns
- BuildingBuilder
This builder for chaining
AddCornerPillars(float, Material?)
Add structural pillars at corners.
public BuildingBuilder AddCornerPillars(float width = 0.4, Material? material = null)
Parameters
widthfloatPillar width in meters
materialMaterialOptional material override
Returns
- BuildingBuilder
This builder for chaining
AddCornerTrim(float, float, Material?)
Add thin vertical trim strips at the four corners of the building. Each corner gets two perpendicular strips forming a right angle that seamlessly connects with horizontal trims (AddRoofTrim(float, Material?), AddBaseMolding(float, float, Material?, IEnumerable<WallSide>?)).
public BuildingBuilder AddCornerTrim(float width = 0.3, float depth = 0.1, Material? material = null)
Parameters
widthfloatVisible width of each trim strip on the wall face in meters
depthfloatHow far the trim protrudes past the wall surface in meters
materialMaterialOptional material override
Returns
- BuildingBuilder
This builder for chaining
AddDoorFrames(Material?)
Add trim-style door frames around door openings. Must be called after AddWalls.
public BuildingBuilder AddDoorFrames(Material? material = null)
Parameters
materialMaterialOptional material override
Returns
- BuildingBuilder
This builder for chaining
AddFloor(Color?, Material?)
Add floor to the room.
public BuildingBuilder AddFloor(Color? color = null, Material? material = null)
Parameters
colorColor?Optional color override
materialMaterialOptional material override
Returns
- BuildingBuilder
This builder for chaining
AddFoundation(float, float, float, Color?, Material?)
Add foundation beneath the building.
public BuildingBuilder AddFoundation(float height = 2, float expandX = 0, float expandZ = 0, Color? color = null, Material? material = null)
Parameters
heightfloatFoundation depth in meters
expandXfloatExtra expansion on X axis
expandZfloatExtra expansion on Z axis
colorColor?Optional color override (defaults to grey)
materialMaterialOptional material override
Returns
- BuildingBuilder
This builder for chaining
AddFurniture(FurnitureType, string, Color?)
Add furniture at a semantic position.
public BuildingBuilder AddFurniture(FurnitureType type, string position, Color? color = null)
Parameters
typeFurnitureTypeType of furniture
positionstringSemantic position (center, north, south, east, west, northeast, etc.)
colorColor?Optional color override
Returns
- BuildingBuilder
This builder for chaining
AddFurniture(FurnitureType, Vector3, Quaternion, Color?)
Add furniture at exact coordinates.
public BuildingBuilder AddFurniture(FurnitureType type, Vector3 position, Quaternion rotation, Color? color = null)
Parameters
typeFurnitureTypeType of furniture
positionVector3Local position
rotationQuaternionLocal rotation
colorColor?Optional color override
Returns
- BuildingBuilder
This builder for chaining
AddHipRoof(float, float, bool?, Color?, Material?, float)
Add a hip (four-slope) roof using custom mesh geometry. All four sides slope inward to a central ridge that is shorter than the building length. For square buildings, the ridge collapses to a point (pyramid roof). A base slab sits at ceiling height giving the roof visible thickness from below. For interior ceilings, use AddCeiling(Color?, Material?) separately — the ceiling sits just below the roof slab with no overlap.
public BuildingBuilder AddHipRoof(float ridgeHeight = 2, float overhang = 0.3, bool? ridgeAlongX = null, Color? roofColor = null, Material? roofMaterial = null, float baseSlabHeight = 0.15)
Parameters
ridgeHeightfloatHeight of the ridge peak above the ceiling in meters.
overhangfloatHow far the roof eaves extend past the walls in meters.
ridgeAlongXbool?If true, ridge runs along X axis. If false, along Z. Null auto-selects the longer axis.
roofColorColor?Color for the sloped roof planes.
roofMaterialMaterialMaterial for the sloped roof planes. Null uses fallback color.
baseSlabHeightfloatHeight of the 3D base slab beneath the slopes. 0 disables the slab.
Returns
- BuildingBuilder
This builder for chaining
AddInteriorDoorFrames(Material?)
Add trim-style door frames around interior doorway openings. Must be called after AddInteriorWall.
public BuildingBuilder AddInteriorDoorFrames(Material? material = null)
Parameters
materialMaterialOptional material override
Returns
- BuildingBuilder
This builder for chaining
AddInteriorWall(InteriorWallAxis, float, WallOpening?, Color?, Material?)
Add an interior wall spanning the full room width along the specified axis.
public BuildingBuilder AddInteriorWall(InteriorWallAxis axis, float position, WallOpening? opening = null, Color? color = null, Material? material = null)
Parameters
axisInteriorWallAxisAxis the wall runs along (X or Z)
positionfloatPosition on the perpendicular axis (Z for X-axis walls, X for Z-axis walls)
openingWallOpeningOptional opening (door or window) centered in the wall
colorColor?Optional wall color override (defaults to palette wall color)
materialMaterialOptional wall material override (defaults to palette wall material)
Returns
- BuildingBuilder
This builder for chaining
AddInteriorWall(InteriorWallAxis, float, float, float, WallOpening?, Color?, Material?)
Add an interior wall spanning a sub-region of the room.
public BuildingBuilder AddInteriorWall(InteriorWallAxis axis, float position, float from, float to, WallOpening? opening = null, Color? color = null, Material? material = null)
Parameters
axisInteriorWallAxisAxis the wall runs along (X or Z)
positionfloatPosition on the perpendicular axis (Z for X-axis walls, X for Z-axis walls)
fromfloatStart coordinate along the wall's axis
tofloatEnd coordinate along the wall's axis
openingWallOpeningOptional opening (door or window) centered in the wall
colorColor?Optional wall color override (defaults to palette wall color)
materialMaterialOptional wall material override (defaults to palette wall material)
Returns
- BuildingBuilder
This builder for chaining
AddLights(float?, Color?)
Add ceiling lights distributed across the room.
public BuildingBuilder AddLights(float? intensity = null, Color? color = null)
Parameters
intensityfloat?Light intensity
colorColor?Light color
Returns
- BuildingBuilder
This builder for chaining
AddParapetRoof(ParapetPreset, float?, float?, float?, float?, Color?, Material?, Color?, Material?)
Add a parapet roof (raised wall and cap above the roofline). The cap extends past the parapet wall by the overhang amount, creating a ledge. Includes a thin roof slab at ceiling height. For interior ceilings, use AddCeiling(Color?, Material?) separately — the ceiling sits just below the roof slab with no overlap. Use Deep for a prominent commercial look or Shallow for a subtler profile.
public BuildingBuilder AddParapetRoof(ParapetPreset preset = ParapetPreset.Deep, float? parapetHeight = null, float? parapetDepth = null, float? capHeight = null, float? capOverhang = null, Color? parapetColor = null, Material? parapetMaterial = null, Color? capColor = null, Material? capMaterial = null)
Parameters
presetParapetPresetSizing preset (Deep or Shallow). Overridden by explicit dimensions.
parapetHeightfloat?Height of the parapet wall in meters. Null uses preset default.
parapetDepthfloat?Depth of the parapet wall. Null uses wall thickness + padding.
capHeightfloat?Height of the cap. Null uses preset default.
capOverhangfloat?How far the cap extends past the parapet wall on each side. Null uses preset default.
parapetColorColor?Color override for the parapet wall.
parapetMaterialMaterialMaterial override for the parapet wall.
capColorColor?Color override for the cap.
capMaterialMaterialMaterial override for the cap.
Returns
- BuildingBuilder
This builder for chaining
AddPrefab(PrefabRef, Vector3, Quaternion, Action<GameObject>?)
Place a game prefab at the specified position.
public BuildingBuilder AddPrefab(PrefabRef prefab, Vector3 position, Quaternion rotation, Action<GameObject>? onCreated = null)
Parameters
prefabPrefabRefPrefab reference from GamePrefabs
positionVector3Local position
rotationQuaternionLocal rotation
onCreatedAction<GameObject>Optional callback invoked with the instantiated GameObject
Returns
- BuildingBuilder
This builder for chaining
AddRoofTrim(float, Material?)
Add decorative trim around the roofline. Not needed when using AddParapetRoof(ParapetPreset, float?, float?, float?, float?, Color?, Material?, Color?, Material?) or AddHipRoof(float, float, bool?, Color?, Material?, float), which include their own roof structure. Useful for custom roof designs with AddCeiling(Color?, Material?).
public BuildingBuilder AddRoofTrim(float height = 0.3, Material? material = null)
Parameters
heightfloatTrim height in meters
materialMaterialOptional material override
Returns
- BuildingBuilder
This builder for chaining
AddSecondaryRoofTrim(float, Material?)
Add a secondary decorative trim above the roofline. Not needed when using AddParapetRoof(ParapetPreset, float?, float?, float?, float?, Color?, Material?, Color?, Material?) or AddHipRoof(float, float, bool?, Color?, Material?, float), which include their own roof structure. Useful for custom roof designs with AddCeiling(Color?, Material?).
public BuildingBuilder AddSecondaryRoofTrim(float height = 0.15, Material? material = null)
Parameters
heightfloatTrim height in meters
materialMaterialOptional material override
Returns
- BuildingBuilder
This builder for chaining
AddSlidingDoors(Vector3, Quaternion, string, Action<GameObject>?)
Add sliding double doors at a door opening. Server only — returns the builder unchanged on clients (the door is replicated via FishNet).
public BuildingBuilder AddSlidingDoors(Vector3 position, Quaternion rotation, string openingHours = "6AM-6PM", Action<GameObject>? onCreated = null)
Parameters
positionVector3Local position for doors
rotationQuaternionLocal rotation
openingHoursstringText for opening hours sign
onCreatedAction<GameObject>Optional callback invoked with the instantiated door GameObject before activation. Runs after internal customization (material, opening hours text) but before Awake/OnEnable fire, so sensors see configured values. Only fires on the server — will NOT fire on clients.
Returns
- BuildingBuilder
This builder for chaining
Remarks
Multiplayer behavior:
- Server/host: Instantiates and network-spawns the door.
FishNet replicates it to all clients. The
onCreatedcallback fires. - Client: Returns immediately — the door is not created locally. The server-spawned door arrives via FishNet replication and is automatically parented to the building hierarchy with material/text customization applied.
DoorController server-gating: The game's DoorController gates
ALL proximity sensor callbacks (PlayerVicinityEnter/Exit, NPCVicinityEnter/Exit) and
auto-close logic behind InstanceFinder.IsServer. This means on clients:
- Doors will NOT auto-open when players/NPCs approach
- Doors will NOT auto-close when players/NPCs leave
- Manual interaction (clicking the door handle) DOES work via ServerRpc
S1MAPI cannot implement client-side auto-open/close because it requires game assembly types (DoorController, EDoorSide, Player) that S1MAPI intentionally does not reference. Consumer mods that need this behavior must implement their own proximity polling using DoorController.SetIsOpen_Server (public, RequireOwnership=false, RunLocally=true).
AddStairs(WallSide, float, float, float, float, Color?, Material?, StairStyle, bool, float)
Add stairs from ground level up to the building floor on the specified wall. Automatically aligns with the door opening offset on the specified wall. Supports multiple visual styles: Solid (default concrete box steps), ClosedRiser (two-tone wood with risers), or OpenStringer (plank treads on diagonal stringer beams).
public BuildingBuilder AddStairs(WallSide wall, float foundationHeight = 2, float maxStepHeight = 0.2, float width = 2.5, float stepDepth = 0.3, Color? color = null, Material? material = null, StairStyle style = StairStyle.Solid, bool flushWithFloor = false, float gap = 0)
Parameters
wallWallSideWhich wall the stairs attach to
foundationHeightfloatFoundation height in meters (must match AddFoundation height)
maxStepHeightfloatMaximum height per step. Lower values create more, shallower steps. (Solid only)
widthfloatStep width in meters (Solid only)
stepDepthfloatStep depth (tread) in meters. Controls how far stairs extend outward. (Solid only)
colorColor?Optional color override — defaults to palette floor color (Solid only)
materialMaterialOptional material override — defaults to palette floor material (Solid only)
styleStairStyleVisual style of stairs to generate
flushWithFloorboolIf true, topmost step is flush with floor level. If false (default), topmost step is one step below floor. (Solid only)
gapfloatVertical gap between foundation edge and top step. ClosedRiser/OpenStringer default to 0 (flush).
Returns
- BuildingBuilder
This builder for chaining
AddWalls(WallOpening?, WallOpening?, WallOpening?, WallOpening?)
Add walls with fine-grained control over openings.
public BuildingBuilder AddWalls(WallOpening? north = null, WallOpening? south = null, WallOpening? east = null, WallOpening? west = null)
Parameters
northWallOpeningNorth wall opening configuration
southWallOpeningSouth wall opening configuration
eastWallOpeningEast wall opening configuration
westWallOpeningWest wall opening configuration
Returns
- BuildingBuilder
This builder for chaining
AddWalls(WallOpening?, WallOpening?, WallOpening?, WallOpening?, IReadOnlyDictionary<WallSide, WallAppearance>)
Add walls with fine-grained control over openings and per-wall appearance. Walls without an appearance override use the palette defaults.
public BuildingBuilder AddWalls(WallOpening? north, WallOpening? south, WallOpening? east, WallOpening? west, IReadOnlyDictionary<WallSide, WallAppearance> wallAppearances)
Parameters
northWallOpeningNorth wall opening configuration
southWallOpeningSouth wall opening configuration
eastWallOpeningEast wall opening configuration
westWallOpeningWest wall opening configuration
wallAppearancesIReadOnlyDictionary<WallSide, WallAppearance>Per-wall material/color overrides keyed by wall side
Returns
- BuildingBuilder
This builder for chaining
AddWalls(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, Color?, Material?)
Add walls with specified openings.
public BuildingBuilder AddWalls(bool northDoor = false, bool southDoor = false, bool eastDoor = false, bool westDoor = false, bool northWindow = false, bool southWindow = false, bool eastWindow = false, bool westWindow = false, bool northDoorWindows = false, bool southDoorWindows = false, bool eastDoorWindows = false, bool westDoorWindows = false, Color? color = null, Material? material = null)
Parameters
northDoorboolAdd door on north wall
southDoorboolAdd door on south wall
eastDoorboolAdd door on east wall
westDoorboolAdd door on west wall
northWindowboolAdd window on north wall
southWindowboolAdd window on south wall
eastWindowboolAdd window on east wall
westWindowboolAdd window on west wall
northDoorWindowsboolAdd windows alongside north door (requires northDoor)
southDoorWindowsboolAdd windows alongside south door (requires southDoor)
eastDoorWindowsboolAdd windows alongside east door (requires eastDoor)
westDoorWindowsboolAdd windows alongside west door (requires westDoor)
colorColor?Optional wall color override
materialMaterialOptional wall material override
Returns
- BuildingBuilder
This builder for chaining
Build()
Finalize and return the building GameObject.
public GameObject Build()
Returns
- GameObject
The completed building
Build(Action<GameObject>)
Finalize and return the building, then execute a post-build action.
public GameObject Build(Action<GameObject> postBuild)
Parameters
postBuildAction<GameObject>Action to execute with the completed building
Returns
- GameObject
The completed building
CreateNavigationBuilder()
Create a NavigationBuilder configured for this building. Collects exterior and interior doorway positions, stair geometry, and building dimensions. Call Build() on the returned instance after positioning the building.
public NavigationBuilder CreateNavigationBuilder()
Returns
- NavigationBuilder
A configured builder ready to build
DefineRoom(float, float, float)
Define room dimensions directly.
public BuildingBuilder DefineRoom(float width, float height, float depth)
Parameters
widthfloatRoom width (X axis) in meters
heightfloatRoom height (Y axis) in meters
depthfloatRoom depth (Z axis) in meters
Returns
- BuildingBuilder
This builder for chaining
FlattenTerrain(float, bool, float)
Flatten terrain under the building footprint. Must be called after the building is positioned in the scene.
public BuildingBuilder FlattenTerrain(float padding = 0.5, bool clearDetails = true, float blendDistance = 3)
Parameters
paddingfloatExtra padding around the footprint in meters.
clearDetailsboolClear grass and detail layers in the flattened region.
blendDistancefloatDistance for smooth transition back to natural terrain.
Returns
WithConfig(BuildingConfig)
Apply a building configuration preset.
public BuildingBuilder WithConfig(BuildingConfig config)
Parameters
configBuildingConfigBuilding configuration
Returns
- BuildingBuilder
This builder for chaining
WithInteriorWallLayer(int)
Set the physics layer for interior wall GameObjects. Use this to place interior walls on a layer outside the placement raycast mask so the ghost model passes through them while players still physically collide.
public BuildingBuilder WithInteriorWallLayer(int layer)
Parameters
layerintUnity layer index (0–31). -1 leaves walls on the default layer.
Returns
- BuildingBuilder
This builder for chaining
WithPalette(BuildingPalette)
Apply a palette to the current config.
public BuildingBuilder WithPalette(BuildingPalette palette)
Parameters
paletteBuildingPaletteBuilding palette
Returns
- BuildingBuilder
This builder for chaining