OpenEnroth 52af553
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
ChestInventory Class Reference

#include <Inventory.h>

Inheritance diagram for ChestInventory:
Inventory

Public Member Functions

 ChestInventory (Sizei size)
 
 ChestInventory ()
 
int size () const
 
int capacity () const
 
Sizei gridSize () const
 
Recti gridRect () const
 
auto entries (this auto &&self)
 
auto items (this auto &&self)
 
auto items (this auto &&self, ItemId itemId)
 
InventoryEntry entry (Pointi position)
 
InventoryConstEntry entry (Pointi position) const
 
InventoryEntry entry (ItemSlot slot)
 
InventoryConstEntry entry (ItemSlot slot) const
 
InventoryEntry entry (int index)
 
InventoryConstEntry entry (int index) const
 
bool canAdd (Pointi position, Sizei size) const
 
bool canAdd (Pointi position, const Item &item) const
 
bool canAdd (Sizei size) const
 
bool canAdd (const Item &item) const
 
InventoryEntry add (Pointi position, const Item &item)
 
InventoryEntry add (const Item &item)
 
InventoryEntry tryAdd (Pointi position, const Item &item)
 
InventoryEntry tryAdd (const Item &item)
 
bool canStash () const
 
InventoryEntry stash (const Item &item)
 
InventoryEntry tryStash (const Item &item)
 
Item take (InventoryEntry entry)
 
std::optional< PointifindSpace (Sizei size) const
 
std::optional< PointifindSpace (const Item &item) const
 
InventoryEntry find (ItemId itemId)
 
InventoryConstEntry find (ItemId itemId) const
 
void clear ()
 

Friends

class Inventory
 
void snapshot (const ChestInventory &src, Chest_MM7 *dst)
 
void reconstruct (const Chest_MM7 &src, ChestInventory *dst, ContextTag< int > chestId)
 

Additional Inherited Members

- Private Member Functions inherited from Inventory
 Inventory (Sizei gridSize, int capacity)
 
 Inventory ()
 
int size () const
 
int capacity () const
 
Sizei gridSize () const
 
Recti gridRect () const
 
auto entries (this auto &&self)
 
auto items (this auto &&self)
 
auto items (this auto &&self, ItemId itemId)
 
InventoryEntry entry (Pointi position)
 
InventoryConstEntry entry (Pointi position) const
 
InventoryEntry entry (ItemSlot slot)
 
InventoryConstEntry entry (ItemSlot slot) const
 
InventoryEntry entry (int index)
 
InventoryConstEntry entry (int index) const
 
bool canAdd (Pointi position, Sizei size) const
 
bool canAdd (Pointi position, const Item &item) const
 
bool canAdd (Sizei size) const
 
bool canAdd (const Item &item) const
 
InventoryEntry add (Pointi position, const Item &item)
 
InventoryEntry add (const Item &item)
 
InventoryEntry tryAdd (Pointi position, const Item &item)
 
InventoryEntry tryAdd (const Item &item)
 
bool canEquip (ItemSlot slot) const
 
InventoryEntry equip (ItemSlot slot, const Item &item)
 
InventoryEntry tryEquip (ItemSlot slot, const Item &item)
 
bool canStash () const
 
InventoryEntry stash (const Item &item)
 
InventoryEntry tryStash (const Item &item)
 
Item take (InventoryEntry entry)
 
std::optional< PointifindSpace (Sizei size) const
 
std::optional< PointifindSpace (const Item &item) const
 
InventoryEntry find (ItemId itemId)
 
InventoryConstEntry find (ItemId itemId) const
 
void clear ()
 
- Static Private Attributes inherited from Inventory
static constexpr std::size_t MAX_ITEMS = 140
 

Detailed Description

Thin facade that exposes only the chest‑appropriate subset of Inventory interface.

Constructor & Destructor Documentation

◆ ChestInventory() [1/2]

ChestInventory::ChestInventory ( Sizei  size)
inlineexplicit

◆ ChestInventory() [2/2]

ChestInventory::ChestInventory ( )
inline

Member Function Documentation

◆ add() [1/2]

InventoryEntry Inventory::add ( const Item item)

