Interface IEquipmentController
Interface for equipment controllers, managing equip/unequip logic and activation of equipment slots. Extends character behaviour and item container functionality.
public interface IEquipmentController : ICharacterBehaviour, IItemContainer
- Inherited Members
Remarks
Equipment is predicted. The owner does not ask the server to equip and wait; it queues the request with RequestEquip(Item, int, InventoryType, ItemSlot) or RequestUnequip(ItemSlot, InventoryType), the request rides the next replicate, and both the owner and the server apply it inside that tick's replicate body. The server's reconcile then confirms the socket. A stale reconcile — one describing a tick before the request — is restored and the replay re-applies the request, exactly as it does for movement and abilities. The reliable acknowledgement that used to carry the answer is gone; there is nothing left for it to answer.
The one message that survives is the unequip destination
(EquipmentUnequipItemBroadcast, server to owner only): the container picks the slot
an unequipped item lands in, and although both peers pick deterministically they can
disagree when their copies of the container differ. ApplyUnequipDestination(long, InventoryType, int)
moves the item, by identity, to the slot the server chose.
Properties
OnEquipTriggers
Triggers invoked when this character equips an item. EventData: EquipItemEventData.
List<Trigger> OnEquipTriggers { get; }
Property Value
OnUnequipTriggers
Triggers invoked when this character unequips an item. EventData: EquipItemEventData.
List<Trigger> OnUnequipTriggers { get; }
Property Value
Methods
Activate(int)
Activates the item in the specified equipment slot, typically triggering its use effect.
void Activate(int index)
Parameters
indexintThe equipment slot index to activate.
ApplyUnequipDestination(long, InventoryType, int)
Moves an unequipped item to the slot the server put it in, if this peer has it anywhere else. Owner only; a no-op when the item is already there.
void ApplyUnequipDestination(long itemID, InventoryType container, int slot)
Parameters
itemIDlongIdentity of the item that was unequipped.
containerInventoryTypeThe container the server placed it in.
slotintThe slot within that container.
Equip(Item, int, IItemContainer, ItemSlot)
Equips the specified item into the given equipment slot, handling swaps and unequips as needed.
bool Equip(Item item, int inventoryIndex, IItemContainer container, ItemSlot toSlot)
Parameters
itemItemThe item to equip.
inventoryIndexintThe index in the source inventory.
containerIItemContainerThe source item container (e.g., inventory or bank).
toSlotItemSlotThe equipment slot to equip the item into.
Returns
- bool
True if the item was successfully equipped, false otherwise.
Remarks
Applies immediately on whichever peer calls it. Server-side paths that are not the owner's predicted request — ECA actions, for instance — call this directly; the owner learns of the change through the reconcile. The owner's own requests must go through RequestEquip(Item, int, InventoryType, ItemSlot) instead, so they run inside the replicate tick.
RequestEquip(Item, int, InventoryType, ItemSlot)
Queues an equip to be applied on the owner's next replicate tick.
bool RequestEquip(Item item, int sourceIndex, InventoryType fromContainer, ItemSlot socket)
Parameters
itemItemThe item to equip, as the caller currently sees it.
sourceIndexintIts index in
fromContainer.fromContainerInventoryTypeThe container it is in.
socketItemSlotThe equipment socket it is going to.
Returns
- bool
True when the request was queued.
Remarks
Owner only. Validates what can be validated locally — the item is where the request says, it fits the socket, it has a database identity, neither slot is locked — and refuses without queueing when it cannot. One request is held at a time; a second call before the first has ridden a replicate replaces it, and the displaced request is reported through OnRequestResolved as not applied.
RequestUnequip(ItemSlot, InventoryType)
Queues an unequip to be applied on the owner's next replicate tick.
bool RequestUnequip(ItemSlot socket, InventoryType toContainer)
Parameters
socketItemSlotThe equipment socket being emptied.
toContainerInventoryTypeThe container the item should land in.
Returns
- bool
True when the request was queued.
Remarks
Unequip(IItemContainer, byte, out List<Item>)
Unequips the item from the specified slot and adds it to the given container (e.g., inventory or bank).
bool Unequip(IItemContainer container, byte slot, out List<Item> modifiedItems)
Parameters
containerIItemContainerThe destination item container.
slotbyteThe equipment slot to unequip from.
modifiedItemsList<Item>The list of items modified during the operation.
Returns
- bool
True if the item was successfully unequipped and added, false otherwise.
Remarks
See Equip(Item, int, IItemContainer, ItemSlot) for when to call this directly.
Events
OnItemEquipped
Fired after an item is successfully equipped. Subscribers receive the item and the slot.
event Action<Item, ItemSlot> OnItemEquipped
Event Type
OnItemUnequipped
Fired after an item is successfully unequipped. Subscribers receive the item and the slot.
event Action<Item, ItemSlot> OnItemUnequipped
Event Type
OnRequestResolved
Fired on the owner when a queued request has run in the replicate body, whether or not it was applied. Arguments: the kind, the socket, the container the request named, the container index (or -1 for an unequip), and whether the move happened.
event Action<EquipmentRequestKind, ItemSlot, InventoryType, int, bool> OnRequestResolved
Event Type
Remarks
This is how a panel that marked two slots as waiting learns that nothing will change them. A refusal here is LOCAL — the item was no longer where the request said, or the socket did not fit it. A refusal by the SERVER is not reported through this event at all: it arrives as a reconcile that puts the item back, which updates the slots directly.
OnServerEquipmentChanged
Fired on the server after any equip or unequip has been applied to this controller, from whichever path applied it. The persistence layer is the intended subscriber.
event Action<IEquipmentController, EquipmentChange> OnServerEquipmentChanged