/** * This method sets the positions of all tasks below <code>t</code> in the * tree. * * @param t * the task whose descendants will be computed their positions. */ private void RecursiveComputePositions(ModelTask t) { /* * Set the position of all of the children of this task and recursively * compute the position of the rest of the tasks. */ for (var i = 0; i < t._children.Count; i++) { var currentChild = t._children[i]; var currentChildPos = new Position(t.Position); currentChildPos.AddMove(i); currentChild._position = currentChildPos; RecursiveComputePositions(currentChild); } }
/** * This method computes the positions of all the tasks of the behaviour tree * whose root is this node. After calling this method, the positions of all * the tasks below this one will be available and accessible through * {@link #getPosition()}. * <p> * It is important to note that, when calling this method, this task is * considered to be the root of the behaviour tree, so its position will be * set to an empty sequence of moves, with no offset, and the positions of * the tasks below it will be computed from it. */ public void ComputePositions() { /* Assume this node is the root of the tree. */ _position = new Position(new List <int>()); /* * Set the position of all of the children of this task and recursively * compute the position of the rest of the tasks. */ for (var i = 0; i < _children.Count; i++) { ModelTask currentChild = _children[i]; var currentChildPos = new Position(_position); currentChildPos.AddMove(i); currentChild._position = currentChildPos; RecursiveComputePositions(currentChild); } }
/** * 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); } }
/** * This method computes the positions of all the tasks of the behaviour tree * whose root is this node. After calling this method, the positions of all * the tasks below this one will be available and accessible through * {@link #getPosition()}. * <p> * It is important to note that, when calling this method, this task is * considered to be the root of the behaviour tree, so its position will be * set to an empty sequence of moves, with no offset, and the positions of * the tasks below it will be computed from it. */ public void ComputePositions() { /* Assume this node is the root of the tree. */ _position = new Position(new List<int>()); /* * Set the position of all of the children of this task and recursively * compute the position of the rest of the tasks. */ for (var i = 0; i < _children.Count; i++) { ModelTask currentChild = _children[i]; var currentChildPos = new Position(_position); currentChildPos.AddMove(i); currentChild._position = currentChildPos; RecursiveComputePositions(currentChild); } }