How-To: Gate Equipping and Unequipping
Goal: refuse an equip the player is not allowed to make - wrong level, in combat, cursed item - and hook the moment one item displaces another.
1. Subclass the manager
The three gates are BlueprintNativeEvents on UCrimsonEquipmentManagerComponent, so you override them on a subclass and use that subclass instead of the base.
Right-click in the Content Browser -> Add -> Crimson Plugins -> Equipment -> Equipment Manager Component. Add that class to your pawn instead of the base - it appears under Add Component just like the base does - or name it in the Game Feature action's Equipment Manager Class.
Crimson Equipment Manager Component.2. Block an equip with Can Equip Item
Can Equip Item is asked before anything happens - before the instance is created, before the slot is resolved. Return false and Equip Item logs the refusal and returns null, leaving the equipment untouched.
Override the Can Equip Item event on your manager Blueprint. It gives you Equipment Definition and Source Object; return a boolean. Get Owner -> Cast to your pawn to read whatever state the rule needs.
Keep it pure - it is a question, not an action. Do not equip, unequip or mutate anything inside it.
ICrimsonEquipmentHost::CanEquip calls this same hook, and reports its refusal as the failure text "Equipping is currently blocked." So an item system asking the bridge whether an equip is legal gets your answer without knowing your rules.false unconditionally: Equip Item returns null, nothing appears on the pawn, and LogCrimsonEquipment logs the refusal. Return true and the equip proceeds normally.3. Block an unequip with Can Unequip Item
Can Unequip Item is asked before an item leaves - a cursed ring the player cannot remove, gear locked during a scripted sequence.
Unequip Item with Force ticked skips Can Unequip Item altogether, and several internal paths pass Force on purpose: the item displaced when you equip into an occupied slot, the wipe at the start of Restore From Save Data, and the teardown when the component is uninitialized. A cursed item is still removed by those. If it must survive a slot displacement, refuse the incoming equip in Can Equip Item as well.Override the Can Unequip Item event, cast the Item Instance to your instance class, and return false while the item is locked.
Unequip Item with Force off: it stays. Call it again with Force on and it comes off.4. Hand shared resources over with On Before Swap Unequip
When you equip into an occupied slot, the manager equips the incoming item first and removes the occupant second, so anything both items own is never briefly ownerless. On Before Swap Unequip fires between those two steps, with both instances in hand.
| Order | What has happened |
|---|---|
| 1 | The incoming item is fully equipped: abilities granted, actors spawned, its OnEquipped has run. |
| 2 | On Before Swap Unequip (Incoming, Outgoing) is called. |
| 3 | The outgoing item is force-unequipped: OnUnequipped runs, actors are destroyed, grants are revoked. |
Override the On Before Swap Unequip event. Use it to move ownership of anything the two items share - a hotbar context, a charge counter, a skill tree the weapon type owns - from Outgoing to Incoming while both still exist.
Swap Equipped Items, which only re-labels slots and unequips nothing.See also
- How-To: Shape the Slot Layout
- Concept: Slots and Displacement
- How-To: Bridge an Item System