ItemSlot.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. void update();
  38. int numberOfAddableItems(const ItemStack* zStack, Direction dir) const;
  39. const ItemStack* zStack() const;
  40. int getPullPriority() const;
  41. int getPushPriority() const;
  42. bool isFull() const;
  43. int getFreeSpace() const;
  44. bool isEmpty() const;
  45. int getNumberOfItems() const;
  46. const Framework::Text& getName() const;
  47. int getId() const;
  48. };