Interface IItemContainer
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
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
CanAddItem(Item)
Determines if the specified item can be added to the container.
bool CanAddItem(Item item)
Parameters
itemItemThe 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
itemTemplateBaseItemTemplateThe 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
itemTemplateBaseItemTemplateThe 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
slotintThe 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
slotintThe 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
slotintThe 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
slotintThe slot index to lock.
RemoveItem(int)
Removes the item from the specified slot.
Item RemoveItem(int slot)
Parameters
slotintThe 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
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
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
fromintThe source slot index.
tointThe destination slot index.
fromItemItemThe item originally in the source slot.
toItemItemThe 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
itemItemThe item to add.
modifiedItemsList<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
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
slotintThe 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
OnSlotUpdated
Event triggered when an item slot is updated (item added, removed, or changed).
event Action<IItemContainer, Item, int> OnSlotUpdated