Add files via upload
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
#ifndef WORLD_WORLDTYPES_H_
|
||||
#define WORLD_WORLDTYPES_H_
|
||||
#ifndef WORLD_WORLDGENERATORS_H_
|
||||
#define WORLD_WORLDGENERATORS_H_
|
||||
|
||||
#include "../voxels/WorldGenerator.h"
|
||||
#include "../content/Content.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
typedef WorldGenerator* (*gen_constructor) (const Content*);
|
||||
|
||||
|
||||
class WorldGenerators {
|
||||
static inline std::map<std::string, gen_constructor> generators = *(new std::map<std::string, gen_constructor>);
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
static void addGenerator(std::string id);
|
||||
|
||||
static std::vector<std::string> getGeneratorsIDs();
|
||||
@@ -18,4 +24,13 @@ public:
|
||||
static WorldGenerator* createGenerator(std::string id, const Content* content);
|
||||
};
|
||||
|
||||
#endif /* WORLD_WORLDTYPES_H_ */
|
||||
template <typename T>
|
||||
void WorldGenerators::addGenerator(std::string id) {
|
||||
generators[id] =
|
||||
[] (const Content* content)
|
||||
{
|
||||
return (WorldGenerator*) new T(content);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* WORLD_WORLDGENERATORS_H_ */
|
||||
Reference in New Issue
Block a user