Esempio n. 1
0
 public void Enqueue(Ability ability, Context context)
 {
     if (ability == null || context == null)
     {
         return;
     }
     if (currentAbility == null)
     {
         currentAbility = ability;
         currentContext = context;
         currentAbility.Use(context);
     }
     else
     {
         queuedAbility = ability;
         queuedContext = context;
     }
 }
Esempio n. 2
0
        public Ability UpdateCast()
        {
            if (queuedExpire.ReadyWithReset(0.2f))
            {
                queuedAbility = null;
            }

            if (currentAbility == null || !gcdTimer.Ready)
            {
                return(null);
            }

            CastState castState = currentAbility.UpdateCast();

            if (castState == CastState.Invalid)
            {
                Clear();
            }
            else if (castState == CastState.Completed)
            {
                if (currentAbility.IsInstant && !currentAbility.IgnoreGCD)
                {
                    gcdTimer.Reset(GetGlobalCooldownTime(currentAbility));
                }

                currentAbility = queuedAbility;
                currentContext = queuedContext;
                queuedAbility  = null;
                queuedContext  = null;

                if (currentAbility != null && !currentAbility.Use(currentContext))
                {
                    currentAbility = null;
                    currentContext = null;
                }
            }

            return(currentAbility);
        }