/// <summary> /// If the maximum run count has not been reached, this executes the wrapped task and /// returns a code indicating the result of execution. Otherwise, the execution /// is deferred. /// </summary> /// <returns>Code indicating the result of executing the task or a deferred code if the task /// was not executed.</returns> public override TaskResultCode Execute() { ++_runCount; if (_runCount <= MaxRunCount) { return(ChildTask.Execute()); } return(TaskResultCode.Deferred); }
/// <summary> /// Executes the wrapped task repeatedly as long as it returns /// a success result code. /// </summary> /// <returns>Always returns success.</returns> public override TaskResultCode Execute() { TaskResultCode result; do { result = ChildTask.Execute(); }while (result == TaskResultCode.Success); return(TaskResultCode.Success); }
/// <summary> /// If at least <see cref="Frequency"/> milliseconds has passed since the last execution, /// this executes the wrapped task and returns a code indicating the result of execution. Otherwise, /// the execution is deferred. /// </summary> /// <returns>Code indicating the result of executing the task or a deferred code if the task /// was not executed.</returns> public override TaskResultCode Execute() { _timeSinceLastExecute += (float)Director.SharedDirector.GameTime.ElapsedGameTime.TotalMilliseconds; if (_timeSinceLastExecute >= Frequency) { _timeSinceLastExecute = 0.0f; return(ChildTask.Execute()); } return(TaskResultCode.Deferred); }
/// <summary> /// Executes the wrapped task <see cref="RunCount"/> number of times or until /// failure, whichever occurs first. /// </summary> /// <returns>Success if the wrapped task was run the set number of times without failure, /// or the result code of the last iteration if not successful.</returns> public override TaskResultCode Execute() { int count = 0; TaskResultCode result = TaskResultCode.Success; while ((count < RunCount) && (result == TaskResultCode.Success)) { result = ChildTask.Execute(); ++count; } return(result); }
/// <summary> /// Executes the wrapped task, returning the inverse of the tasks result code. /// </summary> /// <returns>Success if the wrapped task returned a non-successful result code, /// or failure if it returned success.</returns> public override TaskResultCode Execute() { TaskResultCode result = ChildTask.Execute(); return((result == TaskResultCode.Success) ? TaskResultCode.Failure : TaskResultCode.Success); }