PlantConfig.h 2.3 KB

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