Loading...
Searching...
No Matches
AdventureCore.InventoryBase Class Referenceabstract

Detailed Description

base class for inventories, inventories manages items and the slots they are equipped to
in addition to the simple unlimited ListedInventory a possible use cases could be a re4 style case where item stacks have a position and are limited

https://adventure.softleitner.com/manual/item

Inheritance diagram for AdventureCore.InventoryBase:
AdventureCore.ListedInventory

Public Member Functions

virtual void Initialize (CharacterBase character)
 initializes the inventory including retrieving persisted data
 
bool HasItem (ItemBase item)
 checks whether the item exists in the inventory, regardless of quantity(may be 0 for stacked items to indicate they have been added at some point)
 
virtual bool HasItemQuantity (ItemBase item, int quantity=1)
 checks if the inventory has at least the passed quantity of an item
 
IEnumerable< InventoryItemGetItems (ItemBase item)
 retrieves all inventory items for a specified item
multiple entries may be resturned for items that dont stack-
or when the inventory has a maximum stack size
 
IEnumerable< InventoryItemGetItems (ItemCategory itemCategory=null, ItemSlotCategory itemSlotCategory=null)
 retrieves all inventory items for a specific category or slot
 
int GetQuantity (ItemBase item)
 calculates the total stored quantity of an item
 
int GetQuantity (ItemCategory itemCategory=null, ItemSlotCategory itemSlotCategory=null)
 calculates the total stored quantity of items filtered by an item category and/or slot
 
bool CanAddItems (ItemQuantity itemQuantity, bool fully=true)
 whether an item quantity can be added to the inventory
may be false when the quantity exceeds the capacity
 
int AddItems (ItemQuantity itemQuantity)
 adds a quantity of an item to the inventory
returns the inventory item that was added to or created
 
bool CanRemoveItems (ItemQuantity itemQuantity, bool fully=true)
 whether a quantity of items is present and can be removed
 
int RemoveItems (ItemQuantity itemQuantity)
 removes a quantity of items
 
bool CanRemoveItems (InventoryItem inventoryItem, int quantity=1, bool fully=true)
 whether a quantity of items is present and can be removed from an inventory item
 
int RemoveItems (InventoryItem inventoryItem, int quantity=1)
 removes specified quantity from the inventory item
 
bool CanUseItems (InventoryItem inventoryItem, int quantity=1)
 check if a quantity of an inventory item can be used
 
void UseItems (InventoryItem inventoryItem, int quantity=1)
 uses a quantity of an inventory item can be used
 
bool CanEquipItems (InventoryItem inventoryItem, int index=0)
 checks if an inventory item can be equipped
 
ItemSlotBase EquipItems (InventoryItem inventoryItem, int index=0)
 equipps an inventory item to a slot
 
bool CanUnequipItems (InventoryItem inventoryItem)
 checks if an inventory item can be unequipped
 
ItemSlotBase UnequipItems (InventoryItem inventoryItem)
 unequips an inventory item
 
ItemSlotBase GetSlot (ItemSlotCategory category, int index=0)
 retrieves an item slot by its category
 
ItemSlotBase GetSlot (ItemBase item, int index=0)
 retrieves an item slot for the passed item
 
GetSlot< T > (int index=0)
 retrieves an item slot by its type
 

Public Attributes

UnityEvent< ItemQuantityChanging
 
UnityEvent< ItemQuantityChanged
 
UnityEvent< ItemSlotBaseEquipmentChanged
 

Protected Member Functions

virtual void onItemsChanging (ItemQuantity itemQuantity)
 
virtual void onItemsChanged (ItemQuantity itemQuantity)
 

Properties

CharacterBase Character [get]
 

Member Function Documentation

◆ AddItems()

int AdventureCore.InventoryBase.AddItems ( ItemQuantity itemQuantity)
abstract

adds a quantity of an item to the inventory
returns the inventory item that was added to or created

Parameters
itemQuantityhow much and what to add to the inventory
Returns
the remaining quantity that could not be added

◆ CanAddItems()

bool AdventureCore.InventoryBase.CanAddItems ( ItemQuantity itemQuantity,
bool fully = true )
abstract

whether an item quantity can be added to the inventory
may be false when the quantity exceeds the capacity

Parameters
itemQuantitythe item and quantity to check
fullyif the quantity has to be stored entirely
Returns
whether the item quantity can be stored

◆ CanEquipItems()

bool AdventureCore.InventoryBase.CanEquipItems ( InventoryItem inventoryItem,
int index = 0 )
abstract

checks if an inventory item can be equipped

Parameters
inventoryItemthe inventory item to equip
indexindex of the slot to equip to if there are multiple(for example left/right arm in souls)
Returns
whether the item can be equipped

◆ CanRemoveItems() [1/2]

bool AdventureCore.InventoryBase.CanRemoveItems ( InventoryItem inventoryItem,
int quantity = 1,
bool fully = true )
abstract

whether a quantity of items is present and can be removed from an inventory item

Parameters
inventoryItemthe inventory item to remove from
quantityhow much to remove
fullyif the quantity has to be stored entirely
Returns
whether the quantity can be removed

◆ CanRemoveItems() [2/2]

bool AdventureCore.InventoryBase.CanRemoveItems ( ItemQuantity itemQuantity,
bool fully = true )
abstract

whether a quantity of items is present and can be removed

Parameters
itemQuantityhow much and what to remove from the inventory
fullyif the quantity has to be stored entirely
Returns

