/** * Constructs an ExecutionTask with an associated ModelTask and a * BTExecutor. The ModelTask represents the conceptual task that the * ExecutionTask is running, and the BTExecutor is that in charge of the * ExecutionTask. Also, the parent of the ExecutionTask must be provided. * * @param modelTask * the ModelTask this ExecutionTask will run. * @param executor * the BTExecutor managing this task. * @param parent * the parent ExecutionTask, or null in case this is the root of * the tree. */ protected ExecutionTask(ModelTask modelTask, IBTExecutor executor, ExecutionTask parent) { _modelTask = modelTask; _executor = executor as BTExecutor; _listeners = new List <ITaskListener>(); _spawnable = true; _tickable = false; _terminated = false; _status = Status.Uninitialized; _parent = parent; if (_modelTask != null) { AlwaysFail = modelTask.AlwaysFail; } /* Compute the position of this node. */ if (parent == null) { _position = new Position(); } else { _position = new Position(parent._position); var nextMove = GetMove(); _position.AddMove(nextMove); } }