ItemSlot.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include <Text.h>
  3. #include "Area.h"
  4. class Inventory;
  5. class ItemStack;
  6. class ItemSlotIDSetter
  7. {
  8. protected:
  9. virtual void setId(int id) = 0;
  10. friend Inventory;
  11. };
  12. class ItemSlot : public virtual Framework::ReferenceCounter,
  13. public ItemSlotIDSetter
  14. {
  15. private:
  16. ItemStack* items;
  17. int maxSize;
  18. Directions allowedPullSide;
  19. Directions allowedPushSides;
  20. int pullPriority;
  21. int pushPriority;
  22. bool allowHigherStackSize;
  23. Framework::Text name;
  24. int id;
  25. void setId(int id) override;
  26. public:
  27. ItemSlot(Framework::Text name,
  28. int maxSize,
  29. int pullPriority,
  30. int pushPriority,
  31. int allowedPullSide,
  32. int allowedPushSides,
  33. bool allowHigherStackSize);
  34. ~ItemSlot();
  35. ItemStack* takeItemsOut(int count, Direction dir);
  36. void addItems(ItemStack* zStack, Direction dir);
  37. int numberOfAddableItems(const ItemStack* zStack, Direction dir) const;
  38. const ItemStack* zStack() const;
  39. int getPullPriority() const;
  40. int getPushPriority() const;
  41. bool isFull() const;
  42. int getFreeSpace() const;
  43. bool isEmpty() const;
  44. int getNumberOfItems() const;
  45. const Framework::Text& getName() const;
  46. int getId() const;
  47. };