PlantConfig.h 2.2 KB

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