Loading...
Searching...
No Matches
AdventureCore.TiledInventorySurrogate Class Reference

Detailed Description

placeholder that redirects to an actual component when a character with a specified id is available
can be used to bind things like UI to components of characters that will spawn during gameplay

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

Inheritance diagram for AdventureCore.TiledInventorySurrogate:
AdventureCore.TiledInventory AdventureCore.InventoryBase

Public Member Functions

override 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)
 
override bool HasItemQuantity (ItemBase item, int quantity=1)
 checks if the inventory has at least the passed quantity of an item
 
override InventoryItem GetItem (ItemBase item)
 retrieves the first inventory item for a specified item
 
override 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
 
override IEnumerable< InventoryItemGetItems (ItemCategory itemCategory=null, ItemSlotCategory itemSlotCategory=null)
 retrieves all inventory items for a specific category or slot
 
override int GetQuantity (ItemBase item)
 calculates the total stored quantity of an item
 
override int GetQuantity (ItemCategory itemCategory=null, ItemSlotCategory itemSlotCategory=null)
 calculates the total stored quantity of items filtered by an item category and/or slot
 
override 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
 
override int AddItems (ItemQuantity itemQuantity)
 adds a quantity of an item to the inventory
 
override bool CanRemoveItems (ItemQuantity itemQuantity, bool fully=true)
 whether a quantity of items is present and can be removed
 
override int RemoveItems (ItemQuantity itemQuantity)
 removes a quantity of items
 
override 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
 
override int RemoveItems (InventoryItem inventoryItem, int quantity=1)
 removes specified quantity from the inventory item
 
override void Clear ()
 unequips and removes all items from the inventory
 
override bool CanUseItems (InventoryItem inventoryItem, int quantity=1)
 check if a quantity of an inventory item can be used
 
override void UseItems (InventoryItem inventoryItem, int quantity=1)
 uses a quantity of an inventory item can be used
 
override bool CanEquipItems (InventoryItem inventoryItem, int? index=null)
 checks if an inventory item can be equipped
 
override ItemSlotBase EquipItems (InventoryItem inventoryItem, int? index=null)
 equipps an inventory item to a slot
 
override bool CanUnequipItems (InventoryItem inventoryItem)
 checks if an inventory item can be unequipped
 
override ItemSlotBase UnequipItems (InventoryItem inventoryItem)
 unequips an inventory item
 
override bool CheckItemValue (InventoryItem inventoryItem, string key)
 
override void SetItemValue< T > (InventoryItem inventoryItem, string key, T value)
 
override T GetItemValue< T > (InventoryItem inventoryItem, string key, T defaultValue)
 
override ItemSlotBase GetSlot (ItemSlotCategory category, int? index=null)
 retrieves an item slot by its category
 
override ItemSlotBase GetSlot (ItemBase item, int? index=null)
 retrieves an item slot for the passed item
 
override T GetSlot< T > (int? index=null)
 retrieves an item slot by its type
 
override ItemSlotBase GetEmptySlot (ItemSlotCategory category, int? index=null)
 retrieves an empty item slot by its category
 
override ItemSlotBase GetEmptySlot (ItemBase item, int? index=null)
 retrieves an empty item slot for the passed item
 
override T GetEmptySlot< T > (int? index=null)
 retrieves an empty item slot by its type
 
override int GetCapacity (ItemBase item)
 
override int GetRemainingCapacity (ItemBase item)
 
override bool Retrieve ()
 
override void Persist ()
 
override TiledInventoryData GetData ()
 
- Public Member Functions inherited from AdventureCore.TiledInventory
Vector2Int Clamp (Vector2Int position)
 
Vector2Int Clamp (Vector2Int position, Vector2Int size, bool rotated)
 
bool CanMove (TiledInventoryItem item, Vector2Int position, bool rotated)
 
void Move (TiledInventoryItem item, Vector2Int position, bool rotated)
 
bool CanRotate (TiledInventoryItem item)
 
void Rotate (TiledInventoryItem item)
 
void CanResize (TiledInventoryItem item, Vector2Int size)
 
void Resize (TiledInventoryItem item, Vector2Int size)
 
bool CanSort ()
 
bool Sort ()
 
override bool Retrieve ()
 
override void Persist ()
 
- Public Member Functions inherited from AdventureCore.InventoryBase
virtual void Initialize (CharacterBase character)
 initializes the inventory including retrieving persisted data
 
void SetItemStringValue (InventoryItem inventoryItem, string key, string value)
 
string GetItemStringValue (InventoryItem inventoryItem, string key, string defaultValue)
 
void SetItemIntValue (InventoryItem inventoryItem, string key, int value)
 
int GetItemIntValue (InventoryItem inventoryItem, string key, int defaultValue)
 
void SetItemFloatValue (InventoryItem inventoryItem, string key, float value)
 
float GetItemFloatValue (InventoryItem inventoryItem, string key, float defaultValue)
 
void SetItemBoolValue (InventoryItem inventoryItem, string key, bool value)
 
