Ejemplo n.º 1
0
 public ModelComposite(ModelTask guard, params ModelTask[] children)
     : base(guard, children)
 {
     if (this.children.Count == 0) {
         throw new ArgumentException("The list of children cannot be empty.");
     }
 }
Ejemplo n.º 2
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 ExecutionSelector(ModelTask modelTask, IBTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(modelTask is ModelSelector)) {
         throw new ArgumentException("The ModelTask must subclass "
         + typeof(ModelSelector) + " but it inherits from "
         + modelTask.GetType().BaseType);
     }
 }
 public ExecutionComposite(ModelTask modelTask, IBTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(typeof(ModelComposite).IsAssignableFrom(modelTask.GetType()))) {
         throw new ArgumentException("The ModelTask " + modelTask.GetType() + " must subclass "
         + typeof(ModelComposite) + " but it inherits from "
         + modelTask.GetType().BaseType);
     }
 }
        public CachingBtExecutor(ModelTask modelBT)
        {
            if (modelBT == null) {
                throw new NullReferenceException("Input ModelTask is null, but must not!");
            }

            this.rootModel = modelBT;
            this.context = new DataContext();
            this.tickableTasks = new List<ExecutionTask>();
            this.tickableTasksDeletionQueue = new List<ExecutionTask>();
            this.tickableTasksInsertionQueue = new List<ExecutionTask>();
            this.taskStates = new Dictionary<Position, DataContext>();
        }
 protected override void InternalSpawn()
 {
     this.decoratedExecutor = ((ModelDecorator)this.ModelTask).GetChild().CreateExecutor(this.BTExecutor, this);
     // This saves us, depending on situation, a lot of cpu time when we don't have to check
     // for the decorated executor status and run through a lot of decisions on each tick.
     // It may return running for a lot of ticks so better listen for when it actually changes
     this.decoratedExecutor.AddTaskStatusChangedCallback(this.DecoratedExecutorStatusChange);
     this.decoratedExecutor.Spawn(this.GetGlobalContext());
     // while not ticking return running
     doNotTick = true;
     failed = false; // if failed, return failed
     this.successModel = this.ModelTask.Children[1];
     this.failModel = this.ModelTask.Children[2];
     if (successModel == null && failModel == null) {
         throw new ArgumentException("At least one condition must be handled by a model in StatusResponder! Both were null!");
     }
 }
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 8
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);
     }
 }
Ejemplo n.º 9
0
 public ModelInverter(ModelTask guard, ModelTask child)
     : base(guard, child)
 {
 }
Ejemplo n.º 10
0
 public ModelDecorator(ModelTask guard, params ModelTask[] child)
     : base(guard, child)
 {
 }
Ejemplo n.º 11
0
 public ModelLeaf(ModelTask guard)
     : base(guard)
 {
 }
Ejemplo n.º 12
0
 public ModelSequence(ModelTask guard, params ModelTask[] children)
     : base(guard, children)
 {
 }
Ejemplo n.º 13
0
 public ModelRepeat(ModelTask guard, ModelTask child)
     : base(guard, child)
 {
 }
Ejemplo n.º 14
0
        private void RecursiveLoadModelTree(UnityBtModel current, ModelTask root)
        {
            var childQueue = new Dictionary<ModelTask, UnityBtModel>();
            if (current.children != null && current.children.Count > 0) {
                foreach (var btModelChild in current.children) {
                    if (btModelChild == null || btModelChild.ModelClassName == null) {
                        continue;
                    }
                    var modelTask = btModelChild.Model;
                    root.Children.Add(modelTask);

                    if (btModelChild.children.Count > 0) {
                        childQueue.Add(modelTask, btModelChild);
                    }
                }
                foreach (var kvp in childQueue) {
                    RecursiveLoadModelTree(kvp.Value, kvp.Key);
                }
            }
        }
Ejemplo n.º 15
0
 public ModelSelector(ModelTask guard, params ModelTask[] children)
     : base(guard, children)
 {
 }
Ejemplo n.º 16
0
 public ModelAction(ModelTask guard)
     : base(guard)
 {
 }
 public ModelStatusResponder(ModelTask guard, params ModelTask[] children)
     : base(guard, children)
 {
 }