PlantConfig.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include "JsonExpression.h"
  3. #include "TypeRegistry.h"
  4. class PlantLocation
  5. {
  6. public:
  7. static const int CAVE = 1;
  8. static const int UNDERWATER = 2;
  9. static const int SURFACE = 4;
  10. };
  11. class PlantConfig : public virtual Framework::ReferenceCounter
  12. {
  13. private:
  14. JBoolExpression* condition;
  15. Noise* noise;
  16. Framework::JSON::JSONObject* noiseConfig;
  17. double threshold;
  18. int locations;
  19. Framework::Text plantBlockTypeName;
  20. int plantblockTypeId;
  21. int plantHeight;
  22. public:
  23. PlantConfig();
  24. ~PlantConfig();
  25. void initialize(JExpressionMemory* zMemory);
  26. double doesGeneratePlant(int x,
  27. int y,
  28. int z,
  29. int dimensionId,
  30. Chunk* zChunk,
  31. bool underground,
  32. bool underwater,
  33. int seaFluidBlockTypeId);
  34. void generatePlantAt(int x, int y, int z, int dimensionId, Chunk* zChunk);
  35. void setCondition(JBoolExpression* condition);
  36. JBoolExpression* zCondition() const;
  37. void setNoiseConfig(Framework::JSON::JSONObject* noiseConfig);
  38. Framework::JSON::JSONObject* zNoiseConfig() const;
  39. void setThreshold(double threshold);
  40. double getThreshold() const;
  41. void setLocations(int locations);
  42. int getLocations() const;
  43. void setPlantBlockTypeName(Framework::Text name);
  44. Framework::Text getPlantBlockTypeName() const;
  45. void setPlantHeight(int height);
  46. int getPlantHeight() const;
  47. };
  48. class PlantConfigFactory : public ObjectTypeFactory<PlantConfig>
  49. {
  50. public:
  51. PlantConfigFactory();
  52. PlantConfig* fromJson(Framework::JSON::JSONObject* zJson) const override;
  53. Framework::JSON::JSONObject* toJsonObject(
  54. PlantConfig* zObject) const override;
  55. JSONObjectValidationBuilder* addToValidator(
  56. JSONObjectValidationBuilder* builder) const override;
  57. };