private bool CanExecute(EntityAITask task) { int taskPriority = 0; int givenTaskPriority = tasks.IndexOf(task); foreach (EntityAITask taskToCheck in tasks.GetRange(0, tasks.IndexOf(task))) { if (givenTaskPriority > taskPriority++) { if (executingTasks.IndexOf(taskToCheck) != -1 && !this.AreTasksCompatible(task, taskToCheck)) { return(false); } } else if (executingTasks.IndexOf(taskToCheck) != -1 && !taskToCheck.IsInterruptible()) { return(false); } } return(true); }
private bool AreTasksCompatible(EntityAITask task1, EntityAITask task2) { return((task1.GetMutexBits() & task2.GetMutexBits()) == 0); }
public void AddTask(EntityAITask task) { task.ResetTask(); tasks.Add(task); }