◆ add() [2/2]

InventoryEntry Inventory::add ( Pointi  position,
const Item item 
)

◆ canAdd() [1/4]

bool Inventory::canAdd ( const Item item) const
inline

◆ canAdd() [2/4]

bool Inventory::canAdd ( Pointi  position,
const Item item 
) const
inline

◆ canAdd() [3/4]

bool Inventory::canAdd ( Pointi  position,
Sizei  size 
) const

◆ canAdd() [4/4]

bool Inventory::canAdd ( Sizei  size) const

◆ canStash()

bool Inventory::canStash ( ) const

◆ capacity()

int Inventory::capacity ( ) const
inline
Returns
How many items can this inventory object hold.

◆ clear()

void Inventory::clear ( )

◆ entries()

auto Inventory::entries ( this auto &&  self)
inline
Parameters
self*this.
Returns
A range of InventoryEntry or InventoryConstEntry objects for items in this inventory. Returned entries are never invalid.

◆ entry() [1/6]

InventoryEntry Inventory::entry ( int  index)
Parameters
indexEntry index to look up an item.
Returns
Inventory entry at index, or an invalid entry if index is out of bounds or if there is no item at index.

◆ entry() [2/6]

InventoryConstEntry Inventory::entry ( int  index) const
inline

◆ entry() [3/6]

InventoryEntry Inventory::entry ( ItemSlot  slot)
Parameters
slotEquipment slot to look up an item.
Returns
Inventory entry for an item equipped in slot, or an invalid entry if that slot is empty.

◆ entry() [4/6]

InventoryConstEntry Inventory::entry ( ItemSlot  slot) const
inline

◆ entry() [5/6]

InventoryEntry Inventory::entry ( Pointi  position)
Parameters
positionGrid position to look up an item.
Returns
Inventory entry at provided grid position, or an invalid entry if position is out of bounds or if the grid at position is empty.

◆ entry() [6/6]

InventoryConstEntry Inventory::entry ( Pointi  position) const
inline

◆ find() [1/2]

InventoryEntry Inventory::find ( ItemId  itemId)

◆ find() [2/2]

InventoryConstEntry Inventory::find ( ItemId  itemId) const
inline

◆ findSpace() [1/2]

std::optional< Pointi > Inventory::findSpace ( const Item item) const
inline

◆ findSpace() [2/2]

std::optional< Pointi > Inventory::findSpace ( Sizei  size) const

◆ gridRect()

Recti Inventory::gridRect ( ) const
inline
Returns
Rect for this inventory's grid, in cells. Mainly useful for checks like inventory.gridRect().contains(pos).

◆ gridSize()

Sizei Inventory::gridSize ( ) const
inline
Returns
Size of this inventory's grid, in cells.

◆ items() [1/2]

auto Inventory::items ( this auto &&  self)
inline
Parameters
self*this.
Returns
A range of Item objects for items in this inventory. Returned items are never ITEM_NULL.

◆ items() [2/2]

auto Inventory::items ( this auto &&  self,
ItemId  itemId 
)
inline
Parameters
self*this.
itemIdItem id to filter for.
Returns
A range of Item objects for items in this inventory with the given itemId.

◆ size()

int Inventory::size ( ) const
inline
Returns
How many items are currently held in this inventory object.

◆ stash()

InventoryEntry Inventory::stash ( const Item item)

◆ take()

Item Inventory::take ( InventoryEntry  entry)

◆ tryAdd() [1/2]

InventoryEntry Inventory::tryAdd ( const Item item)

◆ tryAdd() [2/2]

InventoryEntry Inventory::tryAdd ( Pointi  position,
const Item item 
)

◆ tryStash()

InventoryEntry Inventory::tryStash ( const Item item)

Friends And Related Function Documentation

◆ Inventory

friend class Inventory
friend

◆ reconstruct

void reconstruct ( const Chest_MM7 src,
ChestInventory dst,
ContextTag< int >  chestId 
)
friend

◆ snapshot

void snapshot ( const ChestInventory src,
Chest_MM7 dst 
)
friend

The documentation for this class was generated from the following file: