Table of Contents

Class Inventory

Namespace
Nekoyume.Model.Item
Assembly
Lib9c.dll
[Serializable]
public class Inventory : IState, ICloneable
Inheritance
Inventory
Implements
Inherited Members
Extension Methods

Constructors

Inventory()

public Inventory()

Inventory(List)

public Inventory(List serialized)

Parameters

serialized List

Properties

Consumables

public IEnumerable<Consumable> Consumables { get; }

Property Value

IEnumerable<Consumable>

Costumes

public IEnumerable<Costume> Costumes { get; }

Property Value

IEnumerable<Costume>

Equipments

public IEnumerable<Equipment> Equipments { get; }

Property Value

IEnumerable<Equipment>

Items

public IReadOnlyList<Inventory.Item> Items { get; }

Property Value

IReadOnlyList<Inventory.Item>

Materials

public IEnumerable<Material> Materials { get; }

Property Value

IEnumerable<Material>

Methods

AddFungibleItem(ItemBase, int, ILock)

public Inventory.Item AddFungibleItem(ItemBase itemBase, int count = 1, ILock iLock = null)

Parameters

itemBase ItemBase
count int
iLock ILock

Returns

Inventory.Item

AddFungibleItem2(ItemBase, int, ILock)

[Obsolete("Use AddFungibleItem")]
public Inventory.Item AddFungibleItem2(ItemBase itemBase, int count = 1, ILock iLock = null)

Parameters

itemBase ItemBase
count int
iLock ILock

Returns

Inventory.Item

AddItem(ItemBase, int, ILock)

public KeyValuePair<int, int> AddItem(ItemBase itemBase, int count = 1, ILock iLock = null)

Parameters

itemBase ItemBase
count int
iLock ILock

Returns

KeyValuePair<int, int>

AddItem2(ItemBase, int, ILock)

[Obsolete("Use AddItem")]
public KeyValuePair<int, int> AddItem2(ItemBase itemBase, int count = 1, ILock iLock = null)

Parameters

itemBase ItemBase
count int
iLock ILock

Returns

KeyValuePair<int, int>

AddNonFungibleItem(ItemBase, ILock)

public Inventory.Item AddNonFungibleItem(ItemBase itemBase, ILock iLock = null)

Parameters

itemBase ItemBase
iLock ILock

Returns

Inventory.Item

AddTradableFungibleItem(ITradableFungibleItem, int)

Add tradable fungible item. If there is same item which is not locked, add count to it. The same item is item which has same item sheet id, fungible id, tradable id and same required block index. If there is no same item, add new item.

public Inventory.Item AddTradableFungibleItem(ITradableFungibleItem tradableFungibleItem, int count)

Parameters

tradableFungibleItem ITradableFungibleItem
count int

Returns

Inventory.Item

Exceptions

ArgumentNullException
ArgumentOutOfRangeException

Clone()

Creates a new object that is a copy of the current instance.

public object Clone()

Returns

object

A new object that is a copy of this instance.

Equals(Inventory)

protected bool Equals(Inventory other)

Parameters

other Inventory

Returns

bool

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FilterConsumables(int, long)

public List<Consumable> FilterConsumables(int id, long blockIndex)

Parameters

id int
blockIndex long

Returns

List<Consumable>

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

HasFungibleItem(HashDigest<SHA256>, long, int)

public bool HasFungibleItem(HashDigest<SHA256> fungibleId, long blockIndex, int count = 1)

Parameters

fungibleId HashDigest<SHA256>
blockIndex long
count int

Returns

bool

HasItem(int, int)

public bool HasItem(int rowId, int count = 1)

Parameters

rowId int
count int

Returns

bool

HasNonFungibleItem(Guid)

public bool HasNonFungibleItem(Guid nonFungibleId)

Parameters

nonFungibleId Guid

Returns

bool

HasTradableFungibleItem(HashDigest<SHA256>, long?, long?, int)

public bool HasTradableFungibleItem(HashDigest<SHA256> fungibleId, long? requiredBlockIndex, long? blockIndex, int count)

Parameters

fungibleId HashDigest<SHA256>
requiredBlockIndex long?
blockIndex long?
count int

Returns

bool

HasTradableItem(Guid, long, int)

public bool HasTradableItem(Guid tradableId, long blockIndex, int count)

Parameters

tradableId Guid
blockIndex long
count int

Returns

bool

IsMaterialRemovable(Item, int)

Checks if the given item is non-tradable material and can be removed from the inventory.

public static bool IsMaterialRemovable(Inventory.Item item, int id)

Parameters

item Inventory.Item

The item to check for removal.

id int

The ID of the material to remove.

Returns

bool

Returns a boolean indicating whether the item is removable.

IsMaterialRemovable(Item, int, long)

Checks if the given item is material and can be removed from the inventory.

public static bool IsMaterialRemovable(Inventory.Item item, int id, long blockIndex)

Parameters

