# 07 — Multiple Parts

Create bundles with multiple rooms, corridor+room pairs, or large multi-chamber rooms.

---

## How the dungeon generator works

The dungeon is built sequentially by `CreateRandomRoom`. Each step picks one prefab from a pool:

1. First call → picks from `HallWayStructures` (a corridor)
2. Subsequent calls → picks from `NormalRoomStructures`, `PuzzleRoomStructures`, etc.

Rooms are consumed from the pool as they are placed — the same prefab will not appear twice in the same run unless you added it multiple times.

---

## Multiple prefabs in one bundle

A single `.rooms` bundle can contain **several prefab objects**. Each prefab becomes an independent room entry in the pool.

To add a second room to your bundle:

1. In the same scene, create a second root object: `my-pack_AltRoom`
2. Build it just like the first room
3. Drag it into the `Rooms` folder to create a second Prefab
4. Select the Prefab → set its **AssetBundle** to the same name: `my-pack`
5. Export — both rooms are packed into `my-pack.rooms`

Both rooms will be injected into the pool. The game picks between them randomly.

---

## Corridor + combat room pair

Use the pool system to create a matched pair: a corridor that leads into a combat room.

1. Create two root objects in the same scene:
   - `my-pack_Corridor` — long narrow room with `UnbarredDoor` exits at both ends
   - `my-pack_Chamber` — larger combat room with `MonsterLock`
2. Assign both to the same bundle
3. In `rooms.json`, set `"pool": "HallWayStructures"` for the corridor only

> Because `rooms.json` applies to the **entire bundle**, you cannot set different pools for different prefabs in the same bundle via `rooms.json`. Use separate bundle subfolders if you need different pool settings per room.

---

## Large single-prefab multi-chamber rooms

Nothing stops you from building a large room prefab with internal corridors connecting multiple chambers. The entire structure is one prefab — one entry in the pool.

Design considerations:

- Each sub-chamber can have its own `EnemySpawn` markers
- Use only **one** `WhatLockIsNeeded` with a `MonsterLock` — the door checks if ALL enemies in `MMS.EnemiesRef` are dead, which counts all enemies in the entire room regardless of which chamber they are in
- The player spawn (`SpawnHere`) is the entry point of the whole structure
- NavMesh must cover all walkable areas — bake with `NavMeshSurface` on the root with `Collect Objects: All`

---

## Summary

| Goal | Approach |
|---|---|
| Two independent rooms, same theme | Two prefabs in one bundle, same pool |
| Corridor that leads to a chamber | Two bundles in separate subfolders, one `HallWayStructures`, one `NormalRoomStructures` |
| Large branching room | One large prefab, one `SpawnHere`, one `WhatLockIsNeeded/MonsterLock` |

---

## Next

→ [08-ideas.md](08-ideas.md) — ideas and further techniques
