Add files via upload
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user