PlaceableProof.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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* createValue(
  33. Framework::JSON::JSONObject* zJson) const override;
  34. void fromJson(PlaceableProofAnd* zResult,
  35. Framework::JSON::JSONObject* zJson) const override;
  36. void toJson(PlaceableProofAnd* zObject,
  37. Framework::JSON::JSONObject* zResult) const override;
  38. JSONObjectValidationBuilder* addToValidator(
  39. JSONObjectValidationBuilder* builder) const override;
  40. Framework::Text getTypeToken() const override;
  41. };
  42. class PlaceableProofOr : public PlaceableProof
  43. {
  44. private:
  45. Framework::RCArray<PlaceableProof> proofs;
  46. public:
  47. PlaceableProofOr();
  48. bool isPlacable(
  49. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  50. void addProof(PlaceableProof* proof);
  51. const Framework::RCArray<PlaceableProof>& getProofs() const;
  52. };
  53. class PlaceableProofOrFactory
  54. : public SubTypeFactory<PlaceableProof, PlaceableProofOr>
  55. {
  56. public:
  57. PlaceableProofOrFactory();
  58. PlaceableProofOr* createValue(
  59. Framework::JSON::JSONObject* zJson) const override;
  60. void fromJson(PlaceableProofOr* zResult,
  61. Framework::JSON::JSONObject* zJson) const override;
  62. void toJson(PlaceableProofOr* zObject,
  63. Framework::JSON::JSONObject* zResult) const override;
  64. JSONObjectValidationBuilder* addToValidator(
  65. JSONObjectValidationBuilder* builder) const override;
  66. Framework::Text getTypeToken() const override;
  67. };
  68. class PlaceableProofNot : public PlaceableProof
  69. {
  70. private:
  71. PlaceableProof* proof;
  72. public:
  73. PlaceableProofNot();
  74. ~PlaceableProofNot();
  75. bool isPlacable(
  76. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  77. void setProof(PlaceableProof* proof);
  78. PlaceableProof* zProof() const;
  79. };
  80. class PlaceableProofNotFactory
  81. : public SubTypeFactory<PlaceableProof, PlaceableProofNot>
  82. {
  83. public:
  84. PlaceableProofNotFactory();
  85. PlaceableProofNot* createValue(
  86. Framework::JSON::JSONObject* zJson) const override;
  87. void fromJson(PlaceableProofNot* zResult,
  88. Framework::JSON::JSONObject* zJson) const override;
  89. void toJson(PlaceableProofNot* zObject,
  90. Framework::JSON::JSONObject* zResult) const override;
  91. JSONObjectValidationBuilder* addToValidator(
  92. JSONObjectValidationBuilder* builder) const override;
  93. Framework::Text getTypeToken() const override;
  94. };
  95. class PlaceableProofBlockFilter : public PlaceableProof
  96. {
  97. private:
  98. Direction direction;
  99. int distance;
  100. BlockFilter* filter;
  101. public:
  102. PlaceableProofBlockFilter();
  103. ~PlaceableProofBlockFilter();
  104. bool isPlacable(
  105. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  106. void setDirection(Direction direction);
  107. Direction getDirection() const;
  108. void setDistance(int distance);
  109. int getDistance() const;
  110. void setFilter(BlockFilter* filter);
  111. BlockFilter* zFilter() const;
  112. };
  113. class PlaceableProofBlockFilterFactory
  114. : public SubTypeFactory<PlaceableProof, PlaceableProofBlockFilter>
  115. {
  116. public:
  117. PlaceableProofBlockFilterFactory();
  118. PlaceableProofBlockFilter* createValue(
  119. Framework::JSON::JSONObject* zJson) const override;
  120. void fromJson(PlaceableProofBlockFilter* zResult,
  121. Framework::JSON::JSONObject* zJson) const override;
  122. void toJson(PlaceableProofBlockFilter* zObject,
  123. Framework::JSON::JSONObject* zResult) const override;
  124. JSONObjectValidationBuilder* addToValidator(
  125. JSONObjectValidationBuilder* builder) const override;
  126. Framework::Text getTypeToken() const override;
  127. };
  128. // TODO: add item Filter