public Item Equip(Item equippable, EquipmentSlot slot) { if (equippable.SlotKind != slot.Kind || !Slots.Contains(slot)) { return(null); } Item previousItem = null; if (SlotsInUse.Contains(slot)) { previousItem = _equipped[slot]; } _equipped[slot] = equippable; SlotsInUse.Add(slot); OnEquipped?.Invoke(slot, equippable); if (previousItem != null) { OnUnequipped?.Invoke(slot, previousItem); } return(previousItem); }
public void Unequip(EquipSlot slot) { Equipable e = _equipment[(int)slot]; _equipment[(int)slot]?.OnUnequip(); _equipment[(int)slot] = null; OnUnequipped?.Invoke(e); }
public bool Unequip() { if (IsEmpty) { return(false); } IWeapon prevWeapon = Weapon; Weapon = null; OnUnequipped?.Invoke(prevWeapon); return(true); }