|
OpenEnroth 731eccc
|
#include <Inventory.h>
Classes | |
| struct | InventoryRecord |
Static Public Attributes | |
| static constexpr std::size_t | MAX_ITEMS = 140 |
Private Member Functions | |
| int | findFreeIndex () const |
| bool | isGridFree (Pointi position, Sizei size) const |
| InventoryEntry | addAt (Pointi position, const Item &item, int index) |
| InventoryEntry | equipAt (ItemSlot slot, const Item &item, int index) |
| InventoryEntry | stashAt (const Item &item, int index) |
| void | checkInvariants () const |
| auto | availableRecords (this auto &&self) |
| InventoryEntry | entryAt (int index) |
| InventoryConstEntry | entryAt (int index) const |
Private Attributes | |
| Sizei | _gridSize |
| int | _size = 0 |
| int | _capacity = 0 |
| std::array< InventoryRecord, MAX_ITEMS > | _records |
| std::array< int, MAX_ITEMS > | _grid = {{}} |
| IndexedArray< int, ITEM_SLOT_FIRST_VALID, ITEM_SLOT_LAST_VALID > | _equipment = {{}} |
Friends | |
| class | InventoryConstEntry |
| void | snapshot (const ChestInventory &src, Chest_MM7 *dst) |
| void | reconstruct (const Chest_MM7 &src, ChestInventory *dst, ContextTag< int > chestId) |
| void | snapshot (const CharacterInventory &src, Character_MM7 *dst) |
| void | reconstruct (const Character_MM7 &src, CharacterInventory *dst, ContextTag< int > characterIndex) |
Core container that stores items for both chests and characters.
Inventory stores items inside an array, so all items have indices. These indices are exposed through InventoryConstEntry::index and Inventory::entry(int). In practice there shouldn't be a lot of use cases where direct access to item indices is needed.
|
explicit |
|
inline |
Constructs a 1x1 inventory that can hold MAX_ITEMS items.
| InventoryEntry Inventory::add | ( | const Item & | item | ) |
| InventoryEntry Inventory::add | ( | Pointi | position, |
| const Item & | item | ||
| ) |
|
private |
|
inlineprivate |
|
inline |
| bool Inventory::canAdd | ( | Sizei | size | ) | const |
| bool Inventory::canEquip | ( | ItemSlot | slot | ) | const |
| bool Inventory::canStash | ( | ) | const |
|
inline |
|
private |
| void Inventory::clear | ( | ) |
|
inline |
| self | *this. |
InventoryEntry or InventoryConstEntry objects for items in this inventory. Returned entries are never invalid.
|
inline |
| self | *this. |
| itemId | Item id to filter for. |
InventoryEntry or InventoryConstEntry objects for items in this inventory with the given itemId. Returned entries are never invalid. | InventoryEntry Inventory::entry | ( | int | index | ) |
| index | Entry index to look up an item. |
index, or an invalid entry if index is out of bounds or if there is no item at index.
|
inline |
| InventoryEntry Inventory::entry | ( | ItemSlot | slot | ) |
| slot | Equipment slot to look up an item. |
slot, or an invalid entry if that slot is empty.
|
inline |
| InventoryEntry Inventory::entry | ( | Pointi | position | ) |
| position | Grid position to look up an item. |
position is out of bounds or if the grid at position is empty.
|
inline |
|
inlineprivate |
|
inlineprivate |
| InventoryEntry Inventory::equip | ( | ItemSlot | slot, |
| const Item & | item | ||
| ) |
|
private |
|
inline |
| self | *this. |
InventoryEntry or InventoryConstEntry objects for all equipped items in this inventory. Returned entries are never invalid. | InventoryEntry Inventory::find | ( | ItemId | itemId | ) |
|
inline |
|
private |
|
inline |
| slot | Equipment slot to look up an item. |
slot, or an invalid entry if that slot is empty or if the item in the slot is non-functional (broken or out of charges).
|
inline |
|
inline |
| self | *this. |
InventoryEntry or InventoryConstEntry objects for all equipped items in this inventory that are functional (non-broken and not out of charges). Returned entries are never invalid.
|
inline |
inventory.gridRect().contains(pos).
|
inline |
| InventoryEntry Inventory::stash | ( | const Item & | item | ) |
|
private |
| Item Inventory::take | ( | InventoryEntry | entry | ) |
| InventoryEntry Inventory::tryAdd | ( | const Item & | item | ) |
| InventoryEntry Inventory::tryAdd | ( | Pointi | position, |
| const Item & | item | ||
| ) |
| InventoryEntry Inventory::tryEquip | ( | ItemSlot | slot, |
| const Item & | item | ||
| ) |
| InventoryEntry Inventory::tryStash | ( | const Item & | item | ) |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
Max number of items that can be stuffed into this inventory.
|
private |
Equipment array. Positive number is an index into _records plus one. Zero means empty.
|
private |
Backpack grid. 0 means empty cell. Positive number is an index into _records plus one. Negative number is an index into the main slot in _grid minus one.
|
private |
All items in inventory. ITEM_NULL means the slot is empty.
|
private |
Number of items in this inventory.
|
staticconstexpr |