Class RoomBuilder
High-level builder for FieldSetup assets (room content). Provides composable content layers: Structure, Props, Lighting, Population, Hazards.
Like DungeonBuilder wraps PGGGraphBuilder for presets, RoomBuilder wraps PGGFieldSetupBuilder for FieldSetups. The end goal: a room definition that reads like a recipe, not a 300-line procedural script.
Usage: class MyCryptRoom : RoomBuilder { protected override string SetupName => "Crypt Room_Code"; protected override void Configure() { Walls(WallStyle.Stone, "SM_Env_Wall_01", "SM_Env_Wall_03"); Floors(FloorStyle.Tiled, "SM_Env_Tiles_02", "SM_Env_Tiles_03"); Pillars(PillarStyle.GridIntersection, "SM_Env_Pillar_Square_01"); Lighting(LightStyle.WallMounted, "Wall Torch", spacing: 3); Props("FM_Vases", probability: 0.01f); Debris("SM_Env_Rubble_Pebbles_01", probability: 0.16f); Monsters("Undead Spawner", probability: 0.25f); } }
Architecture: RoomBuilder (high-level recipe API) -> PGGFieldSetupBuilder (low-level PGG primitives) -> FieldSetup + ModificatorsPack + FieldModification + FieldSpawner + SpawnRuleBase
Each content method (Walls, Floors, etc.) creates a FieldModification with spawners and rules, adds it to the current ModPack, and returns a handle for further customization.
public abstract class RoomBuilder : PGGFieldSetupBuilder
- Inheritance
-
objectRoomBuilder
- Derived
- Inherited Members
- Extension Methods
Properties
- CellSize
Cell size in Unity units. Default 5.
- CurrentPack
Currently active ModPack (content goes here).
- FS
The FieldSetup being built.
- HasDoorways
Whether doorway system is enabled. Default true for dungeon rooms.
- RootPack
Root modification pack (always last).
- SetupName
Asset name for the FieldSetup (e.g. "Crypt Armory_Code").
- TriggerCollider
Trigger collider generation mode. Default BoxFit.
Methods
- Build()
Build the FieldSetup and all ModPacks. Calls Configure() which subclasses implement.
- BuildAndSave()
Build and save everything to disk.
- Configure()
Called by Build() — add content layers here.
- CustomMod(string, string)
Create a custom mod in the current pack with full access. Use when the standard content methods don't fit your needs. Returns the mod for manual configuration.
- Debris(string, float, params string[])
Add ground debris/rubble with random placement and rotation.
- Doorways(FieldModification, FieldModification)
Set up the doorway system with custom door/wall mods. Call this early in Configure() to set the mods used for doorway instructions. If not called, default PGG example mods are used.
- Doorways(string, string)
Set up doorways using named mods from the project.
- Emitters(string, string, float, string)
Add an emitter-based prop (e.g. Vases, object multi-emitter prefabs). Simple probability-based spawning.
- FinalizeRootPack()
Finalize the root pack (adds it to FieldSetup if not already).
- Floors(string, string, params string[])
Add floor tiles to the room. One random tile per cell.
- Instruction(string, EInstruction)
Add a custom cell instruction.
- Monsters(string, string, string, float, bool)
Add a monster spawner with probability-based placement.
- Pack(string)
Start a new content pack. All subsequent content methods (Walls, Floors, etc.) add to this pack until the next Pack() call. The pack is saved as a separate asset and can be reused across FieldSetups.
- Pillars(string)
Add pillars at grid intersections with optional broken replacements.
- RootMod(string, string)
Create a mod in the root pack (runs before/after all other packs). Use for special single-instance spawners like stairs, boss spawners, etc. Returns the FieldModification for further configuration.
- Spawner(FieldModification, string, int, string)
Create a custom spawner on a mod. Exposes the low-level NewSpawner for advanced use cases.
- Toggle(string, float)
Add a toggle variable (0-1) to the FieldSetup.
- Traps(string, string, float, params string[])
Add a trap spawner with probability and non-overlap checks.
- UsePack(ModificatorsPack)
Use an existing ModPack (e.g. one shared across multiple rooms). Does not save it — caller is responsible for saving shared packs.
- UsePack(string)
Use an existing ModPack found by name in the project.
- Variable(string, float, float, float)
Add a numeric variable to the FieldSetup.
- WallLights(string, string, string, float, Vector3?)
Add wall-mounted lights (torches, sconces, etc.). Snaps to walls, maintains minimum spacing.
- WallProps(string, float, Vector3?, params string[])
Add wall-mounted props (weapon racks, bookshelves, etc.). Snaps to walls with directional offset.
- Walls(string, float)
Add walls to the room. Creates a Stone Walls-style mod with:
- Main wall spawner (random selection from wall prefabs)
- Inner corner spawner
- Outer corner spawner
Returns the wall mod for further customization.