Пример #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;
        }