bool GetItemBoolValue (InventoryItem inventoryItem, string key, bool defaultValue)
 
bool Retrieve ()
 fills inventory with data retrieved from persister
 
void Persist ()
 saves inventory data to persister
 

Public Attributes

string CharacterId
 
- Public Attributes inherited from AdventureCore.TiledInventory
List< TiledInventoryItemItems = new List<TiledInventoryItem>()
 
Vector2Int InventorySize = new Vector2Int(16, 8)
 
TiledInventorySize[] ItemSizes
 
- Public Attributes inherited from AdventureCore.InventoryBase
PersisterBase Persister
 
bool PersistManual
 
ItemSet ItemSet
 
bool EquipOnAdded
 
bool UnequipOnEmpty
 
ItemSlotBase[] Slots
 
List< ItemQuantityCapacities
 
UnityEvent< ItemQuantityChanging
 
UnityEvent< ItemQuantityChanged
 
UnityEvent< ItemSlotBaseEquipmentChanged
 

Protected Member Functions

override int add (ItemQuantity itemQuantity)
 
override void remove (InventoryItem inventoryItem)
 
- Protected Member Functions inherited from AdventureCore.TiledInventory
override int add (ItemQuantity itemQuantity)
 
override void remove (InventoryItem inventoryItem)
 
override void clear ()
 
bool tryGetPosition (Vector2Int size, out Vector2Int position, out bool rotated, List< TiledInventoryItem > items=null)
 
bool checkAvailable (Vector2Int position, Vector2Int size, bool rotated, List< TiledInventoryItem > items=null)
 
bool checkAvailable (Vector2Int position, Vector2Int size, bool rotated, TiledInventoryItem movingItem)
 
InventoryItem getInventoryItem (Vector2Int position, List< TiledInventoryItem > items=null)
 
Vector2Int getSize (ItemBase item)
 
- Protected Member Functions inherited from AdventureCore.InventoryBase
virtual void onItemsChanging (ItemQuantity itemQuantity)
 
virtual void onItemsChanged (ItemQuantity itemQuantity)
 
virtual void onItemValueChanged (InventoryItem inventoryItem, string key)
 
int add (ItemQuantity itemQuantity)
 
void remove (InventoryItem inventoryItem)
 
void clear ()
 

Properties

override ObservableCollection< TiledInventoryItemObservableItems [get]
 
- Properties inherited from AdventureCore.TiledInventory
override IReadOnlyList< InventoryItemInventoryItems [get]
 
virtual ObservableCollection< TiledInventoryItemObservableItems [get]
 
- Properties inherited from AdventureCore.InventoryBase
CharacterBase Character [get]
 
IReadOnlyList< InventoryItemInventoryItems [get]
 

Additional Inherited Members

- Static Public Attributes inherited from AdventureCore.InventoryBase
const string PERSISTENCE_SUB_KEY = "INV"
 
- Protected Attributes inherited from AdventureCore.InventoryBase
bool _isInitialized
 
bool _isChanging
 

Member Function Documentation

◆ AddItems()

override int AdventureCore.TiledInventorySurrogate.AddItems ( ItemQuantity itemQuantity)
virtual

adds a quantity of an item to the inventory

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

Reimplemented from AdventureCore.InventoryBase.

◆ CanAddItems()

override bool AdventureCore.TiledInventorySurrogate.CanAddItems ( ItemQuantity itemQuantity,
bool fully = true )
virtual

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

Reimplemented from AdventureCore.TiledInventory.

◆ CanEquipItems()

override bool AdventureCore.TiledInventorySurrogate.CanEquipItems ( InventoryItem inventoryItem,
int? index = null )
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ CanRemoveItems() [1/2]

override bool AdventureCore.TiledInventorySurrogate.CanRemoveItems ( InventoryItem inventoryItem,
int quantity = 1,
bool fully = true )
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ CanRemoveItems() [2/2]

override bool AdventureCore.TiledInventorySurrogate.CanRemoveItems ( ItemQuantity itemQuantity,
bool fully = true )
virtual

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 removed entirely
Returns

Reimplemented from AdventureCore.TiledInventory.

◆ CanUnequipItems()

override bool AdventureCore.TiledInventorySurrogate.CanUnequipItems ( InventoryItem inventoryItem)
virtual

checks if an inventory item can be unequipped

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

Reimplemented from AdventureCore.InventoryBase.

◆ CanUseItems()

override bool AdventureCore.TiledInventorySurrogate.CanUseItems ( InventoryItem inventoryItem,
int quantity = 1 )
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ CheckItemValue()

override bool AdventureCore.TiledInventorySurrogate.CheckItemValue ( InventoryItem inventoryItem,
string key )
virtual

Reimplemented from AdventureCore.InventoryBase.

◆ Clear()

override void AdventureCore.TiledInventorySurrogate.Clear ( )
virtual

unequips and removes all items from the inventory

Reimplemented from AdventureCore.InventoryBase.

◆ EquipItems()