◆ CanUnequipItems()

bool AdventureCore.InventoryBase.CanUnequipItems ( InventoryItem inventoryItem)
abstract

checks if an inventory item can be unequipped

Parameters
inventoryItemthe inventory item to unequip
Returns
whether the item can be unequipped

◆ CanUseItems()

bool AdventureCore.InventoryBase.CanUseItems ( InventoryItem inventoryItem,
int quantity = 1 )
abstract

check if a quantity of an inventory item can be used

Parameters
inventoryItemthe inventory item to use
quantityhow many to use
Returns
whether the quantity can be used

◆ EquipItems()

ItemSlotBase AdventureCore.InventoryBase.EquipItems ( InventoryItem inventoryItem,
int index = 0 )
abstract

equipps an inventory item to a slot

Parameters
inventoryItemthe inventory item to equip
indexindex of the slot to equip to if there are multiple(for example left/right arm in souls)
Returns
the slot the item was equipped to

◆ GetItems() [1/2]

IEnumerable< InventoryItem > AdventureCore.InventoryBase.GetItems ( ItemBase item)
abstract

retrieves all inventory items for a specified item
multiple entries may be resturned for items that dont stack-
or when the inventory has a maximum stack size

Parameters
itemthe item to check
Returns
all inventory items that store the specified item

◆ GetItems() [2/2]

IEnumerable< InventoryItem > AdventureCore.InventoryBase.GetItems ( ItemCategory itemCategory = null,
ItemSlotCategory itemSlotCategory = null )
abstract

retrieves all inventory items for a specific category or slot

Parameters
itemCategorythe category to filter items for
itemSlotCategorythe slot to filter items for
Returns
all inventory items that match the given category and/or slot

◆ GetQuantity() [1/2]

int AdventureCore.InventoryBase.GetQuantity ( ItemBase item)
abstract

calculates the total stored quantity of an item

Parameters
itemthe item to sum quantities for
Returns
sum of all inventory item quantities that have the specified item

◆ GetQuantity() [2/2]

int AdventureCore.InventoryBase.GetQuantity ( ItemCategory itemCategory = null,
ItemSlotCategory itemSlotCategory = null )
abstract

calculates the total stored quantity of items filtered by an item category and/or slot

Parameters
itemCategorythe category to filter items for
itemSlotCategorythe slot to filter items for
Returns
sum of all inventory item quantities that have the given category and/or slot

◆ GetSlot() [1/2]

ItemSlotBase AdventureCore.InventoryBase.GetSlot ( ItemBase item,
int index = 0 )
abstract

retrieves an item slot for the passed item

Parameters
itemthe item to retrieve a slot for
indexwhen there are mutliple slots in one category(sould left/right weapon slots)
Returns
the found slot

◆ GetSlot() [2/2]

ItemSlotBase AdventureCore.InventoryBase.GetSlot ( ItemSlotCategory category,
int index = 0 )
abstract

retrieves an item slot by its category

Parameters
categorythe category of the slot(helmet, shield, ...)
indexwhen there are mutliple slots in one category(sould left/right weapon slots)
Returns
the found slot

◆ GetSlot< T >()

T AdventureCore.InventoryBase.GetSlot< T > ( int index = 0)
abstract

retrieves an item slot by its type

Template Parameters
Tthe type of the item slot
Parameters
indexwhen there are mutliple slots in one category(sould left/right weapon slots)
Returns
the found slot
Type Constraints
T :ItemSlotBase 

◆ HasItem()

bool AdventureCore.InventoryBase.HasItem ( ItemBase item)
abstract

checks whether the item exists in the inventory, regardless of quantity(may be 0 for stacked items to indicate they have been added at some point)

Parameters
item
Returns

◆ HasItemQuantity()

virtual bool AdventureCore.InventoryBase.HasItemQuantity ( ItemBase item,
int quantity = 1 )
virtual

checks if the inventory has at least the passed quantity of an item

Parameters
itemthe item to check
quantitythe minimum quantity needed
Returns
true if the needed quantity is present

◆ Initialize()

virtual void AdventureCore.InventoryBase.Initialize ( CharacterBase character)
inlinevirtual

initializes the inventory including retrieving persisted data

Parameters
characterthe owner of the inventory

Reimplemented in AdventureCore.ListedInventory.

◆ RemoveItems() [1/2]

int AdventureCore.InventoryBase.RemoveItems ( InventoryItem inventoryItem,
int quantity = 1 )
abstract

removes specified quantity from the inventory item

Parameters
inventoryItemthe inventory item to remove from
quantitythe quantity to remove
Returns
the remaining quantity that could not be removed

◆ RemoveItems() [2/2]

int AdventureCore.InventoryBase.RemoveItems ( ItemQuantity itemQuantity)
abstract

removes a quantity of items

Parameters
itemQuantityhow much and what to remove
Returns
the remaining quantity that could not be removed

◆ UnequipItems()

ItemSlotBase AdventureCore.InventoryBase.UnequipItems ( InventoryItem inventoryItem)
abstract

unequips an inventory item

Parameters
inventoryItemthe inventory item to unequip
Returns
the slot the inventory item was equipped to

◆ UseItems()

void AdventureCore.InventoryBase.UseItems ( InventoryItem inventoryItem,
int quantity = 1 )
abstract

uses a quantity of an inventory item can be used

Parameters
inventoryItemthe inventory item to use
quantityhow many to use