Biome-independent structure tables#2129
Conversation
|
On the topic of this PR, I was thinking about how addons might target biomes and with the current approach they'd use biome tags. I think it may make sense to allow the structure table to use the biome's id as a tag, too. Just check if the structure table's biomeTags contains the biome's Id (it would just be an In the future I envision we start categorizing biomes. like |
|
I didn't mean to close that |
This PR splits out structures and hashing from biomes.zig into structures.zig and src/utils.zig respectively. This change should be done for the following reasons: 1. It cleans up #2129. A lot. 2. Splitting it out from biomes.zig into another file makes it a bit cleaner once we add the changes from #2129 that introduces the StructureTable struct for example. It's technically feasible to leave it all in biomes.zig, splitting it out made the most sense to me at the time for organization purposes.
|
Memory leak fixed, and I added migrations stuff to it for whenever someone needs to migrate structure_tables in the future. This should be good to go for review. |
|
Whenever this is merged, #1283 can proceed as meteorites can be made into a structure table that spawns in any biome or biomes with specific tags. (Biomes currently have no tags, but coming up with those tags could be an issue on its own to discuss) |
- Added back structureTablesById - Added sorting to the structureTables slice - Removed unused numerical id (paletteId) - Removed potentially dangerous check that returned `undefined` instead of an empty structureTable
|
@ikabod-kee could you add your special structure from https://github.com/IntegratedQuantum/Cubyz-Lore/issues/4#issuecomment-3114276769 to this PR as an entry to an ultra-rare structure table that applies to all biomes |
| for (structureList.items) |*model| { | ||
| model.chance /= totalChance; | ||
| } | ||
| } |
There was a problem hiding this comment.
Do we need this normalization here? I think it could change the chances in unexpected ways (.chance = 1 in structure table has a different meaning from .chance = 1 in the host biome) when combined with the host biome normalization or other structure tables.
| itemPalette: *assets.Palette = undefined, | ||
| toolPalette: *assets.Palette = undefined, | ||
| biomePalette: *assets.Palette = undefined, | ||
| structureTablePalette: *assets.Palette = undefined, |
There was a problem hiding this comment.
with the sorting, a palette isn't needed
Leaking the cubyz lore like that? For shame!!! (just joking XD) Sure! I'll have to rebuild it, but it should be easy. |
Fixes #1805
Implements biome-independent structure tables.
The way these work:
Structure tables are loaded into the game along with all other assets.
When loading biomes, each biome checks its biomeTags (new feature, currently unused) against the biomeTags in each structure table that was loaded previously. If any biomeTags match, add the structures from those tables into the biome's internal structure table in memory at world load time.
Additionally, if a structure table has an empty .biomeTags (len == 0), it should spawn those structures in all biomes. So those structures are added to all biomes' internal structure table.
Implementation details:
Moved hashing functions out of src/server/terrain/biomes.zig into src/utils/hash.zig
Moved SimpleStructureModel into src/server/terrain/structures.zig from src/server/terrain/biomes.zig.
Example structure table .zig.zon in assets/cubyz/structure_tables in this branch.