Пример #1
0
        /// <summary>
        /// Can the item be used?
        /// </summary>
        /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
        /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
        /// <returns>True if the item can be used.</returns>
        public override bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState)
        {
            if (!base.CanUseItem(itemAbility, abilityState))
            {
                return(false);
            }

            // The item can't be used if it is already being used.
            if (abilityState == UseAbilityState.Start && (m_Throwing || m_Reequipping))
            {
                return(false);
            }

            // The item can't be used if there aren't any items left.
            if (m_Inventory != null && m_Inventory.GetItemIdentifierAmount(m_Item.ItemIdentifier) == 0)
            {
                return(false);
            }

            // The item can't be used if it hasn't been started yet, is reequipping the throwable item, or has been requipped.
            if (abilityState == UseAbilityState.Update && (!m_Throwing || m_Reequipping || m_Reequipped))
            {
                return(false);
            }

            // Give the item a frame to recover from the reequip.
            if (Time.frameCount == m_ReequipFrame)
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Can the item be used?
        /// </summary>
        /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
        /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
        /// <returns>True if the item can be used.</returns>
        public override bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState)
        {
            if (!base.CanUseItem(itemAbility, abilityState))
            {
                return(false);
            }

            // The item can't be used if it is already being used.
            if (abilityState == UseAbilityState.Start && (m_Throwing || m_Reequipping))
            {
                return(false);
            }

            // The item can't be used if there aren't any items left.
            if (m_Inventory != null && m_Inventory.GetItemTypeCount(m_ConsumableItemType) == 0)
            {
                return(false);
            }

            // The item can't be used if it hasn't been started yet, is reequipping the throwable item, or has been requipped.
            if (abilityState == UseAbilityState.Update && (!m_Throwing || m_Reequipping || m_Reequipped))
            {
                return(false);
            }

            return(true);
        }
Пример #3
0
 /// <summary>
 /// Can the item be used?
 /// </summary>
 /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
 /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
 /// <returns>True if the item can be used.</returns>
 public override bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState)
 {
     if (!base.CanUseItem(itemAbility, abilityState)) {
         return false;
     }
     if (abilityState == UseAbilityState.Update) {
         // Don't allow the item to continue to be reused if it can no longer be used.
         if (m_Used && CanStopItemUse()) {
             return false;
         }
     } else if (abilityState == UseAbilityState.Start) {
         // Certain items require the character to be grounded.
         if (m_RequireGrounded && !m_CharacterLocomotion.Grounded) {
             return false;
         }
         // The item can't start if it is in the process of being stopped.
         if (m_Stopping) {
             return false;
         }
         // If the cast isn't valid then the item shouldn't start.
         if (m_Direction == CastDirection.Target) {
             DetermineTargetColliders();
         }
         if (!DetermineCastValues(0, ref m_CastDirection, ref m_CastPosition, ref m_CastNormal)) {
             return false;
         }
     }
     return true;
 }
Пример #4
0
        /// <summary>
        /// Can the item be used?
        /// </summary>
        /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
        /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
        /// <returns>True if the item can be used.</returns>
        public override bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState)
        {
            if (!base.CanUseItem(itemAbility, abilityState))
            {
                return(false);
            }

            // The flashlight can't be used if there is no battery left.
            if (m_BatteryModifier != null && !m_BatteryModifier.IsValid())
            {
                return(false);
            }

            return(true);
        }
Пример #5
0
        /// <summary>
        /// Can the item be used?
        /// </summary>
        /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
        /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
        /// <returns>True if the item can be used.</returns>
        public virtual bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState)
        {
            // Prevent the item from being used too soon.
            if (Time.time < m_NextAllowedUseTime)
            {
                return(false);
            }

            // The attribute may prevent the item from being used (such as if the character doesn't have enough stamina to use the item).
            if ((m_UseAttribute != null && !m_UseAttribute.IsValid(-m_UseAttributeAmount)) ||
                (m_CharacterUseAttribute != null && !m_CharacterUseAttribute.IsValid(-m_CharacterUseAttributeAmount)))
            {
                return(false);
            }

            return(true);
        }
Пример #6
0
        /// <summary>
        /// Can the item be used?
        /// </summary>
        /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
        /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
        /// <param name="checkAttributes">Should the use attributes be checked?</param>
        /// <returns>True if the item can be used.</returns>
        protected bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState, bool checkAttributes)
        {
            // Prevent the item from being used too soon.
            if (Time.time < m_NextAllowedUseTime)
            {
                return(false);
            }

            // The attribute may prevent the item from being used (such as if the character doesn't have enough stamina to use the item).
            if (checkAttributes && InvalidUseAttributes())
            {
                // The item can no longer be used. Stop the ability.
                if (abilityState != UseAbilityState.Start)
                {
                    itemAbility.StopAbility();
                }
                return(false);
            }

            return(true);
        }
Пример #7
0
 /// <summary>
 /// Can the item be used?
 /// </summary>
 /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
 /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
 /// <param name="checkAttributes">Should the use attributes be checked?</param>
 /// <returns>True if the item can be used.</returns>
 public virtual bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState)
 {
     return(CanUseItem(itemAbility, abilityState, true));
 }