ItemSlot.h 1.2 KB

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