WorldGenerator.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <Critical.h>
  3. #include <Thread.h>
  4. #include "Area.h"
  5. #include "DimensionGenerator.h"
  6. class WorldGenerator : public Framework::Thread
  7. {
  8. private:
  9. Framework::Critical cs;
  10. Framework::Array<Area> requestQueue;
  11. Framework::RCArray<DimensionGenerator> dimensionGenerators;
  12. bool exit;
  13. int seed;
  14. Framework::JSON::Validator::JSONValidator *buildConfigValidator();
  15. void loadConfig(
  16. const char* path, Framework::JSON::Validator::JSONValidator *zValidator);
  17. void loadDimensionConfig(Framework::JSON::JSONValue* zConfig);
  18. void addMissingDimensions();
  19. DimensionGenerator* zGenerator(int dimensionId);
  20. public:
  21. WorldGenerator(int seed);
  22. ~WorldGenerator();
  23. void thread() override;
  24. void requestGeneration(Area request);
  25. void exitAndWait();
  26. Framework::Either<Block*, int> generateSingleBlock(
  27. Framework::Vec3<int> location, int dimensionId);
  28. bool spawnStructure(Framework::Vec3<int> location,
  29. int dimensionId,
  30. std::function<bool(GeneratorTemplate* tmpl)> filter);
  31. };