Skip to content

Commit 09d4607

Browse files
Move biome definitions to YAML configuration with hot reload support (#404)
* Biomes can now be defined in the world configuration and loaded dynamically - Enabling biome definitions outsite of code - Biomes reload in the same way as items * Added hot reload to biomes "reload biomes" will now hot reload changes, like on items. * Fixed review comments and minor other improvements 1. YAML tags changed to lowercase - Changed yaml:"darkArea" to yaml:"darkarea" - Changed yaml:"litArea" to yaml:"litarea" - Changed yaml:"requiredItemId" to yaml:"requireditemid" - Changed yaml:"usesItem" to yaml:"usesitem" - All YAML tags now follow the lowercase convention as requested 2. Implemented Loadable interface methods - Added Id() method that returns the biome ID as a string - Added Validate() method with proper validation logic - Added Filepath() method that returns the individual file path - BiomeInfo now satisfies the Loadable[string] interface 3. Refactored to use fileloader.LoadAllFlatFiles pattern - Converted from single biomes.yaml file to individual biome files (e.g., city.yaml, forest.yaml) - Changed loading mechanism to use fileloader.LoadAllFlatFiles[string, *BiomeInfo]() - Created individual biome files in _datafiles/world/default/biomes/ directory I looked at races/mobs/items and tried to follow the same pattern. Additional fixes and changes: - Updated all references to BiomeInfo fields to use the new exported fields - Fixed method calls from Symbol() to GetSymbol() and Name() to Name field access - Fixed the return type of GetBiome() to return *BiomeInfo instead of BiomeInfo Also had to fix an unreachable code issue in mutators.go (This was a compiler error due to unreachable code after line 49 because of a 'return false') This may be intentional, but the compiler will not make the binary without this change. * Added two missing hard coded biomes Added missing hard coded biomes as regular biome files: - Land - Dungeon Also added them back as hard coded fallbacks in biomes.go * Fixed a slight duplication issue with the Dungeon biome * Simplified biome system and removed ValidateBiomes function - Removed all hardcoded biomes from biomes.go - Replaced with single default fallback biome when no files are loaded - Removed ValidateBiomes() function and its call from main.go - Changed GetAllBiomes() to return []BiomeInfo instead of []*BiomeInfo to prevent accidental modifications - Reverted mutators.go changes that were accidentally included in this branch * Cleaned up old single biomes.yaml in /default and added all the individual biomes to /empty * Fixed biome-related nil pointer panics and improved error handling - Added defensive nil checks in mapper.go before calling biome methods - Ensured default biome always exists after LoadBiomeDataFiles() is called - Added warning log when a requested biome is not found, showing biome name, room ID, and zone - Improved biome fallback logic to prevent nil pointer dereferences - Added mudlog import to rooms.go for biome warning messages * Added startup biome validation and improved missing biome handling - Added validateRoomBiomes() function in mapper that checks all rooms during PreCacheMaps() - Logs warnings at startup for rooms without biomes (when zone also has no default) - Logs warnings for rooms referencing non-existent biomes - Provides summary count of missing and invalid biome references * Removed empty line in main.go
1 parent f60710d commit 09d4607

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+475
-152
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
biomeid: cave
2+
name: Cave
3+
symbol:
4+
description: Dark areas underground.
5+
darkarea: true
6+
litarea: false
7+
requireditemid: 0
8+
usesitem: false
9+
burns: false
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
biomeid: city
2+
name: City
3+
symbol:
4+
description: Cities are generally well protected. Law enforcement will attempt to
5+
subdue those who murder or steal. It's generally considered a safe area although
6+
it's not unknown for predators to hunt within their walls.
7+
darkarea: false
8+
litarea: true
9+
requireditemid: 0
10+
usesitem: false
11+
burns: false
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
biomeid: cliffs
2+
name: Cliffs
3+
symbol:
4+
description: Steep, rocky areas that can be dangerous to navigate.
5+
darkarea: false
6+
litarea: false
7+
requireditemid: 0
8+
usesitem: false
9+
burns: false
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
biomeid: desert
2+
name: Desert
3+
symbol: '*'
4+
description: Harsh and dry.
5+
darkarea: false
6+
litarea: false
7+
requireditemid: 0
8+
usesitem: false
9+
burns: false
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
biomeid: dungeon
2+
name: Dungeon
3+
symbol:
4+
description: These are cave-like underground areas built with a purpose.
5+
darkarea: true
6+
litarea: false
7+
requireditemid: 0
8+
usesitem: false
9+
burns: false
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
biomeid: farmland
2+
name: Farmland
3+
symbol: ','
4+
description: Cultivated land used for growing crops.
5+
darkarea: false
6+
litarea: false
7+
requireditemid: 0
8+
usesitem: false
9+
burns: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
biomeid: forest
2+
name: Forest
3+
symbol:
4+
description: Forests are generally green and verdant. All types of creatures lurk
5+
within them. Plenty of trees.
6+
darkarea: false
7+
litarea: false
8+
requireditemid: 0
9+
usesitem: false
10+
burns: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
biomeid: fort
2+
name: Fort
3+
symbol:
4+
description: Forts are cities or dwellings that are fortified.
5+
darkarea: false
6+
litarea: true
7+
requireditemid: 0
8+
usesitem: false
9+
burns: false
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
biomeid: house
2+
name: House
3+
symbol:
4+
description: Standard domiciles and other dwellings.
5+
darkarea: false
6+
litarea: true
7+
requireditemid: 0
8+
usesitem: false
9+
burns: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
biomeid: land
2+
name: Land
3+
symbol:
4+
description: The world is made of land.
5+
darkarea: false
6+
litarea: true
7+
requireditemid: 0
8+
usesitem: false
9+
burns: false

0 commit comments

Comments
 (0)