示例#1
0
        /// <summary>
        /// This function waits until the current task is done before setting the new task.
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public virtual IEnumerator <YieldInstruction> WaitSetTask(GroundTask task)
        {
            yield return(new WaitWhile(() => { return Task != null && !Task.Finished(); }));

            Task = task;
            CoroutineManager.Instance.StartCoroutine(new Coroutine(runToCompletion()), true);
        }
示例#2
0
        /// <summary>
        /// Set the entity's current task to the one specified in parameters.
        /// Only sets the task if the current one is finished!
        /// </summary>
        /// <param name="task">New task to set as current task</param>
        /// <returns>Returns false if the entity is still running a task! And true if the task was properly set!</returns>
        public virtual bool SetTask(GroundTask task)
        {
            if (Task != null && !Task.Finished())
            {
                return(false);
            }

            Task = task;
            return(true);
        }
示例#3
0
        /// <summary>
        /// Set the entity's current task to the one specified in parameters.
        /// Only sets the task if the current one is finished!
        /// </summary>
        /// <param name="task">New task to set as current task</param>
        /// <returns>Returns false if the entity is still running a task! And true if the task was properly set!</returns>
        public virtual bool SetTask(GroundTask task)
        {
            if (Task != null && !Task.Finished())
            {
                return(false);
            }

            Task = task;
            CoroutineManager.Instance.StartCoroutine(new Coroutine(runToCompletion()), true);
            return(true);
        }
示例#4
0
        /// <summary>
        /// Update tasks specifically.
        /// </summary>
        public virtual void UpdateTask()
        {
            if (Task == null)
            {
                return;
            }

            if (TaskState == ETaskState.None)
            {
                CoroutineManager.Instance.StartCoroutine(runToCompletion());
            }
            else if (TaskState == ETaskState.Complete)
            {
                TaskState = ETaskState.None;
            }

            if (Task.Finished())
            {
                Task = null;
            }
        }
示例#5
0
        /// <summary>
        /// This function waits until the current task is done before setting the new task.
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public virtual IEnumerator <YieldInstruction> WaitSetTask(GroundTask task)
        {
            yield return(new WaitWhile(() => { return Task != null && !Task.Finished(); }));

            Task = task;
        }
示例#6
0
        private IEnumerator <YieldInstruction> runToCompletion()
        {
            yield return(CoroutineManager.Instance.StartCoroutine(Task.Run(this)));

            Task = null;
        }