示例#1
0
 public void addChild(PLAN_TASK childTask)
 {
     if (null == ChildTask)
     {
         ChildTask = new LinkedList <PLAN_TASK>();
     }
     ChildTask.AddLast(childTask);
 }
        protected override void OnStart()
        {
            base.OnStart();

            props.IsEventTriggered = false;

            SubscribeEvent <SimpleEventTriggeredEvent>();

            ChildTask.EnqueueForUpdate();
        }
        /// <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);
        }
        protected override TaskResult OnUpdate()
        {
            if (props.IsEventTriggered)
            {
                ChildTask.EnqueueForAbort();

                return(TaskResult.Success);
            }

            return(ChildTask.LastResult);
        }
示例#6
0
        /// <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);
        }
示例#8
0
        private bool IsTaskExists(string taskId, out ChildTask childTask)
        {
            childTask = new ChildTask();

            var result = Guid.TryParse(taskId, out var item);

            if (result)
            {
                childTask = _tasksRepo.Data.FirstOrDefault(x => x.Id == item);
                return(true);
            }

            return(false);
        }
示例#9
0
        protected override void OnStart()
        {
            base.OnStart();

            props.WaitForChildCompleted = true;
            props.Count = 0;

            if (description.ShareCount)
            {
                SetSharedVariable("LoopCount", VariableType.UInteger, VariableSource.LiteralConstant, props.Count.ToString());
            }

            ChildTask.EnqueueForUpdate();
        }
示例#10
0
        private IQueryable <ChildTask> GetTasksData(string userId, bool isChild)
        {
            var data = new ChildTask[] { }.AsQueryable();

            if (isChild)
            {
                data = _tasksRepo.Data.Where(x => x.ChildId == userId);
            }
            else
            {
                data = _tasksRepo.Data.Where(x => x.ParentId == userId);
            }

            return(data);
        }
示例#11
0
        protected override TaskResult OnUpdate()
        {
            if (props.WaitForChildCompleted)
            {
                if (ChildTask.LastResult == TaskResult.Running)
                {
                    return(TaskResult.Running);
                }

                ++props.Count;
                if (description.ShareCount)
                {
                    SetSharedVariable("LoopCount", VariableType.UInteger, VariableSource.LiteralConstant, props.Count.ToString());
                }

                if (description.Count > 0 && props.Count >= description.Count)
                {
                    return(TaskResult.Failure);
                }

                if (!IsRepeaterCompleted(ChildTask.LastResult))
                {
                    props.WaitForChildCompleted = false;
                    if (Owner.CurrentTime > props.LastUpdateTime)
                    {
                        EnqueueForUpdate();
                    }
                    else
                    {
                        EnqueueForNextUpdate();
                    }
                }
            }
            else
            {
                props.WaitForChildCompleted = true;
                ChildTask.EnqueueForUpdate();
            }

            props.LastUpdateTime = Owner.CurrentTime;

            return(TaskResult.Running);
        }
示例#12
0
        protected override void OnStart()
        {
            base.OnStart();

            ChildTask.EnqueueForUpdate();
        }
示例#13
0
        /// <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);
        }