Interface IItemCollection
Interface for inventory item collections (Lists and Maps).
Namespace: UnityEngine.GameFoundation
Syntax
public interface IItemCollection : IEnumerable<InventoryItem>, IEnumerable
Properties
Count
Count of InventoryItems in this ItemList.
Declaration
int Count { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
hasBeenDiscarded
Determines if this IItemCollection has been discarded (removed from Game Foundation).
Items being standard objects, they cannot be destroyed and garbage collected as long as all their
references are not set to null.
This property is a way for you to know if the object is still active within Game Foundation.
Declaration
bool hasBeenDiscarded { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
|
id
Key used for this ItemList. Key is read-only and is set when created through IInventoryManager or will be assigned unique Guid.
Declaration
string id { get; }
Property Value
| Type | Description |
|---|---|
| String |
Methods
Clear()
Remove all items from this IItemCollection.
Declaration
void Clear()
Contains(InventoryItem)
Check if this ItemList contains specified InventoryItem.
Declaration
bool Contains(InventoryItem inventoryItem)
Parameters
| Type | Name | Description |
|---|---|---|
| InventoryItem | inventoryItem | InventoryItem for which to search. |
Returns
| Type | Description |
|---|---|
| Boolean | true if specified InventoryItem is contained in this ItemList, else false. |
Find(Predicate<InventoryItem>)
Finds all the InventoryItem instances passing the filter.
Declaration
int Find(Predicate<InventoryItem> filter)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<InventoryItem> | filter | The filter the InventoryItem instances have to fulfill. |
Returns
| Type | Description |
|---|---|
| Int32 | The number of items found. |
Find(Predicate<InventoryItem>, ICollection<InventoryItem>, Boolean)
Finds all the InventoryItem instances passing the filter.
Declaration
int Find(Predicate<InventoryItem> filter, ICollection<InventoryItem> target, bool clearTarget = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<InventoryItem> | filter | |
| ICollection<InventoryItem> | target | The target collection the InventoryItem instances are copied to. |
| Boolean | clearTarget | If |
Returns
| Type | Description |
|---|---|
| Int32 | The number of items found. |
Find(InventoryItemDefinition)
Finds the InventoryItem instances of the specified definition.
Declaration
int Find(InventoryItemDefinition definition)
Parameters
| Type | Name | Description |
|---|---|---|
| InventoryItemDefinition | definition | InventoryItemDefinition to search for. |
Returns
| Type | Description |
|---|---|
| Int32 | Count of InventoryItems with specified |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If |
Find(InventoryItemDefinition, ICollection<InventoryItem>, Boolean)
Finds the InventoryItem instances of the specified definition.
Declaration
int Find(InventoryItemDefinition definition, ICollection<InventoryItem> target, bool clearTarget = true)
Parameters
| Type | Name | Description |
|---|---|---|
| InventoryItemDefinition | definition | |
| ICollection<InventoryItem> | target | The target collection the InventoryItem instances are copied to. |
| Boolean | clearTarget | If |
Returns
| Type | Description |
|---|---|
| Int32 | Count of InventoryItems with specified |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If |
Find(Tag)
Finds the InventoryItem instances using specified Tag.
Declaration
int Find(Tag tag)
Parameters
| Type | Name | Description |
|---|---|---|
| Tag | tag | Tag to search for. |
Returns
| Type | Description |
|---|---|
| Int32 | Count of InventoryItems with specified Tag. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If |
Find(Tag, ICollection<InventoryItem>, Boolean)
Finds the InventoryItem instances using specified Tag.
Declaration
int Find(Tag tag, ICollection<InventoryItem> target, bool clearTarget = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Tag | tag | |
| ICollection<InventoryItem> | target | The target collection the InventoryItem instances are copied to. |
| Boolean | clearTarget | If |
Returns
| Type | Description |
|---|---|
| Int32 | Count of InventoryItems with specified Tag. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If |
Find<TState>(Func<TState, InventoryItem, Boolean>, TState)
Finds all the InventoryItem instances passing the filter.
Declaration
int Find<TState>(Func<TState, InventoryItem, bool> filter, TState state)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TState, InventoryItem, Boolean> | filter | The filter the InventoryItem instances have to fulfill. |
| TState | state | The data used bny the filter. |
Returns
| Type | Description |
|---|---|
| Int32 | The number of items found. |
Type Parameters
| Name | Description |
|---|---|
| TState | The type of the |
Find<TState>(Func<TState, InventoryItem, Boolean>, TState, ICollection<InventoryItem>, Boolean)
Finds all the InventoryItem instances passing the filter.
Declaration
int Find<TState>(Func<TState, InventoryItem, bool> filter, TState state, ICollection<InventoryItem> target, bool clearTarget = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TState, InventoryItem, Boolean> | filter | |
| TState | state | |
| ICollection<InventoryItem> | target | The target collection the InventoryItem instances are copied to. |
| Boolean | clearTarget | If |
Returns
| Type | Description |
|---|---|
| Int32 | The number of items found. |
Type Parameters
| Name | Description |
|---|---|
| TState | The type of the |
GetItems(ICollection<InventoryItem>, Boolean)
Fill target with all InventoryItems.
Declaration
int GetItems(ICollection<InventoryItem> target = null, bool clearTarget = true)
Parameters
| Type | Name | Description |
|---|---|---|
| ICollection<InventoryItem> | target | The target collection the InventoryItem instances are copied to. |
| Boolean | clearTarget | If |
Returns
| Type | Description |
|---|---|
| Int32 | Count of ItemLists owned by IInventoryManager. |
GetTotalQuantity()
Count all InventoryItems in this IItemCollection (including total quantities of any StackableInventoryItems) and return total quantity.
Declaration
long GetTotalQuantity()
Returns
| Type | Description |
|---|---|
| Int64 | Total quantity of all items in IItemCollection. Non-stackable items count as 1, StackableInventoryItems count as the total stack quantity. |
GetTotalQuantity(InventoryItemDefinition)
Count all specified InventoryItemDefinition in this IItemCollection (including total quantities of any StackableInventoryItems) and return total quantity.
Declaration
long GetTotalQuantity(InventoryItemDefinition definition)
Parameters
| Type | Name | Description |
|---|---|---|
| InventoryItemDefinition | definition | InventoryItemDefinition to accumulate total quantity for. |
Returns
| Type | Description |
|---|---|
| Int64 | Total quantity of all items. Non-stackable items count as 1, StackableInventoryItems count as the total stack quantity. |
Remove(InventoryItem)
Remove specified ItemList item by reference.
Declaration
bool Remove(InventoryItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| InventoryItem | item | InventoryItem to remove. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Remove(InventoryItemDefinition)
Remove all InventoryItems with specified InventoryItemDefinition.
Declaration
bool Remove(InventoryItemDefinition definition)
Parameters
| Type | Name | Description |
|---|---|---|
| InventoryItemDefinition | definition | InventoryItemDefinitions to find and remove. |
Returns
| Type | Description |
|---|---|
| Boolean | true if any InventoryItemDefinitions were found and removed, else false. |