Loading...
Searching...
No Matches
AdventureCore.TiledInventory Class Reference
Inheritance diagram for AdventureCore.TiledInventory:
AdventureCore.InventoryBase

Classes

struct  TiledInventoryData
 
class  TiledInventorySize
 

Public Member Functions

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

Public Attributes

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)
 
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)
 

Properties

override IReadOnlyList< InventoryItemInventoryItems [get]
 
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

◆ CanAddItems()

override bool AdventureCore.TiledInventory.CanAddItems ( ItemQuantity itemQuantity,
bool fully = true )
inlinevirtual

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.InventoryBase.

◆ CanRemoveItems()

override bool AdventureCore.TiledInventory.CanRemoveItems ( ItemQuantity itemQuantity,
bool fully = true )
inlinevirtual

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.InventoryBase.