move biomes definition to a json file
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user