BiomGenerator.h 2.6 KB

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