Show / Hide Table of Contents

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.

Inheritance
Object
ItemCollection
Namespace: DaggerfallWorkshop.Game.Items
Assembly: Assembly-CSharp.dll
Syntax
[Serializable]
public class ItemCollection

Properties

| Improve this Doc View Source

Count

Gets count of items in collection.

Declaration
public int Count { get; }
Property Value
Type Description
Int32

Methods

| Improve this Doc View Source

AddItem(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
| Improve this Doc View Source

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.

| Improve this Doc View Source

Clear()

Clears all items from this collection. Items in this collection will be destroyed.

Declaration
public void Clear()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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[]
| Improve this Doc View Source

GetCreditAmount()

Gets the value of all the credit letters in this collection.

Declaration
public int GetCreditAmount()
Returns
Type Description
Int32

Amount in gp

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

GetNumItems()

Gets number of items in collection, including item stack sizes.

Declaration
public int GetNumItems()
Returns
Type Description
Int32
| Improve this Doc View Source

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

| Improve this Doc View Source

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.

| Improve this Doc View Source

RegisterCustomItem(String, Type)

Declaration
public static bool RegisterCustomItem(string itemClassName, Type itemClassType)
Parameters
Type Name Description
String itemClassName
Type itemClassType
Returns
Type Description
Boolean
| Improve this Doc View Source

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()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

RemoveOrphanedItems()

Removes any orphaned items from this collection.

Declaration
public int RemoveOrphanedItems()
Returns
Type Description
Int32
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

SerializeItems()

Serialize items from this collection.

Declaration
public ItemData_v1[] SerializeItems()
Returns
Type Description
ItemData_v1[]

ItemData_v1 array.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX