Table of Contents

Interface IItemContainer

Namespace
FishMMO.Shared.Core
Assembly
FishMMO.Shared.dll

Interface for item containers, providing methods and events for managing items and slots. Used for inventories, equipment, banks, and other item storage systems.

public interface IItemContainer

Properties

Items

Gets the list of items contained in this container.

List<Item> Items { get; }

Property Value

List<Item>

Methods

AddSlots(List<Item>, int)

Adds slots to the container, optionally initializing with a list of items.

void AddSlots(List<Item> items, int amount)

Parameters

items List<Item>

The initial items to add (can be null).

amount int

The number of slots to add.

CanAddItem(Item)

Determines if the specified item can be added to the container.

bool CanAddItem(Item item)

Parameters

item Item

The item to check.

Returns

bool

True if the item can be added, false otherwise.

CanManipulate()

Determines if the container can be manipulated (e.g., items moved or swapped).

bool CanManipulate()

Returns

bool

True if manipulation is allowed, false otherwise.

Clear()

Clears all items from the container.

void Clear()

ContainsItem(BaseItemTemplate)

Checks if the container contains an item with the specified template.

bool ContainsItem(BaseItemTemplate itemTemplate)

Parameters

itemTemplate BaseItemTemplate

The item template to search for.

Returns

bool

True if the item is found, false otherwise.

FilledSlots()

Gets the number of filled slots in the container.

int FilledSlots()

Returns

int

The number of filled slots.

FreeSlots()

Gets the number of free slots in the container.

int FreeSlots()

Returns

int

The number of free slots.

GetItemCount(BaseItemTemplate)

Gets the count of items matching the specified template.

int GetItemCount(BaseItemTemplate itemTemplate)

Parameters

itemTemplate BaseItemTemplate

The item template to count.

Returns

int

The number of items matching the template.

HasFreeSlot()

Checks if the container has at least one free slot.

bool HasFreeSlot()

Returns

bool

True if a free slot exists, false otherwise.

IsSlotEmpty(int)

Checks if the specified slot is empty.

bool IsSlotEmpty(int slot)

Parameters

slot int

The slot index to check.

Returns

bool

True if the slot is empty, false otherwise.

IsSlotLocked(int)

Returns true if the specified slot is currently locked (e.g., a consumable activation is in progress). Locked slots cannot be swapped, removed, or transferred until unlocked.

bool IsSlotLocked(int slot)

Parameters

slot int

The slot index to check.

Returns

bool

True if the slot is locked, false otherwise.

IsValidSlot(int)

Checks if the specified slot index is valid for this container.

bool IsValidSlot(int slot)

Parameters

slot int

The slot index to check.

Returns

bool

True if the slot is valid, false otherwise.

LockSlot(int)

Locks the specified slot, preventing it from being swapped, removed, or transferred.

void LockSlot(int slot)

Parameters

slot int

The slot index to lock.

RemoveItem(int)

Removes the item from the specified slot.

Item RemoveItem(int slot)

Parameters

slot int

The slot index to remove the item from.

Returns

Item

The item that was removed, or null if no item was present.

SetItemSlot(Item, int)

Sets the item in the specified slot.

bool SetItemSlot(Item item, int slot)

Parameters

item Item

The item to set.

slot int

The slot index to set the item in.

Returns

bool

True if the item was successfully set, false otherwise.

SwapItemSlots(int, int)

Swaps items between two slots.

bool SwapItemSlots(int from, int to)

Parameters

from int

The source slot index.

to int

The destination slot index.

Returns

bool

True if the swap was successful, false otherwise.

SwapItemSlots(int, int, out Item, out Item)

Swaps items between two slots and returns the items that were swapped.

bool SwapItemSlots(int from, int to, out Item fromItem, out Item toItem)

Parameters

from int

The source slot index.

to int

The destination slot index.

fromItem Item

The item originally in the source slot.

toItem Item

The item originally in the destination slot.

Returns

bool

True if the swap was successful, false otherwise.

TryAddItem(Item, out List<Item>)

Attempts to add the specified item to the container, returning a list of modified items.

bool TryAddItem(Item item, out List<Item> modifiedItems)

Parameters

item Item

The item to add.

modifiedItems List<Item>

The list of items modified during the operation.

Returns

bool

True if the item was successfully added, false otherwise.

TryGetItem(int, out Item)

Attempts to get the item in the specified slot.

bool TryGetItem(int slot, out Item item)

Parameters

slot int

The slot index to retrieve.

item Item

The item found in the slot, or null if not found.

Returns

bool

True if an item was found, false otherwise.

UnlockSlot(int)

Unlocks the specified slot, allowing normal manipulation again.

void UnlockSlot(int slot)

Parameters

slot int

The slot index to unlock.

Events

OnSlotLockChanged

Event triggered when a slot's lock state changes. Parameters: container, slot index, isLocked.

event Action<IItemContainer, int, bool> OnSlotLockChanged

Event Type

Action<IItemContainer, int, bool>

OnSlotUpdated

Event triggered when an item slot is updated (item added, removed, or changed).

event Action<IItemContainer, Item, int> OnSlotUpdated

Event Type

Action<IItemContainer, Item, int>