World: how it is built ​
The World chapter explains the editors. This page is the map of the code: what a world is made of, what happens when one is loaded, and how it is remembered. The other pages of this section cover the editor tools (Add Object, the Unique Object tool) the placed object types that need a runtime of their own (Trigger areas, Encounters) and the spaces that change how whoever is in them moves (Movement volumes, Audio zones).
The pieces ​
| Class | What it is | Where |
|---|---|---|
WorldData | The definition of a world: a database resource (type world) with the scene path, persistence, audio, weather and config overrides | data_classes/world/ |
WorldScene | The root node of the scene of a world. Holds the WorldData, the party spawn, the respawn points, the terrain provider and the minimap and preview generators | runtime_classes/world/ |
WorldContainer | A node of the game host. Loads and unloads worlds, remembers them, applies their environment, positions the party | |
ObjectRegistry | A RefCounted that knows every NPC, interactable, trigger area and encounter of the loaded world, saves and restores them, and runs the level of detail | |
UniqueEntityData, UniqueInteractableData, TriggerAreaData, UniqueEncounterData | The uniques: one database resource per placed object (types unique_entity, unique_interactable, trigger_area, unique_encounter) | data_classes/world/ |
TriggerArea, Encounter | The nodes of the two objects that are not entities | runtime_classes/world/ |
WeatherSystem, WorldSun, WorldSkyEnvironment, the fog system | The look of the world |
A world is a definition and an instance in the usual sense: WorldData is the shared, never-changed definition; what the party did in it (dead NPCs, open chests) is the state the container keeps.
Loading a world ​
WorldContainer.load_world(system_hub, world_data, pending_spawn_override, loading_screen):
- Refuses if a load is already running or the data has no scene.
unload_current_world(): captures what the world remembers (see below) into a cache, then frees the scene and clears the registry.- Loads the scene (with the loading screen), adds it to the container and waits for
world_scene_ready, so collision and physics exist. - Registers the objects:
WorldScenecollects the nodes of its containers (Entities,Interactables,TriggerAreas) and the registry registers each one by its unique id. An NPC placed in the scene isplaced_*; one spawned while the game runs isdynamic_*. - Restores what the world remembered, if the party is arriving by a swap (a loaded game restores in phase 4 of the load instead).
- Sets up the fog of war for the world and restores its explored image.
- Positions the party (
_position_party_at_spawn), by priority: the pending spawn override (a rabbit hole id, or an exact position and rotation), else theparty_spawnmarker. - Applies the environment: time, sun, sky and environment configs (the override of the world, else the project default), through
SystemHub.apply_environment_configs. The running game clock is not set back; only a different time config moves the time of day. A new game sets the clock itself. - Starts the default weather (
WeatherSystem.start_world_weather) and activates the NPC behaviors if the party exists. - Emits
world_loading_finished.
The spawn override is a dictionary: {"type": "rabbit_hole", "id": <unique id of the interactable>} or {"type": "position", "pos": Vector3, "rot": Vector3}. An id the world does not have falls back to the party spawn with a warning.
Persistence ​
WorldData.persistance_logic decides what the container keeps when the party leaves:
| Logic | The cache entry | Saved to a file |
|---|---|---|
PERSISTANT | kept | yes |
INSTANCE | none (only the interactables with allow_partial_persistence) | no |
TIMED_RESET | kept with an exit_timestamp; forgotten when total_game_hours - exit_timestamp in seconds reaches reset_duration | yes |
SESSION_ONLY | kept in session_worlds_cache | no |
_get_saved_world_state decides on return; with allow_partial_persistence the world's interactables are kept in the cases where the rest starts over. The clock is ChronoManager.total_game_hours, the running hours that never wrap. to_save_data always saves the world the party is in, exactly as it is, whatever its logic. reset_session_state() (called by the new-game cleanup of the TransitionManager) empties the caches and the fog cache.
The registry ​
ObjectRegistry keeps placed_* dictionaries by unique id and dynamic_* lists. It:
- registers and unregisters objects, and notices when one leaves the tree (a freed node unregisters itself);
- creates a behavior controller for each NPC (
register_controller) and, everylod_optimization_interval, moves a batch of NPCs between level of detail levels by their distance from the party (HIGH_DETAILtoCULLED, thresholds and intervals in the Gameplay Config); - spawns (
spawn_npc,spawn_pet,spawn_interactable,spawn_dynamic_entity); - saves (
to_save_data: placed objects by unique id with their state, dynamic ones with their definition id and position) and restores (from_save_data). A placed NPC that is not in the save is removed from the scene; a dynamic one is made again from its definition.
Encounters and trigger areas are registered for lookup (get_encounter, get_trigger_area). An encounter saves its state and whether it is active (placed_encounters); its members are NPCs and are saved as NPCs. A trigger area has nothing to save.
The registry hooks the party for the NPC level scaling rules: when the party's levels change, living NPCs rescale (see NpcLevels).
Extending ​
| You want | Do |
|---|---|
| A new kind of placed object | A node that creates its own unique data in the editor (see TriggerArea and Encounter: a _check_and_create_* on enter, a sync on scene_pre_save, a cleanup on delete), is registered by ObjectRegistry (register_*), and is collected by WorldScene. Add a choice to AddObjectToolbarManager |
| A new world config field | Add an @export to TimeConfig, SunConfig, SkyConfig or EnvironmentConfig; the config editor builds its fields from the exports, and groups with @export_group. Apply it in ChronoManager, WorldSun or WorldSkyEnvironment |
| A new spawn override | Add a match branch to WorldContainer._apply_gameroot_spawn_override |
| A new persistence rule | WorldContainer._get_saved_world_state and _capture_current_world_state |
The classes ​
World data ​
| Class | What it is |
|---|---|
| ShelterPreset | The settings of a shelter volume that make it a wooden cabin, a cave or a tent: how much of the weather it keeps off, whether it stops the exposed effects, the audio profile and the weather sounds. |
| ShelterProfile | What a kind of shelter does (a wooden cabin, a cave, a tent, a stone hall): how much of the weather it keeps off, what it does to the sound and which sound plays inside for each kind of weather. |
| ShelterWeatherSound | One line of the weather sounds of a shelter: for a kind of weather (rain, snow, wind ...) the track that plays while the camera is inside and that weather is on. |
| TriggerAreaData | Map this trigger area belongs to |
| UniqueEncounterData | UniqueEncounterData defines both the behavior AND unique instance data for an encounter. |
| UniqueEntityData | A placed NPC: what the world keeps about one NPC in one world. |
| UniqueInteractableData | A placed object: what the world keeps about one interactable in one world. |
| UniqueSpawnerData | A placed spawner: what the world keeps about one Spawner node in one world. |
| WeatherTable | A table of weathers for a place that has a weather of its own, not the same all the time: the lines are weathers (or a clear sky) with a weight and how long they last. |
| WeatherTableEntry | One line of a weather table: a weather (or a clear sky) with how likely it is and how long it lasts when it is picked. |
| WorldData | Pure data storage for world information Contains only world metadata, spawn points, and references to unique objects |
| ZoneDefinition | A zone: a named place of the map ("Elderwood", "The Sunken Caves", "Port Haven"). |
| ZoneLookup | What is known about the zones from the database alone: who is whose parent, the chain of a zone, its full name. |
| ZoneMapEntry | The picture of one zone, made for the world map: a top-down picture (a file in the maps folder of the world) and the area of the world it covers (a square), so any place of the world is a place of the picture and a marker can be put on it where its thing really is. |
World configs ​
| Class | What it is |
|---|---|
| EnvironmentConfig | Configuration for Environment visual settings |
| SkyConfig | Configuration for the sky shader appearance |
| SunConfig | The PATH of the sun: where it is in the sky and when. |
| TimeConfig | Configuration for time flow and day/night cycle timing |
| WeatherConfig | A weather of the world: what falls (a particle scene), how the wind blows and what the weather does to the ground (wet and darker, tinted, covered by snow, sand, ash or anything else). |
| WeatherEffectEntry | An effect a weather gives to those who stand in it (a burn in a rain of embers, a Wet debuff in the rain), and how. |
Encounters ​
| Class | What it is |
|---|---|
| CallReinforcementsAction | Spawns reinforcement entities at designated positions to aid the group |
| EncounterAction | EncounterAction is the base class for actions that affect the entire encounter group. |
| EncounterQuestActivateAction | Activates a specific quest when the encounter reaction triggers |
| EncounterReaction | EncounterReaction handles group-level responses to encounter events. |
| EncounterRecords | What the editor needs to know about the encounters of a world. |
| ForceGroupTargetAction | Forces all group members to target the same enemy based on selection criteria |
| GroupFormationAction | Organizes group members into specific formations |
| ModifyGroupBehaviorAction | Modifies the group's overall behavior and aggression level |
| SpawnEffectAction | Spawns a world effect at a specific position during an encounter |
| TriggerEventAction | Triggers a specific event in the event system |
Runtime ​
| Class | What it is |
|---|---|
| AmbientSound | A sound that comes from a place in the world: a waterfall, a campfire, a market, wind in a ruin. |
| AudioProfileStack | The audio profile that is on now. |
| AudioZone | A place that changes how the world sounds while the camera is inside it: a cave with echo, a house that muffles the weather outside, a tunnel. |
| ChronicleTerrainProvider | Answers the TerrainService from a ChronicleTerrain: heights, directions and holes come straight from the data of the terrain (no physics, no rendering: the same answer on a server as in front of a screen). |
| EncounterGroup | An encounter while the game runs: a group of NPCs that fights as one. |
| FogExplorationData | Stores fog of war exploration data for a single map. |
| FogOfWarCompositorEffect | CompositorEffect that renders fog of war as a post-process. |
| FogOfWarSystem | FogOfWarSystem manages fog of war using a CompositorEffect for rendering. |
| HTerrainProvider | Tells which surface type the ground is at a position on a Heightmap Terrain (HTerrain): the texture under the position is looked up in texture_surface_map, and default_surface is used when it has no entry. |
| Light | LightEffect manages light sources and associated audio effects in the game world. |
| MovementVolume | A space that changes how whoever is in it moves: water to swim in, a room with no gravity, a cloud to fly through, a pool of lava that hurts. |
| MovementVolumeCamera | The look the screen gets while the camera is inside a movement volume (underwater: a tint over the screen and fog; the sound is the business of AudioProfileStack). |
| ObjectRegistry | ObjectRegistry - manages all NPCs, Interactables, Trigger areas, and special Encounters with advanced LOD system Integrated with CombatSystem's encounter management for coordinated combat behavior Features configurable LOD system via GameplayConfig, behavior optimization, and comprehensive performance management Handles registration, spawning, interaction tracking, and state management Provides centralized access for quest systems, events, and ability effects |
| Shelter | Questions about the shelter volumes of the world: how sheltered is a point, by which volume. |
| ShelterVolume | A place that keeps the weather off: a cabin, a cave, a tent, a porch. |
| SpaceVolume | A space in a world, given by the shape of its CollisionShape3D child (a box, sphere, cylinder or capsule). |
| Spawner | A spawner: a place in a world that makes things appear and keeps the place alive. |
| TerraBrushProvider | Tells which surface type the ground is at a position on a TerraBrush terrain: the texture under the position is looked up in texture_surface_map, and default_surface is used when it has no entry. |
| Terrain3DProvider | Tells which surface type the ground is at a position on a Terrain3D terrain: the texture under the position is looked up in texture_surface_map, and default_surface is used when it has no entry. |
| TerrainProvider | The terrain of a world, seen by the TerrainService. |
| TriggerArea | Trigger area node that creates and manages its own TriggerAreaData in the database. |
| VolumeLook | The look of a movement volume: a mesh made from its box shape (the top, the bottom or all six faces), with the material you give it (a shader, or a texture). |
| VoxelTerrainProvider | Tells which surface type the ground is at a position on a voxel terrain (Voxel Tools): the voxel type under the position is looked up in voxel_type_map, and default_surface is used when it has no entry. |
| WeatherExposure | Gives the exposed effects of the weather (WeatherConfig.exposed_effects) to those who stand in it, and takes them away again. |
| WeatherGround | The height of the terrain around the camera as a picture, for the particles of the weather. |
| WeatherScreen | The screen look of a weather while it changes: a blend of two ScreenLooks (the weather coming in, going out, a shelter weakening it). |
| WeatherSystem | Deals with weather application logic: which weather is wanted (an event's choice for the zone, an event's choice for the world, the weather or table of the zone the party is in, the weather or table of the world), the particles that fall, the wind, the ground (TerrainWeatherDriver) and the sky, fog and light the weather is laid on (WorldSkyEnvironment.set_weather_look, see WeatherLook) |
| WorldContainer | Lightweight coordinator for world management Handles world transitions and delegates object queries to the current WorldScene |
| WorldMapMaker | What is worked out and written when the pictures of a world's map are made (the buttons Generate Map Preview, Generate Zone Maps and Generate Reference Sheet of the WorldScene): which area each zone's picture covers and how high the camera goes, where the files go and what they are called, and the reference sheet a person who draws a stylized map traces. |
| WorldScene | WorldScene manages all objects within a specific map/scene Handles object discovery, tracking, and provides query methods |
| WorldSkyEnvironment | Preloaded stylized sky shader |
| WorldSun | The sun of the game: a DirectionalLight3D that follows the game clock. |
| ZoneMap | The zones of a world as a picture from above, the same area the map image of the world covers: one byte for each cell, the number of the zone there (0 = no zone). |
| ZoneTracker | Watches which zone the party is in and tells the game when it changes. |
| ZoneVolume | A zone volume: a box, sphere, cylinder or capsule (the shape of its CollisionShape3D child) that puts the party in a zone while it is inside. |
Editor tools ​
| Class | What it is |
|---|---|
| EncounterReactionsEditor | Embedded editor for UniqueEncounterData.reactions property Used by UniqueObjectInspector to provide a custom interface for the reactions array |
| UniqueObjectInspector | Dynamic inspector for unique object data (NPC, Encounter, InteractableObject) Displays in the bottom dock when one of these nodes is selected Similar to EffectDynamicPropertyPanel but for UniqueData resources |