PlaceableProof.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #pragma once
  2. #include <Array.h>
  3. #include <TypeRegistry.h>
  4. #include <Vec3.h>
  5. #include "Area.h"
  6. class Item;
  7. class BlockFilter;
  8. class PlaceableProof : public Framework::ReferenceCounter
  9. {
  10. public:
  11. PlaceableProof();
  12. virtual bool isPlacable(
  13. const Item* item, Framework::Vec3<float> pos, int dimensionId)
  14. = 0;
  15. };
  16. class PlaceableProofAnd : public PlaceableProof
  17. {
  18. private:
  19. Framework::RCArray<PlaceableProof> proofs;
  20. public:
  21. PlaceableProofAnd();
  22. bool isPlacable(
  23. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  24. void addProof(PlaceableProof* proof);
  25. const Framework::RCArray<PlaceableProof>& getProofs() const;
  26. };
  27. class PlaceableProofAndFactory
  28. : public SubTypeFactory<PlaceableProof, PlaceableProofAnd>
  29. {
  30. public:
  31. PlaceableProofAndFactory();
  32. PlaceableProofAnd* fromJson(
  33. Framework::JSON::JSONObject* zJson) const override;
  34. Framework::JSON::JSONObject* toJsonObject(
  35. PlaceableProofAnd* zObject) const override;
  36. JSONObjectValidationBuilder* addToValidator(
  37. JSONObjectValidationBuilder* builder) const override;
  38. const char* getTypeToken() const override;
  39. };
  40. class PlaceableProofOr : public PlaceableProof
  41. {
  42. private:
  43. Framework::RCArray<PlaceableProof> proofs;
  44. public:
  45. PlaceableProofOr();
  46. bool isPlacable(
  47. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  48. void addProof(PlaceableProof* proof);
  49. const Framework::RCArray<PlaceableProof>& getProofs() const;
  50. };
  51. class PlaceableProofOrFactory
  52. : public SubTypeFactory<PlaceableProof, PlaceableProofOr>
  53. {
  54. public:
  55. PlaceableProofOrFactory();
  56. PlaceableProofOr* fromJson(
  57. Framework::JSON::JSONObject* zJson) const override;
  58. Framework::JSON::JSONObject* toJsonObject(
  59. PlaceableProofOr* zObject) const override;
  60. JSONObjectValidationBuilder* addToValidator(
  61. JSONObjectValidationBuilder* builder) const override;
  62. const char* getTypeToken() const override;
  63. };
  64. class PlaceableProofNot : public PlaceableProof
  65. {
  66. private:
  67. PlaceableProof* proof;
  68. public:
  69. PlaceableProofNot();
  70. ~PlaceableProofNot();
  71. bool isPlacable(
  72. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  73. void setProof(PlaceableProof* proof);
  74. PlaceableProof* zProof() const;
  75. };
  76. class PlaceableProofNotFactory
  77. : public SubTypeFactory<PlaceableProof, PlaceableProofNot>
  78. {
  79. public:
  80. PlaceableProofNotFactory();
  81. PlaceableProofNot* fromJson(
  82. Framework::JSON::JSONObject* zJson) const override;
  83. Framework::JSON::JSONObject* toJsonObject(
  84. PlaceableProofNot* zObject) const override;
  85. JSONObjectValidationBuilder* addToValidator(
  86. JSONObjectValidationBuilder* builder) const override;
  87. const char* getTypeToken() const override;
  88. };
  89. class PlaceableProofBlockFilter : public PlaceableProof
  90. {
  91. private:
  92. Direction direction;
  93. int distance;
  94. BlockFilter* filter;
  95. public:
  96. PlaceableProofBlockFilter();
  97. ~PlaceableProofBlockFilter();
  98. bool isPlacable(
  99. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  100. void setDirection(Direction direction);
  101. Direction getDirection() const;
  102. void setDistance(int distance);
  103. int getDistance() const;
  104. void setFilter(BlockFilter* filter);
  105. BlockFilter* zFilter() const;
  106. };
  107. class PlaceableProofBlockFilterFactory
  108. : public SubTypeFactory<PlaceableProof, PlaceableProofBlockFilter>
  109. {
  110. public:
  111. PlaceableProofBlockFilterFactory();
  112. PlaceableProofBlockFilter* fromJson(
  113. Framework::JSON::JSONObject* zJson) const override;
  114. Framework::JSON::JSONObject* toJsonObject(
  115. PlaceableProofBlockFilter* zObject) const override;
  116. JSONObjectValidationBuilder* addToValidator(
  117. JSONObjectValidationBuilder* builder) const override;
  118. const char* getTypeToken() const override;
  119. };
  120. // TODO: add item Filter