override ItemSlotBase AdventureCore.TiledInventorySurrogate.EquipItems ( InventoryItem inventoryItem,
int? index = null )
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ GetCapacity()

override int AdventureCore.TiledInventorySurrogate.GetCapacity ( ItemBase item)
virtual

Reimplemented from AdventureCore.InventoryBase.

◆ GetData()

override TiledInventoryData AdventureCore.TiledInventorySurrogate.GetData ( )
virtual

Reimplemented from AdventureCore.TiledInventory.

◆ GetEmptySlot() [1/2]

override ItemSlotBase AdventureCore.TiledInventorySurrogate.GetEmptySlot ( ItemBase item,
int? index = null )
virtual

retrieves an empty item slot for the passed item

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

Reimplemented from AdventureCore.InventoryBase.

◆ GetEmptySlot() [2/2]

override ItemSlotBase AdventureCore.TiledInventorySurrogate.GetEmptySlot ( ItemSlotCategory category,
int? index = null )
virtual

retrieves an empty item slot by its category

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

Reimplemented from AdventureCore.InventoryBase.

◆ GetEmptySlot< T >()

override T AdventureCore.TiledInventorySurrogate.GetEmptySlot< T > ( int? index = null)
virtual

retrieves an empty item slot by its type

Template Parameters
Tthe type of the item slot
Parameters
indexwhen there are mutliple slots in one category(souls left/right weapon slots)
Returns
the found slot

Reimplemented from AdventureCore.InventoryBase.

◆ GetItem()

override InventoryItem AdventureCore.TiledInventorySurrogate.GetItem ( ItemBase item)
virtual

retrieves the first inventory item for a specified item

Parameters
itemthe item to check
Returns
first inventory items that stores the specified item

Reimplemented from AdventureCore.InventoryBase.

◆ GetItems() [1/2]

override IEnumerable< InventoryItem > AdventureCore.TiledInventorySurrogate.GetItems ( ItemBase item)
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ GetItems() [2/2]

override IEnumerable< InventoryItem > AdventureCore.TiledInventorySurrogate.GetItems ( ItemCategory itemCategory = null,
ItemSlotCategory itemSlotCategory = null )
inlinevirtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ GetItemValue< T >()

override T AdventureCore.TiledInventorySurrogate.GetItemValue< T > ( InventoryItem inventoryItem,
string key,
T defaultValue )
inlinevirtual

Reimplemented from AdventureCore.InventoryBase.

◆ GetQuantity() [1/2]

override int AdventureCore.TiledInventorySurrogate.GetQuantity ( ItemBase item)
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ GetQuantity() [2/2]

override int AdventureCore.TiledInventorySurrogate.GetQuantity ( ItemCategory itemCategory = null,
ItemSlotCategory itemSlotCategory = null )
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ GetRemainingCapacity()

override int AdventureCore.TiledInventorySurrogate.GetRemainingCapacity ( ItemBase item)
virtual

Reimplemented from AdventureCore.InventoryBase.

◆ GetSlot() [1/2]

override ItemSlotBase AdventureCore.TiledInventorySurrogate.GetSlot ( ItemBase item,
int? index = null )
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ GetSlot() [2/2]

override ItemSlotBase AdventureCore.TiledInventorySurrogate.GetSlot ( ItemSlotCategory category,
int? index = null )
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ GetSlot< T >()

override T AdventureCore.TiledInventorySurrogate.GetSlot< T > ( int? index = null)
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ HasItem()

override bool AdventureCore.TiledInventorySurrogate.HasItem ( ItemBase item)
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ HasItemQuantity()

override bool AdventureCore.TiledInventorySurrogate.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

Reimplemented from AdventureCore.InventoryBase.

◆ RemoveItems() [1/2]

override int AdventureCore.TiledInventorySurrogate.RemoveItems ( InventoryItem inventoryItem,
int quantity = 1 )
virtual

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

Reimplemented from AdventureCore.InventoryBase.

◆ RemoveItems() [2/2]

override int AdventureCore.TiledInventorySurrogate.RemoveItems ( ItemQuantity itemQuantity)
virtual

removes a quantity of items

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

Reimplemented from AdventureCore.InventoryBase.

◆ SetItemValue< T >()

override void AdventureCore.TiledInventorySurrogate.SetItemValue< T > ( InventoryItem inventoryItem,
string key,
T value )
virtual

Reimplemented from AdventureCore.InventoryBase.

◆ UnequipItems()

override ItemSlotBase AdventureCore.TiledInventorySurrogate.UnequipItems ( InventoryItem inventoryItem)
virtual

unequips an inventory item

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

Reimplemented from AdventureCore.InventoryBase.

◆ UseItems()

override void AdventureCore.TiledInventorySurrogate.UseItems ( InventoryItem inventoryItem,
int quantity = 1 )
virtual

uses a quantity of an inventory item can be used

Parameters
inventoryItemthe inventory item to use
quantityhow many to use

Reimplemented from AdventureCore.InventoryBase.