PlantConfig.h 2.0 KB

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