ItemSlot.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "ItemStack.h"
  3. #include "Area.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, public ItemSlotIDSetter
  12. {
  13. private:
  14. ItemStack* items;
  15. int maxSize;
  16. Directions allowedPullSide;
  17. Directions allowedPushSides;
  18. int pullPriority;
  19. int pushPriority;
  20. bool allowHigherStackSize;
  21. Framework::Text name;
  22. int id;
  23. void setId(int id) override;
  24. public:
  25. ItemSlot(Framework::Text name, int maxSize, int pullPriority, int pushPriority, int allowedPullSide, int allowedPushSides, bool allowHigherStackSize);
  26. ~ItemSlot();
  27. ItemStack* takeItemsOut(int count, Direction dir);
  28. void addItems(ItemStack* zStack, Direction dir);
  29. int numberOfAddableItems(const ItemStack* zStack, Direction dir) const;
  30. const ItemStack* zStack() const;
  31. int getPullPriority() const;
  32. int getPushPriority() const;
  33. bool isFull() const;
  34. int getFreeSpace() const;
  35. bool isEmpty() const;
  36. int getNumberOfItems() const;
  37. const Framework::Text& getName() const;
  38. int getId() const;
  39. };