Esempio n. 1
0
 public ModelTask(ModelTask guard, params ModelTask[] children)
 {
     this.guard = guard;
     this.children = new List<ModelTask>();
     foreach (ModelTask t in children) {
         this.children.Add(t);
     }
     this.position = new Position();
 }
        public ExecutionTask(ModelTask modelTask, IBTExecutor executor, ExecutionTask parent)
        {
            this.modelTask = modelTask;
            this.executor = executor;
            this.spawnable = true;
            this.tickable = false;
            this.status = TaskStatus.UNINITIALISED;

            if (parent == null) {
                this.position = new Position();
            }
            else {
                this.position = new Position(parent.position);
                this.position.AddMove(GetMove());
                this.parent = parent;
            }
        }
 public DataContext GetTaskState(Position pos)
 {
     if (this.taskStates.ContainsKey(pos)) {
         return this.taskStates[pos];
     }
     return null;
 }
 public void SetTaskState(Position pos, DataContext taskState)
 {
     this.taskStates[pos] = taskState;
 }
Esempio n. 5
0
 // reflection ctor
 public ModelTask()
 {
     this.children = new List<ModelTask>();
     this.position = new Position();
 }
Esempio n. 6
0
 private void RecursiveComputePositions(ModelTask t)
 {
     for (int i = 0; i < t.children.Count; ++i) {
         ModelTask currentChild = t.children[i];
         Position currentChildPos = new Position(t.position);
         currentChildPos.AddMove(i);
         currentChild.position = currentChildPos;
         RecursiveComputePositions(currentChild);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 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()}.
        ///
        /// 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.
        /// </summary>
        public void ComputePositions()
        {
            // assume this node is the root of the tree
            this.position = new Position(new LinkedList<int>());

            /*
             * Set the position of all of the children of this task and recursively
             * compute the position of the rest of the tasks.
             */
            for (int i = 0; i < this.children.Count; ++i) {
                ModelTask currentChild = this.children[i];
                Position currentChildPos = new Position(this.position);
                currentChildPos.AddMove(i);
                currentChild.position = currentChildPos;
                RecursiveComputePositions(currentChild);
            }
        }
Esempio n. 8
0
 public Position(Position copy)
 {
     this.moves = new LinkedList<int>(copy.moves);
 }