Exemple #1
0
        /// <summary>
        /// Unequip the item in the given slot.
        /// </summary>
        /// <param name="slot"></param>
        public void Unequip(EquipmentItem.EquipmentSlot slot)
        {
            switch (slot)
            {
            case EquipmentItem.EquipmentSlot.Head:
                if (_headSlot != null)
                {
                    _headSlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_HeadSlot);
                    OnUnequip?.Invoke(_headSlot);
                    _headSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Torso:
                if (_torsoSlot != null)
                {
                    _torsoSlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_TorsoSlot);
                    OnUnequip?.Invoke(_torsoSlot);
                    _torsoSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Legs:
                if (_legsSlot != null)
                {
                    _legsSlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_LegsSlot);
                    OnUnequip?.Invoke(_legsSlot);
                    _legsSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Feet:
                if (_feetSlot != null)
                {
                    _feetSlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_FeetSlot);
                    OnUnequip?.Invoke(_feetSlot);
                    _feetSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Accessory:
                if (_accessorySlot != null)
                {
                    _accessorySlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_AccessorySlot);
                    OnUnequip?.Invoke(_accessorySlot);
                    _accessorySlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Weapon:
                if (Weapon != null)
                {
                    Weapon.UnequippedBy(_owner);

                    OnUnequip?.Invoke(Weapon);
                    Weapon = null;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(slot), slot, null);
            }
        }