item Inventory.Item

The item to check for removal.

id int

The ID of the material to remove.

blockIndex long

The block index.

Returns

bool

Returns a boolean indicating whether the item is removable.

LockByReferringToDigestList(OrderDigestListState, Guid, long)

public void LockByReferringToDigestList(OrderDigestListState digestList, Guid tradableId, long blockIndex)

Parameters

digestList OrderDigestListState
tradableId Guid
blockIndex long

ReconfigureFungibleItem(OrderDigestListState, Guid)

public void ReconfigureFungibleItem(OrderDigestListState digestList, Guid tradableId)

Parameters

digestList OrderDigestListState
tradableId Guid

RemoveConsumable(int, long, int)

public bool RemoveConsumable(int id, long blockIndex, int count = 1)

Parameters

id int
blockIndex long
count int

Returns

bool

RemoveFungibleItem(HashDigest<SHA256>, long, int, bool)

public bool RemoveFungibleItem(HashDigest<SHA256> fungibleId, long blockIndex, int count = 1, bool onlyTradableItem = false)

Parameters

fungibleId HashDigest<SHA256>
blockIndex long
count int
onlyTradableItem bool

Returns

bool

RemoveFungibleItem(IFungibleItem, long, int, bool)

public bool RemoveFungibleItem(IFungibleItem fungibleItem, long blockIndex, int count = 1, bool onlyTradableItem = false)

Parameters

fungibleItem IFungibleItem
blockIndex long
count int
onlyTradableItem bool

Returns

bool

RemoveFungibleItem2(HashDigest<SHA256>, int, bool)

[Obsolete("Use RemoveFungibleItem")]
public bool RemoveFungibleItem2(HashDigest<SHA256> fungibleId, int count = 1, bool onlyTradableItem = false)

Parameters

fungibleId HashDigest<SHA256>
count int
onlyTradableItem bool

Returns

bool

RemoveFungibleItem2(IFungibleItem, int, bool)

[Obsolete("Use RemoveFungibleItem")]
public bool RemoveFungibleItem2(IFungibleItem fungibleItem, int count = 1, bool onlyTradableItem = false)

Parameters

fungibleItem IFungibleItem
count int
onlyTradableItem bool

Returns

bool

RemoveItem(Item)

public void RemoveItem(Inventory.Item item)

Parameters

item Inventory.Item

RemoveMaterial(int, long, int)

Remove a material from the inventory. contains tradable materials.

public bool RemoveMaterial(int id, long blockIndex, int count = 1)

Parameters

id int

The ID of the material item to remove.

blockIndex long

The block index.

count int

The number of materials to remove. Default value is 1.

Returns

bool

True if the material is successfully removed, false otherwise.

RemoveNonFungibleItem(INonFungibleItem)

public bool RemoveNonFungibleItem(INonFungibleItem nonFungibleItem)

Parameters

nonFungibleItem INonFungibleItem

Returns

bool

RemoveNonFungibleItem(Guid)

public bool RemoveNonFungibleItem(Guid nonFungibleId)

Parameters

nonFungibleId Guid

Returns

bool

RemoveNonFungibleItem2(Guid)

[Obsolete("Use RemoveNonFungibleItem(Guid nonFungibleId)")]
public bool RemoveNonFungibleItem2(Guid nonFungibleId)

Parameters

nonFungibleId Guid

Returns

bool

RemoveNonTradableMaterial(int, int)

Remove a non-tradable material from the inventory.

public bool RemoveNonTradableMaterial(int id, int count = 1)

Parameters

id int

The ID of the material item to remove.

count int

The number of materials to remove. Default value is 1.

Returns

bool

True if the material is successfully removed, false otherwise.

RemoveTradableFungibleItem(HashDigest<SHA256>, long?, long?, int)

Remove tradable item from inventory. Use the requiredBlockIndex when you want to remove the item that has same requiredBlockIndex. Use the blockIndex when you want to remove the item that has requiredBlockIndex less than or equal to blockIndex. Do not use both requiredBlockIndex and blockIndex at the same time.

public bool RemoveTradableFungibleItem(HashDigest<SHA256> fungibleId, long? requiredBlockIndex, long? blockIndex, int count)

Parameters

fungibleId HashDigest<SHA256>
requiredBlockIndex long?
blockIndex long?
count int

Returns

bool

Exceptions

ArgumentNullException

RemoveTradableItem(Guid, long, int)

public bool RemoveTradableItem(Guid tradableId, long blockIndex, int count = 1)

Parameters

tradableId Guid
blockIndex long
count int

Returns

bool

RemoveTradableItemV1(ITradableItem, int)

[Obsolete("Use RemoveTradableItem()")]
public bool RemoveTradableItemV1(ITradableItem tradableItem, int count = 1)

Parameters

tradableItem ITradableItem
count int

Returns

bool

RemoveTradableItemV1(Guid, long, int)

