Пример #1
0
    // updates the task queue
    public void Update()
    {
        // if we're out of steps, we can't update anything
        if (steps.Count == 0)
        {
            return;
        }

        // see the next step and update its timer
        Step s = steps.Peek();

        s.Timer += Time.deltaTime;

        // handle the step
        switch (s.Type)
        {
        // actions just get invoked
        case StepType.Action:
            s.Action();
            s.Action = null;
            stepCache.Push(steps.Dequeue());
            break;

        // timers check for a specific time before moving on
        case StepType.TimeWait:
            if (s.Timer >= s.Length)
            {
                stepCache.Push(steps.Dequeue());
            }
            break;

        // conditions require a delegate to return true to move on
        case StepType.ConditionWait:
            if (s.Condition(s.Timer))
            {
                s.Condition = null;
                stepCache.Push(steps.Dequeue());
            }
            break;

        default:
            break;
        }
    }
Пример #2
0
 internal async Task ExecuteStepAsync(Step step)
 {
     try
     {
         PreExecution(step);
         if (step.ActionAsync == null && step.Action != null)
         {
             await Task.Run(() => { step.Action(step); });
         }
         else
         {
             await step.ActionAsync(step);
         }
         PostExecution(step);
     }
     catch (Exception ex)
     {
         stepExceptionHandler.HandleException(this, step, ex);
     }
 }