BiomGenerator.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include <Either.h>
  3. #include <JSON.h>
  4. #include <ReferenceCounter.h>
  5. #include "GeneratorRule.h"
  6. #include "JNoise.h"
  7. #include "JsonExpression.h"
  8. #include "StructureCollection.h"
  9. class Block;
  10. class Noise;
  11. class BiomGenerator : public virtual Framework::ReferenceCounter
  12. {
  13. private:
  14. Framework::Text name;
  15. Framework::RCArray<StructureTemplateCollection> templates;
  16. Framework::RCArray<GeneratorRule> rules;
  17. JBoolExpression* condition;
  18. Framework::Vec3<int> minStructureOffset;
  19. Framework::Vec3<int> maxStructureOffset;
  20. protected:
  21. int seed;
  22. public:
  23. BiomGenerator();
  24. ~BiomGenerator();
  25. void initialize(JExpressionMemory* zMemory);
  26. Framework::Either<Block*, int> generateBlock(int x,
  27. int y,
  28. int z,
  29. int dimensionId,
  30. JExpressionMemory* zMemory,
  31. Chunk* partialGeneratedChunk);
  32. bool isApplicable(JExpressionMemory* zMemory);
  33. void generateStructures(int x,
  34. int y,
  35. int z,
  36. int dimensionId,
  37. JExpressionMemory* zMemory,
  38. Framework::Vec3<int> minPos,
  39. Framework::Vec3<int> maxPos,
  40. Framework::RCArray<GeneratedStructure>* zResult);
  41. const Framework::RCArray<StructureTemplateCollection>& getTemplates() const;
  42. Framework::Vec3<int> getMinStructureOffset() const;
  43. Framework::Vec3<int> getMaxStructureOffset() const;
  44. void setName(Framework::Text name);
  45. Framework::Text getName() const;
  46. void setCondition(JBoolExpression* condition);
  47. JBoolExpression* getCondition() const;
  48. void addTemplate(StructureTemplateCollection* collection);
  49. const Framework::RCArray<StructureTemplateCollection>& getTemplates();
  50. void addGeneratorRule(GeneratorRule* rule);
  51. const Framework::RCArray<GeneratorRule>& getGeneratorRules() const;
  52. };
  53. class BiomGeneratorFactory : public TypeFactory<BiomGenerator>
  54. {
  55. public:
  56. BiomGeneratorFactory();
  57. BiomGenerator* createValue(
  58. Framework::JSON::JSONObject* zJson) const override;
  59. void fromJson(BiomGenerator* zResult,
  60. Framework::JSON::JSONObject* zJson) const override;
  61. void toJson(BiomGenerator* zObject,
  62. Framework::JSON::JSONObject* zResult) const override;
  63. JSONObjectValidationBuilder* addToValidator(
  64. JSONObjectValidationBuilder* builder) const override;
  65. };