public void RemoveSlot(IWeaponSlot slot)
 {
     if (slots.Remove(slot))
     {
         UnsubscribeFromSlotEvents(slot);
     }
 }
 public bool EmptySlot(IWeaponSlot slot)
 {
     if (!OwnsSlot(slot))
     {
         return(false);
     }
     return(slot.Unequip());
 }
 public void AddSlot(IWeaponSlot slot)
 {
     if (slots.Contains(slot))
     {
         return;
     }
     slots.Add(slot);
     SubscribeToSlotEvents(slot);
 }
        public bool UnequipWeapon(IWeapon weapon)
        {
            IWeaponSlot matchingSlot = GetMatchingSlot(weapon);

            if (matchingSlot == null)
            {
                return(false);
            }
            return(matchingSlot.Unequip());
        }
        public bool EquipWeapon(IWeapon weapon)
        {
            if (IsEquipped(weapon))
            {
                return(false);
            }
            IWeaponSlot emptySlot = FindEmptySlot;

            return(EquipWeapon(emptySlot, weapon));
        }
        public bool EmptySlotAtIndex(int index)
        {
            IWeaponSlot slot = GetSlotAtIndex(index);

            if (slot == null)
            {
                return(false);
            }
            return(slot.Unequip());
        }
 public int GetSlotIndex(IWeaponSlot slot)
 => slot != null?slots.IndexOf(slot) : -1;
 public bool EquipWeapon(IWeaponSlot slot, IWeapon weapon)
 => OwnsSlot(slot) ? slot.Equip(weapon) : false;
        public bool OwnsSlot(IWeaponSlot slot)
        {
            int index = GetSlotIndex(slot);

            return(index >= 0 && index < SlotCount);
        }
Ejemplo n.º 10
0
 public void UnsubscribeFromSlotEvents(IWeaponSlot slot)
 {
     slot.OnEquipped   -= WeaponEquipped;
     slot.OnUnequipped -= WeaponUnequipped;
 }
Ejemplo n.º 11
0
 private void SubscribeToSlotEvents(IWeaponSlot slot)
 {
     slot.OnEquipped   += WeaponEquipped;
     slot.OnUnequipped += WeaponUnequipped;
 }