Class ItemCollection
Collection of items. Items are stored in an ordered dictionary keyed to a unique identifier. This collection may represent an inventory, a loot pile, harvestable items, etc.
Namespace: DaggerfallWorkshop.Game.Items
Assembly: Assembly-CSharp.dll
Syntax
[Serializable]
public class ItemCollection
Properties
| Improve this Doc View SourceCount
Gets count of items in collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
| Improve this Doc View SourceAddItem(DaggerfallUnityItem, ItemCollection.AddPosition, Boolean)
Adds an item to this collection.
Declaration
public void AddItem(DaggerfallUnityItem item, ItemCollection.AddPosition position = ItemCollection.AddPosition.Back, bool noStack = false)
Parameters
Type | Name | Description |
---|---|---|
DaggerfallUnityItem | item | Item to add. |
ItemCollection.AddPosition | position | Position in list to insert item. |
Boolean | noStack |
AddItems(IEnumerable<DaggerfallUnityItem>)
Adds items to this collection from an array of items. Items in this collection will remain. UIDs will be retained.
Declaration
public void AddItems(IEnumerable<DaggerfallUnityItem> items)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<DaggerfallUnityItem> | items | Items array. |
Clear()
Clears all items from this collection. Items in this collection will be destroyed.
Declaration
public void Clear()
CloneAll()
Creates a clone of all items in this collection. Items in this collection will remain. Cloned items will have new UIDs.
Declaration
public DaggerfallUnityItem[] CloneAll()
Returns
Type | Description |
---|---|
DaggerfallUnityItem[] | Array of cloned items. |
Contains(DaggerfallUnityItem)
Check if item exists in this collection.
Declaration
public bool Contains(DaggerfallUnityItem item)
Parameters
Type | Name | Description |
---|---|---|
DaggerfallUnityItem | item | Item to check. |
Returns
Type | Description |
---|---|
Boolean | True if item exists in this collection. |
Contains(ItemGroups, Int32)
Check if item type exists in this collection.
Declaration
public bool Contains(ItemGroups itemGroup, int itemIndex)
Parameters
Type | Name | Description |
---|---|---|
ItemGroups | itemGroup | Item group. |
Int32 | itemIndex | Template index. |
Returns
Type | Description |
---|---|
Boolean | True if collection contains an item of this type. |
Contains(Item)
Check if quest item held by player.
Declaration
public bool Contains(Item questItem)
Parameters
Type | Name | Description |
---|---|---|
Item | questItem | Quest Item resource. |
Returns
Type | Description |
---|---|
Boolean | True if player holding this quest item. |
Contains(UInt64)
Check if item UID exists in this collection.
Declaration
public bool Contains(ulong uid)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | uid | UID to check. |
Returns
Type | Description |
---|---|
Boolean | True if item with UID exists in this collection. |
CopyAll(ItemCollection)
Clones all items from source collection into this collection. Source items will not be changed. New UIDs will be allocated to cloned items.
Declaration
public void CopyAll(ItemCollection source)
Parameters
Type | Name | Description |
---|---|---|
ItemCollection | source | Source collection to copy from. |
DeserializeItems(ItemData_v1[])
Deserialize items into this collection. Existing items will be destroyed.
Declaration
public void DeserializeItems(ItemData_v1[] itemArray)
Parameters
Type | Name | Description |
---|---|---|
ItemData_v1[] | itemArray | ItemData_v1 array. |
Export()
Exports items from this collection to an array of items. Items in this collection will be destroyed. UIDs will be retained.
Declaration
public DaggerfallUnityItem[] Export()
Returns
Type | Description |
---|---|
DaggerfallUnityItem[] | Items array. |
ExportQuestItems(UInt64, Symbol)
Gets all quest items for a specific quest and item Symbol. Ignores ex-quest items that have been made permanent.
Declaration
public DaggerfallUnityItem[] ExportQuestItems(ulong questUID, Symbol itemSymbol)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | questUID | Quest UID for item search. |
Symbol | itemSymbol | Item Symbol for item search. |
Returns
Type | Description |
---|---|
DaggerfallUnityItem[] |
GetCreditAmount()
Gets the value of all the credit letters in this collection.
Declaration
public int GetCreditAmount()
Returns
Type | Description |
---|---|
Int32 | Amount in gp |
GetItem(ItemGroups, Int32, Boolean)
Get the first of an item type from this collection.
Declaration
public DaggerfallUnityItem GetItem(ItemGroups itemGroup, int itemIndex, bool priorityToConjured)
Parameters
Type | Name | Description |
---|---|---|
ItemGroups | itemGroup | Item group. |
Int32 | itemIndex | Template index. |
Boolean | priorityToConjured | Prefer (short lived) conjured items. |
Returns
Type | Description |
---|---|
DaggerfallUnityItem | An item of this type, or null if none found. |
GetItem(ItemGroups, Int32, Boolean, Boolean, Boolean)
Get the first of an item type from this collection that satisfies extra conditions.
Declaration
public DaggerfallUnityItem GetItem(ItemGroups itemGroup, int itemIndex, bool allowEnchantedItem = true, bool allowQuestItem = true, bool priorityToConjured = false)
Parameters
Type | Name | Description |
---|---|---|
ItemGroups | itemGroup | Item group. |
Int32 | itemIndex | Template index. |
Boolean | allowEnchantedItem | Include enchanted items. |
Boolean | allowQuestItem | Include quest items. |
Boolean | priorityToConjured | Prefer (short lived) conjured items. |
Returns
Type | Description |
---|---|
DaggerfallUnityItem | An item of this type, or null if none found. |
GetItem(Int32)
Gets item from index.
Declaration
public DaggerfallUnityItem GetItem(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of item between 0 and Count. |
Returns
Type | Description |
---|---|
DaggerfallUnityItem | DaggerfallUnityItem. |
GetItem(UInt64)
Gets item from UID.
Declaration
public DaggerfallUnityItem GetItem(ulong key)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | key | UID of item. |
Returns
Type | Description |
---|---|
DaggerfallUnityItem | DaggerfallUnityItem. |
GetNumItems()
Gets number of items in collection, including item stack sizes.
Declaration
public int GetNumItems()
Returns
Type | Description |
---|---|
Int32 |
GetWeight()
Gets the combined weight of all the items in this collection. (ignoring arrows like classic)
Declaration
public float GetWeight()
Returns
Type | Description |
---|---|
Single | Weight in kg |
Import(IEnumerable<DaggerfallUnityItem>)
Imports items to this collection from an array of items. Items in this collection will be destroyed. Source items will not be changed. UIDs will be retained.
Declaration
public void Import(IEnumerable<DaggerfallUnityItem> items)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<DaggerfallUnityItem> | items | Items array. |
RegisterCustomItem(String, Type)
Declaration
public static bool RegisterCustomItem(string itemClassName, Type itemClassType)
Parameters
Type | Name | Description |
---|---|---|
String | itemClassName | |
Type | itemClassType |
Returns
Type | Description |
---|---|
Boolean |
RemoveExpiredItems()
Removes items that have expired. Used for magically-created items. Only for the player. Note: Reverse-engineering suggests this was intended behavior in classic, but classic does not correctly set the item flags so magically-created items never disappear.
Declaration
public void RemoveExpiredItems()
RemoveItem(DaggerfallUnityItem)
Removes an item from this collection.
Declaration
public void RemoveItem(DaggerfallUnityItem item)
Parameters
Type | Name | Description |
---|---|---|
DaggerfallUnityItem | item | Item to remove. Must exist inside this collection. |
RemoveOne(DaggerfallUnityItem)
Removes one item from this collection, decrementing stack count.
Declaration
public void RemoveOne(DaggerfallUnityItem item)
Parameters
Type | Name | Description |
---|---|---|
DaggerfallUnityItem | item | Item to remove. Must exist inside this collection. |
RemoveOrphanedItems()
Removes any orphaned items from this collection.
Declaration
public int RemoveOrphanedItems()
Returns
Type | Description |
---|---|
Int32 |
ReorderItem(DaggerfallUnityItem, ItemCollection.AddPosition)
Reorders item in collection.
Declaration
public void ReorderItem(DaggerfallUnityItem item, ItemCollection.AddPosition position)
Parameters
Type | Name | Description |
---|---|---|
DaggerfallUnityItem | item | Item to reorder. Must exist inside this collection. |
ItemCollection.AddPosition | position | Position to reorder to. |
ReplaceAll(ItemCollection)
Replaces all items in this collection with clones of items from source collection. Items in this collection will be destroyed. Source items will not be changed. New UIDs will be allocated to cloned items.
Declaration
public void ReplaceAll(ItemCollection source)
Parameters
Type | Name | Description |
---|---|---|
ItemCollection | source | Source collection to copy from. |
SearchItems(ItemGroups, Int32)
Linear search that returns all items of particular group and template from this collection. Does not change items in this collection. For speed purposes returns actual item reference not a clone.
Declaration
public List<DaggerfallUnityItem> SearchItems(ItemGroups itemGroup, int templateIndex = -1)
Parameters
Type | Name | Description |
---|---|---|
ItemGroups | itemGroup | Item group. |
Int32 | templateIndex | Item template index. Use -1 to match group only. |
Returns
Type | Description |
---|---|
List<DaggerfallUnityItem> | List of item references. |
SerializeItems()
Serialize items from this collection.
Declaration
public ItemData_v1[] SerializeItems()
Returns
Type | Description |
---|---|
ItemData_v1[] | ItemData_v1 array. |
SplitStack(DaggerfallUnityItem, Int32)
Remove some number of items from a stack, return the removed items or null if not possible.
Declaration
public DaggerfallUnityItem SplitStack(DaggerfallUnityItem stack, int numberToPick)
Parameters
Type | Name | Description |
---|---|---|
DaggerfallUnityItem | stack | Source stack of items |
Int32 | numberToPick | Number of items to pick |
Returns
Type | Description |
---|---|
DaggerfallUnityItem | The items picked from stack. |
Transfer(DaggerfallUnityItem, ItemCollection, ItemCollection.AddPosition)
Transfers a single item from another collection to this collection. Item will be removed from source collection and placed in this collection. UID will be retained.
Declaration
public void Transfer(DaggerfallUnityItem item, ItemCollection source, ItemCollection.AddPosition position = ItemCollection.AddPosition.DontCare)
Parameters
Type | Name | Description |
---|---|---|
DaggerfallUnityItem | item | Item to transfer. |
ItemCollection | source | Source collection to transfer from. |
ItemCollection.AddPosition | position | Position in list to transfer item. |
TransferAll(ItemCollection)
Transfers all items from another collection. Items will be removed from source collection and placed in this collection. UIDs will be retained.
Declaration
public void TransferAll(ItemCollection source)
Parameters
Type | Name | Description |
---|---|---|
ItemCollection | source | Source collection to transfer from. |