Class Inventory
[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
Costumes
public IEnumerable<Costume> Costumes { get; }
Property Value
Equipments
public IEnumerable<Equipment> Equipments { get; }
Property Value
Items
public IReadOnlyList<Inventory.Item> Items { get; }
Property Value
Materials
public IEnumerable<Material> Materials { get; }
Property Value
Methods
AddFungibleItem(ItemBase, int, ILock)
public Inventory.Item AddFungibleItem(ItemBase itemBase, int count = 1, ILock iLock = null)
Parameters
Returns
AddFungibleItem2(ItemBase, int, ILock)
[Obsolete("Use AddFungibleItem")]
public Inventory.Item AddFungibleItem2(ItemBase itemBase, int count = 1, ILock iLock = null)
Parameters
Returns
AddItem(ItemBase, int, ILock)
public KeyValuePair<int, int> AddItem(ItemBase itemBase, int count = 1, ILock iLock = null)
Parameters
Returns
AddItem2(ItemBase, int, ILock)
[Obsolete("Use AddItem")]
public KeyValuePair<int, int> AddItem2(ItemBase itemBase, int count = 1, ILock iLock = null)
Parameters
Returns
AddNonFungibleItem(ItemBase, ILock)
public Inventory.Item AddNonFungibleItem(ItemBase itemBase, ILock iLock = null)
Parameters
Returns
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
ITradableFungibleItemcount
int
Returns
Exceptions
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
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
FilterConsumables(int, long)
public List<Consumable> FilterConsumables(int id, long blockIndex)
Parameters
Returns
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
Returns
HasItem(int, int)
public bool HasItem(int rowId, int count = 1)
Parameters
Returns
HasNonFungibleItem(Guid)
public bool HasNonFungibleItem(Guid nonFungibleId)
Parameters
nonFungibleId
Guid
Returns
HasTradableFungibleItem(HashDigest<SHA256>, long?, long?, int)
public bool HasTradableFungibleItem(HashDigest<SHA256> fungibleId, long? requiredBlockIndex, long? blockIndex, int count)
Parameters
Returns
HasTradableItem(Guid, long, int)
public bool HasTradableItem(Guid tradableId, long blockIndex, int count)
Parameters
Returns
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
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.ItemThe item to check for removal.
id
intThe ID of the material to remove.
blockIndex
longThe 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
OrderDigestListStatetradableId
GuidblockIndex
long
ReconfigureFungibleItem(OrderDigestListState, Guid)
public void ReconfigureFungibleItem(OrderDigestListState digestList, Guid tradableId)
Parameters
digestList
OrderDigestListStatetradableId
Guid
RemoveConsumable(int, long, int)
public bool RemoveConsumable(int id, long blockIndex, int count = 1)
Parameters
Returns
RemoveFungibleItem(HashDigest<SHA256>, long, int, bool)
public bool RemoveFungibleItem(HashDigest<SHA256> fungibleId, long blockIndex, int count = 1, bool onlyTradableItem = false)
Parameters
Returns
RemoveFungibleItem(IFungibleItem, long, int, bool)
public bool RemoveFungibleItem(IFungibleItem fungibleItem, long blockIndex, int count = 1, bool onlyTradableItem = false)
Parameters
fungibleItem
IFungibleItemblockIndex
longcount
intonlyTradableItem
bool
Returns
RemoveFungibleItem2(HashDigest<SHA256>, int, bool)
[Obsolete("Use RemoveFungibleItem")]
public bool RemoveFungibleItem2(HashDigest<SHA256> fungibleId, int count = 1, bool onlyTradableItem = false)
Parameters
Returns
RemoveFungibleItem2(IFungibleItem, int, bool)
[Obsolete("Use RemoveFungibleItem")]
public bool RemoveFungibleItem2(IFungibleItem fungibleItem, int count = 1, bool onlyTradableItem = false)
Parameters
fungibleItem
IFungibleItemcount
intonlyTradableItem
bool
Returns
RemoveItem(Item)
public void RemoveItem(Inventory.Item item)
Parameters
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
intThe ID of the material item to remove.
blockIndex
longThe block index.
count
intThe 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
RemoveNonFungibleItem(Guid)
public bool RemoveNonFungibleItem(Guid nonFungibleId)
Parameters
nonFungibleId
Guid
Returns
RemoveNonFungibleItem2(Guid)
[Obsolete("Use RemoveNonFungibleItem(Guid nonFungibleId)")]
public bool RemoveNonFungibleItem2(Guid nonFungibleId)
Parameters
nonFungibleId
Guid
Returns
RemoveNonTradableMaterial(int, int)
Remove a non-tradable material from the inventory.
public bool RemoveNonTradableMaterial(int id, int count = 1)
Parameters
id
intThe ID of the material item to remove.
count
intThe 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
Returns
Exceptions
RemoveTradableItem(Guid, long, int)
public bool RemoveTradableItem(Guid tradableId, long blockIndex, int count = 1)
Parameters
Returns
RemoveTradableItemV1(ITradableItem, int)
[Obsolete("Use RemoveTradableItem()")]
public bool RemoveTradableItemV1(ITradableItem tradableItem, int count = 1)
Parameters
tradableItem
ITradableItemcount
int
Returns
RemoveTradableItemV1(Guid, long, int)
[Obsolete("Use RemoveTradableItem()")]
public bool RemoveTradableItemV1(Guid tradableId, long blockIndex, int count = 1)
Parameters
Returns
RemoveTradableMaterial(int, long, int)
Remove a tradable material from the inventory.
public bool RemoveTradableMaterial(int materialId, long blockIndex, int count = 1)
Parameters
materialId
intThe ID of the material item to remove.
blockIndex
longThe block index.
count
intThe 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
Returns
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
Returns
TryGetFungibleItems(HashDigest<SHA256>, out List<Item>)
public bool TryGetFungibleItems(HashDigest<SHA256> fungibleId, out List<Inventory.Item> outItems)
Parameters
Returns
TryGetItem(int, out Item)
public bool TryGetItem(int rowId, out Inventory.Item outItem)
Parameters
Returns
TryGetLockedItem(ILock, out Item)
public bool TryGetLockedItem(ILock iLock, out Inventory.Item outItem)
Parameters
Returns
TryGetNonFungibleItem(Guid, out Item)
public bool TryGetNonFungibleItem(Guid nonFungibleId, out Inventory.Item outItem)
Parameters
Returns
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
GuidThe ID of the non-fungible item to retrieve.
outNonFungibleItem
TWhen this method returns, contains the non-fungible item with the specified ID, if found; otherwise, the default value for the type.
blockIndex
longThe 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
ToutNonFungibleItem
T
Returns
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
Exceptions
TryGetTradableItem(Guid, long, int, out Item)
public bool TryGetTradableItem(Guid tradeId, long blockIndex, int count, out Inventory.Item outItem)
Parameters
Returns
TryGetTradableItems(Guid, long, int, out List<Item>)
public bool TryGetTradableItems(Guid tradeId, long blockIndex, int count, out List<Inventory.Item> outItem)
Parameters
Returns
UnlockInvalidSlot(OrderDigestListState, Address, Address)
public void UnlockInvalidSlot(OrderDigestListState digestListState, Address agentAddress, Address avatarAddress)
Parameters
digestListState
OrderDigestListStateagentAddress
AddressavatarAddress
Address
UpdateTradableItem(Guid, long, int, long)
public ITradableItem UpdateTradableItem(Guid tradableId, long blockIndex, int count, long requiredBlockIndex)