move biomes definition to a json file

This commit is contained in:
MihailRis
2024-09-29 22:03:37 +03:00
parent d62d66cf85
commit 3784b57eed
10 changed files with 183 additions and 184 deletions
+25
View File
@@ -1,6 +1,9 @@
#include "GeneratorDef.hpp"
#include "VoxelFragment.hpp"
#include "content/Content.hpp"
#include "util/stringutil.hpp"
#include "voxels/Block.hpp"
GeneratingVoxelStructure::GeneratingVoxelStructure(
VoxelStructureMeta meta,
@@ -9,3 +12,25 @@ GeneratingVoxelStructure::GeneratingVoxelStructure(
GeneratorDef::GeneratorDef(std::string name) : name(std::move(name)) {}
void GeneratorDef::prepare(const Content* content) {
for (auto& biome : biomes) {
for (auto& layer : biome.groundLayers.layers) {
layer.rt.id = content->blocks.require(layer.block).rt.id;
}
for (auto& layer : biome.seaLayers.layers) {
layer.rt.id = content->blocks.require(layer.block).rt.id;
}
for (auto& plant : biome.plants.entries) {
plant.rt.id = content->blocks.require(plant.name).rt.id;
}
for (auto& structure : biome.structures.entries) {
const auto& found = structuresIndices.find(structure.name);
if (found == structuresIndices.end()) {
throw std::runtime_error(
"no structure "+util::quote(structure.name)+" found");
}
structure.rt.id = found->second;
}
}
}