PlaceableProof.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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(Framework::RCArray<PlaceableProof> proofs);
  22. bool isPlacable(
  23. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  24. const Framework::RCArray<PlaceableProof>& getProofs() const;
  25. };
  26. class PlaceableProofAndFactory
  27. : public SubTypeFactory<PlaceableProof, PlaceableProofAnd>
  28. {
  29. public:
  30. PlaceableProofAndFactory();
  31. PlaceableProofAnd* fromJson(
  32. Framework::JSON::JSONObject* zJson) const override;
  33. Framework::JSON::JSONObject* toJson(
  34. PlaceableProofAnd* zObject) const override;
  35. Framework::JSON::Validator::JSONValidator* getValidator(
  36. Framework::JSON::Validator::ObjectValidationBuilder<
  37. Framework::JSON::Validator::JSONValidator>* builder) const override;
  38. Framework::Text getTypeToken() const override;
  39. };
  40. class PlaceableProofOr : public PlaceableProof
  41. {
  42. private:
  43. Framework::RCArray<PlaceableProof> proofs;
  44. public:
  45. PlaceableProofOr(Framework::RCArray<PlaceableProof> proofs);
  46. bool isPlacable(
  47. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  48. const Framework::RCArray<PlaceableProof>& getProofs() const;
  49. };
  50. class PlaceableProofOrFactory
  51. : public SubTypeFactory<PlaceableProof, PlaceableProofOr>
  52. {
  53. public:
  54. PlaceableProofOrFactory();
  55. PlaceableProofOr* fromJson(
  56. Framework::JSON::JSONObject* zJson) const override;
  57. Framework::JSON::JSONObject* toJson(
  58. PlaceableProofOr* zObject) const override;
  59. Framework::JSON::Validator::JSONValidator* getValidator(
  60. Framework::JSON::Validator::ObjectValidationBuilder<
  61. Framework::JSON::Validator::JSONValidator>* builder) const override;
  62. Framework::Text getTypeToken() const override;
  63. };
  64. class PlaceableProofNot : public PlaceableProof
  65. {
  66. private:
  67. PlaceableProof* proof;
  68. public:
  69. PlaceableProofNot(PlaceableProof* proof);
  70. ~PlaceableProofNot();
  71. bool isPlacable(
  72. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  73. PlaceableProof* zProof() const;
  74. };
  75. class PlaceableProofNotFactory
  76. : public SubTypeFactory<PlaceableProof, PlaceableProofNot>
  77. {
  78. public:
  79. PlaceableProofNotFactory();
  80. PlaceableProofNot* fromJson(
  81. Framework::JSON::JSONObject* zJson) const override;
  82. Framework::JSON::JSONObject* toJson(
  83. PlaceableProofNot* zObject) const override;
  84. Framework::JSON::Validator::JSONValidator* getValidator(
  85. Framework::JSON::Validator::ObjectValidationBuilder<
  86. Framework::JSON::Validator::JSONValidator>* builder) const override;
  87. Framework::Text 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. Direction direction, int distance, BlockFilter* filter);
  98. ~PlaceableProofBlockFilter();
  99. bool isPlacable(
  100. const Item* item, Framework::Vec3<float> pos, int dimensionId) override;
  101. Direction getDirection() const;
  102. int getDistance() const;
  103. BlockFilter* zFilter() const;
  104. };
  105. class PlaceableProofBlockFilterFactory
  106. : public SubTypeFactory<PlaceableProof, PlaceableProofBlockFilter>
  107. {
  108. public:
  109. PlaceableProofBlockFilterFactory();
  110. PlaceableProofBlockFilter* fromJson(
  111. Framework::JSON::JSONObject* zJson) const override;
  112. Framework::JSON::JSONObject* toJson(
  113. PlaceableProofBlockFilter* zObject) const override;
  114. Framework::JSON::Validator::JSONValidator* getValidator(
  115. Framework::JSON::Validator::ObjectValidationBuilder<
  116. Framework::JSON::Validator::JSONValidator>* builder) const override;
  117. Framework::Text getTypeToken() const override;
  118. };
  119. // TODO: add item Filter