Equipment

⚔️ Equipment Class

The settings and functionality of the inventory's equipment section.

Namespace: Esper.Inventool

Access: public

Type: class

Inherits: InventoolObject


📦 Fields

Access
Field
Type
Description

public

rotationType

RotationType

The character viewer rotation type.

public

parityX

Parity

Controls whether the amount of slots on the X-axis are even or odd.

public

parityY

Parity

Controls whether the amount of slots on the Y-axis are even or odd.

public

characterImage

Sprite

A character image to use instead of the 3D character viewer. This is meant for 2D games only.

public

useEquipFallback

bool

If enabled, when an item is attempted to be equipped through the TryEquip method and there are no slots available for it, the item will replace an existing one.

public

slots

List<EquipmentSlot>

A list of all created equipment slots.

public

canEquip

Func<ItemStack, bool>

A function that checks if an item can be equipped. You can use this to set your own logic to prevent/allow equipping.

public

canUnequip

Func<ItemStack, bool>

A function that checks if an item can be unequipped. You can use this to set your own logic to prevent/allow unequipping.

public

onItemEquipped

UnityEvent<ItemStack, EquipmentSlot>

A callback for when an item is equipped. This accepts 2 arguments: the item equipped (ItemStack), the affected equipment slot (EquipmentSlot).

public

onItemUnequipped

UnityEvent<ItemStack, EquipmentSlot>

A callback for when an item is unequipped. This accepts 2 argument: the item unequipped (ItemStack), the affected equipment slot (EquipmentSlot).


🧰 Methods

Access
Method
Returns
Description

public

ClearData()

void

Clears all runtime data. Slots will remain intact.

public

GetAllItems()

List<ItemStack>

Creates and returns a list of all equipped items.

public

EmptySlots()

void

Removes all items from all equipment slots. This will not invoke unequip events.

public

HasSlot(int positionIndex)

bool

Checks if a slot at a position index exists. Returns true if a slot at the position index exists. Otherwise, false.

public

HasSlot(string name)

bool

Checks if a slot with a name exists. Returns true if a slot with the name exists. Otherwise, false.

public

GetIndexOfSlot(int positionIndex)

int

Gets the index of the slot in the list by the position index. Returns the index of the slot or -1 if it doesn't exist.

public

ToggleEquip(ItemStack itemStack)

void

Checks the item's state and attempts to equip it if unequipped, or unequip it if currently equipped.

public

IsEquipped(ItemStack itemStack)

bool

Checks if an item stack is currently equipped in any slot. Returns true if the item stack is equipped. Otherwise, false.

public

IsEquipped(Item item)

bool

Checks if an item is currently equipped in any slot. Returns true if the item is equipped. Otherwise, false.

public

TryEquip(ItemStack itemStack)

bool

Attempts to equip an item stack. Returns true if the item stack was successfully equipped. Otherwise, false.

public

TryUnequip(ItemStack itemStack)

bool

Attempts to unequip an item stack. Returns true if the item stack was successfully unequipped. Otherwise, false.

public

TryUnequip(Item item)

bool

Attempts to unequip an item. Returns true if the item was successfully unequipped. Otherwise, false.

public

UnequipAll()

void

Unequips all items.

public

GetSlot(int positionIndex)

EquipmentSlot

Gets an equipment slot by position index. Returns the equipment slot at the position index or null if such a slot doesn't exist.

public

GetSlot(string name)

EquipmentSlot

Gets an equipment slot by name. Returns the equipment slot with the name or null if such a slot doesn't exist.

public

GetSlot(ItemStack itemStack)

EquipmentSlot

Gets an equipment slot that contains a specific item stack. Returns the equipment slot with the item stack or null if such a slot doesn't exist.

public

GetSlot(Item item)

EquipmentSlot

Gets the first equipment slot that contains a specific item. Returns the first equipment slot with the item or null if such a slot doesn't exist.

public

GetFirstSlotOfType(string itemTypeName)

EquipmentSlot

Gets the first slot of a specific item type by name. Returns the first slot found that supports the item type or null if such a slot doesn't exist.

public

GetFirstSlotOfType(ItemType itemType)

EquipmentSlot

Gets the first slot of a specific item type. Returns the first slot found that supports the item type or null if such a slot doesn't exist.

public

SetData(Equipment equipment)

void

Sets the data from another equipment.

public static

GetObjectByID(int id)

Equipment

Gets the equipment by ID. Returns the equipment with the ID or null if one doesn't exist.

public static

Create()

Equipment

Creates a new instance of an equipment (editor only).

public static

CreateCopy(Equipment original)

Equipment

Creates a copy of another equipment.


🧩 Nested Enums

RotationType

Supported rotation types.

Value
Description

Free

Free rotation.

X

Rotate only on the X-axis.

Y

Rotate only on the Y-axis.

Parity

Equipment grid parity types.

Value
Description

Even

An even number of rows or columns.

Odd

An odd number of rows or columns.

Accessing the Equipment

You can access the player's equipment with Inventool.Equipment.

Getting Slots

You can access the full list of slots with the slots field.

Check If A Slot Exists

bool result = Inventool.Equipment.HasSlot("My Slot Name");

Get Slot By Name

EquipmentSlot slot = Inventool.Equipment.GetSlot("My Slot Name");

Get Slot At Position

// Get slot at position 0
EquipmentSlot slot = Inventool.Equipment.GetSlot(0);

Get Slot With A Specific Item Stack

EquipmentSlot slot = Inventool.Equipment.GetSlot(myItemStack);

Get First Slot of An Item Type

EquipmentSlot slot = Inventool.Equipment.GetSlot(myItemType);

Removing Slots

Inventool.Equipment.slots.Remove(mySlot);

Equipping

Checking Item Equipped State

The IsEquipped method checks if an Item or Item Stack is currently equipped at any slot.

bool result = Inventool.Equipment.IsEquipped(myItem);

Equip An Item

The TryEquip method attempts to equip an ItemStack at the first slot possible. This method returns true if the item was successfully equipped. This may fail if there isn't a slot that can equip the item.

bool result = Inventool.Equipment.TryEquip(itemStack);

Unequipping

Unequip An Item

The TryUnequip method attempts to unequip an ItemStack. This method returns true if the item was successfully unequipped. This will only fail if the item stack was not equipped.

bool result = Inventool.Equipment.TryUnequip(itemStack);

Unequip All

The UnequipAll method unequips all item stacks from all slots.

Inventool.Equipment.UnequipAll();

Last updated