85 void addItem(
int id,
int quantity);
90 void setItem(
int index,
int id,
int quantity);
138 std::vector<std::unique_ptr<Item>>
mItems;
virtual ~InventoryListener()=default
virtual void slotsChanged(Inventory *inventory)=0
void clear()
Reset all item slots.
void setItem(int index, int id, int quantity)
Sets the item at the given position.
bool isMainInventory() const
void removeInventoryListener(InventoryListener *listener)
int mUsed
The number of slots in use.
void addItem(int id, int quantity)
Adds a new item in a free slot.
void distributeSlotsChangedEvent()
int getLastUsedSlot() const
Returns the index of the last occupied slot or 0 if none occupied.
std::vector< std::unique_ptr< Item > > mItems
The holder of items.
std::list< InventoryListener * > mInventoryListeners
Item * findItem(int itemId) const
Searches for the specified item by it's id.
Item * getItem(int index) const
Returns the item at the specified index.
static const int NO_SLOT_INDEX
Slot has no index.
void addInventoryListener(InventoryListener *listener)
void removeItemAt(int index)
Remove the item at the specified index from the inventory.
int getFreeSlot() const
Returns id of next free slot or -1 if all occupied.
int getSize() const
Returns the size that this instance is configured for.
int getNumberOfSlotsUsed() const
Get the number of slots filled with an item.
bool contains(Item *item) const
Checks if the given item is in the inventory.
Represents one or more instances of a certain item type.