[Obsolete("Use RemoveTradableItem()")]
public bool RemoveTradableItemV1(Guid tradableId, long blockIndex, int count = 1)

Parameters

tradableId Guid
blockIndex long
count int

Returns

bool

RemoveTradableMaterial(int, long, int)

Remove a tradable material from the inventory.

public bool RemoveTradableMaterial(int materialId, long blockIndex, int count = 1)

Parameters

materialId int

The ID of the material item to remove.

blockIndex long

The block index.

count int

The number of materials to remove. Default value is 1.

Returns

bool

True if the material is successfully removed, false otherwise.

SellItem(Guid, long, int)

public ITradableItem SellItem(Guid tradableId, long blockIndex, int count)

Parameters

tradableId Guid
blockIndex long
count int

Returns

ITradableItem

Serialize()

public IValue Serialize()

Returns

IValue

TryGetCostume(int, out Costume)

[Obsolete("Use public bool TryGetNonFungibleItem<T>(Guid itemId, out T outNonFungibleItem)")]
public bool TryGetCostume(int rowId, out Costume outCostume)

Parameters

rowId int
outCostume Costume

Returns

bool

TryGetFungibleItems(HashDigest<SHA256>, out List<Item>)

public bool TryGetFungibleItems(HashDigest<SHA256> fungibleId, out List<Inventory.Item> outItems)

Parameters

fungibleId HashDigest<SHA256>
outItems List<Inventory.Item>

Returns

bool

TryGetItem(int, out Item)

public bool TryGetItem(int rowId, out Inventory.Item outItem)

Parameters

rowId int
outItem Inventory.Item

Returns

bool

TryGetLockedItem(ILock, out Item)

public bool TryGetLockedItem(ILock iLock, out Inventory.Item outItem)

Parameters

iLock ILock
outItem Inventory.Item

Returns

bool

TryGetNonFungibleItem(Guid, out Item)

public bool TryGetNonFungibleItem(Guid nonFungibleId, out Inventory.Item outItem)

Parameters

nonFungibleId Guid
outItem Inventory.Item

Returns

bool

TryGetNonFungibleItem<T>(Guid, out T, long)

Tries to get a non-fungible item from the inventory with the specified item ID.

public bool TryGetNonFungibleItem<T>(Guid itemId, out T outNonFungibleItem, long blockIndex = 9223372036854775807) where T : INonFungibleItem

Parameters

itemId Guid

The ID of the non-fungible item to retrieve.

outNonFungibleItem T

When this method returns, contains the non-fungible item with the specified ID, if found; otherwise, the default value for the type.

blockIndex long

The block index for the non-fungible item to be considered valid. Defaults to MaxValue.

Returns

bool

true if a non-fungible item with the specified ID is found in the inventory; otherwise, false.

Type Parameters

T

The type of non-fungible item to retrieve.

TryGetNonFungibleItem<T>(T, out T)

public bool TryGetNonFungibleItem<T>(T nonFungibleItem, out T outNonFungibleItem) where T : INonFungibleItem

Parameters

nonFungibleItem T
outNonFungibleItem T

Returns

bool

Type Parameters

T

TryGetTradableFungibleItems(HashDigest<SHA256>, long?, long?, out IEnumerable<Item>)

Get ITradableFungibleItem from the inventory. This method check the item is not locked, and the item's required block index is less than or equal to the given block index. Do not use both requiredBlockIndex and blockIndex at the same time.

public bool TryGetTradableFungibleItems(HashDigest<SHA256> fungibleId, long? requiredBlockIndex, long? blockIndex, out IEnumerable<Inventory.Item> outItems)

Parameters

fungibleId HashDigest<SHA256>
requiredBlockIndex long?
blockIndex long?
outItems IEnumerable<Inventory.Item>

Returns

bool

Exceptions

ArgumentNullException

TryGetTradableItem(Guid, long, int, out Item)

public bool TryGetTradableItem(Guid tradeId, long blockIndex, int count, out Inventory.Item outItem)

Parameters

tradeId Guid
blockIndex long
count int
outItem Inventory.Item

Returns

bool

TryGetTradableItems(Guid, long, int, out List<Item>)

public bool TryGetTradableItems(Guid tradeId, long blockIndex, int count, out List<Inventory.Item> outItem)

Parameters

tradeId Guid
blockIndex long
count int
outItem List<Inventory.Item>

Returns

bool

UnlockInvalidSlot(OrderDigestListState, Address, Address)

public void UnlockInvalidSlot(OrderDigestListState digestListState, Address agentAddress, Address avatarAddress)

Parameters

digestListState OrderDigestListState
agentAddress Address
avatarAddress Address

UpdateTradableItem(Guid, long, int, long)

public ITradableItem UpdateTradableItem(Guid tradableId, long blockIndex, int count, long requiredBlockIndex)

Parameters

tradableId Guid
blockIndex long
count int
requiredBlockIndex long

Returns

ITradableItem