RaRa_LevelGenerationSystem - robblofield/Tomebound-Docs GitHub Wiki
RaRa Level Generation System β Overview Documentation
RaRa_LevelEnums.cs
1. Responsibilities:
- Holds shared enums for consistent classification of levels and districts.
- Enums:
District
:Midday, Dusk, Midnight, Dawn
LevelType
:Plaza, Battleground, Gauntlet, Observatory, Treasury, Merchant, Boss
RaRa_LevelComponentProfile.cs
(Sub-ScriptableObject)
2. Responsibilities:
- Defines data for a single level component (room/section).
- Fields:
LevelType levelComponentType
β Type of the level component.GameObject levelComponentPrefab
β Prefab to instantiate for this component.bool IsSingleUseOnly
β Whether this component can only be spawned once (narrative/special rooms).
RaRa_LevelGenerationProfile.cs
(Main Pool ScriptableObject)
3. Responsibilities:
- A pool of level component profiles for a given combination of district + level type.
- Fields:
District district
β Which district this pool applies to.LevelType levelType
β Which type of levels this pool contains.List<RaRa_LevelComponentProfile> levelGenerationPool
β All components eligible for spawning.
RaRa_NoFlyList.cs
4. Responsibilities:
- A runtime pool tracking single-use-only components that canβt be spawned again this session.
- Key Methods:
AddToNoFlyList(RaRa_LevelComponentProfile profile)
IsInNoFlyList(RaRa_LevelComponentProfile profile)
ClearNoFlyList()
RaRa_LevelGenerationSystem.cs
(Runtime MonoBehaviour)
5. Responsibilities:
-
The runtime procedural generation system.
-
Key Features Implemented:
- Queue Generation:
- Generates a list (
generatedQueue
) of components to spawn. - Randomly selects components from the pool.
- Skips single-use components already in the No-Fly List.
- Adds single-use components to the No-Fly List once queued.
- Generates a list (
- Spawning Logic:
- Instantiates prefabs in order along the X-axis, offset by 5m each.
- Organizes spawned prefabs under an optional
spawnParent
. - Tracks spawned prefabs for clearing.
- Queue Generation:
-
Key Methods:
GenerateLevelQueue()
β Builds the queue.SpawnGeneratedQueue()
β Instantiates prefabs at runtime.ClearSpawnedPrefabs()
β Destroys all spawned prefabs.GetGeneratedQueue()
β Returns the current queue.
6. Editor Tools
- Custom Inspectors for:
RaRa_LevelGenerationProfile
β Enum dropdowns, warnings for mismatched types.RaRa_LevelGenerationSystem
β Buttons for:- Generate Level Queue
- Spawn Generated Queue
- Clear Spawned Prefabs
- Clear No-Fly List
Remaining Features / To-Do List
1. Room Rarity System
- Initial Rarity: Each component profile gets a rarity weight (e.g., Common, Rare, Epic, or just a float/int weight).
- Repeat Rarity Modifier: After being spawned once, a componentβs chance to be picked decreases further (stacks for each repeat).
2. Doorway & Room Connectivity
- Each prefab can have up to 4 doorway spawn points.
- Spawn 1β4 active doorways randomly for each room.
- Mark certain rooms as through-rooms or dead ends programmatically (dead ends keep only 1 doorway active).
3. Rune Gate & Rune Blocks System
- One room in the queue will be marked as Rune Gate Room:
- When spawned, finds the Rune Gate component in its prefab and activates it.
- Other rooms:
- Have ~20 possible rune block spawn points.
- Randomly activate a certain number of rune block spawns.
- Communicate with the existing Rune Gate system to:
- Assign runes to the blocks.
- Prime the Rune Gate to expect those specific rune combinations.
4. Doorway Connectivity Graph
- Procedurally connect doorways:
- Either randomly or via a more intelligent graph-based system.
- Ensure:
- A valid loop exists (all rooms are accessible via at least 1 continuous path).
- Dead ends are respected (
F -> G
example). - No isolated/unreachable rooms.
5. Misc. Polish / Future Systems
- Rotation/Position Variation for room placement.
- Grid / NavMesh Based Placement instead of simple X-axis offset.
- Debug Visualization Tools (gizmos for doorway connections).
- Save/Load Seeds for deterministic level generation.
Next Step Proposal
- Implement the Room Rarity System first (weights + repeat modifiers).
- Move into Doorway Connectivity & Through-Room Logic (larger procedural system).
- Then integrate the Rune Gate & Rune Blocks system.