Add files via upload

This commit is contained in:
Onran
2024-02-23 17:12:00 +09:00
committed by GitHub
parent a5087cf221
commit 8130b0626f
17 changed files with 95 additions and 39 deletions
+5 -13
View File
@@ -3,34 +3,26 @@
#include "../voxels/FlatWorldGenerator.h"
#include "../content/Content.h"
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <function>
std::map<std::string, std::function> generators;
template <typename T>
void WorldGenerators::addGenerator(std::string id) {
using create_func = std::function<T*>(const Content*);
generators[id] = create_func
}
std::vector<std::string> WorldGenerators::getGeneratorsIDs() {
std::vector<std::string> ids;
for(std::map<std::string, std::function>::iterator it = generators.begin(); it != generators.end(); ++it) {
for(std::map<std::string, gen_constructor>::iterator it = generators.begin(); it != generators.end(); ++it) {
ids.push_back(it->first);
}
return ids;
}
std::string WorldGenerators::getDefaultWorldGeneratorID() {
std::string WorldGenerators::getDefaultGeneratorID() {
return "core:default";
}
WorldGenerator* WorldGenerators::createWorldGenerator(std::string id, const Content* content) {
for(std::map<std::string, std::function>::iterator it = generators.begin(); it != generators.end(); ++it) {
WorldGenerator* WorldGenerators::createGenerator(std::string id, const Content* content) {
for(std::map<std::string, gen_constructor>::iterator it = generators.begin(); it != generators.end(); ++it) {
if(id == it->first) {
return (WorldGenerator*) it->second(content);
}