ItemFilter.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <ReferenceCounter.h>
  3. #include <functional>
  4. class Item;
  5. class ItemType;
  6. class ItemSlot;
  7. class ItemFilter : public virtual Framework::ReferenceCounter
  8. {
  9. public:
  10. ItemFilter();
  11. virtual bool matchItem(const Item* zItem) const;
  12. virtual bool matchSourceSlot(ItemSlot* zSlot) const;
  13. virtual bool matchTargetSlot(ItemSlot* zSlot) const;
  14. };
  15. class CombinedItemFilter : public ItemFilter
  16. {
  17. private:
  18. ItemFilter* filterA;
  19. ItemFilter* filterB;
  20. std::function<bool(bool, bool)> op;
  21. public:
  22. CombinedItemFilter(ItemFilter* filterA, ItemFilter* filterB, std::function<bool(bool, bool)> op);
  23. bool matchItem(const Item* zItem) const override;
  24. };
  25. class AnyItemFilter : public ItemFilter
  26. {
  27. public:
  28. AnyItemFilter();
  29. bool matchItem(const Item* zItem) const override;
  30. };
  31. class TypeItemFilter : public ItemFilter
  32. {
  33. private:
  34. const ItemType* zType;
  35. public:
  36. TypeItemFilter(const ItemType* zType);
  37. bool matchItem(const Item* zItem) const override;
  38. };
  39. class SpecificSlotFilter : public ItemFilter
  40. {
  41. private:
  42. int sourceSlotId;
  43. int targetSlotId;
  44. public:
  45. SpecificSlotFilter(int sourceSlotId, int targetSlotId);
  46. bool matchSourceSlot(ItemSlot* zSlot) const override;
  47. bool matchTargetSlot(ItemSlot* zSlot) const override;
  48. };