// Task management // AddTask: // - Adds the created task to a queue // - Starts the task if it's the first one in the queue protected virtual void AddTask(S_AI_Task newTask) { tasks.Enqueue(newTask); if (tasks.Count == 1) { StartTask(); } }
// StartTask: // - Check if current task is already finished // - Calls CreateSubtasks() // - Check if subtasks successfully created // - Starts sub tasks if successful // - Finishes Task if unsuccessful private void StartTask() { currentTask = tasks.Peek(); if (QueryCurrentTaskFinished()) { FinishTask(); return; } bool success = CreateSubTasks(); if (success) { StartSubTask(); } else { FinishTask(); } }