Item Pouch

🎒 ItemPouch Class

An object that stores a pack of items.

Namespace: Esper.Inventool.Items Access: public Type: class Inherits: ScriptableObject


📦 Fields

Access
Field
Type
Description

public

itemStacks

List<ItemStack>

A list of item stacks in this pouch.


🧰 Methods

Access
Method
Returns
Description

public

GetItems()

List<ItemStack>

Gets all items. Returns copies of each stack. Cleans invalid entries if found.

public

GetRandom()

ItemStack

Gets a random item stack from the pouch, or null if empty. Cleans invalid entries if found.

public

Clean()

void

Cleans the item list by removing deleted or invalid items, then updates profiles.

public

Save()

void

Saves the object. (Editor only)

Creating an Item Pouch

Since item pouches are scriptable objects, you can create them with ScriptableObject.CreateInstance.

ItemPouch itemPouch = ScriptableObject.CreateInstance<ItemPouch>();

Working with an Item Pouch

Setting Item Stacks

Adding

itemPouch.itemStacks.Add(itemStack);

Remove

itemPouch.itemStacks.Remove(itemStack);

Getting Items

Its recommended to use the GetItems method to get all item stacks from an ItemPouch. However, you can get all items by simply accessing the itemStacks field.

var itemStacks = itemPouch.GetItems();

You can also get a single random item from the pouch with the GetRandom method.

var itemStack = itemPouch.GetRandom();

Last updated