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."); } }
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!"); } }
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; } }
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); } }
public ModelInverter(ModelTask guard, ModelTask child) : base(guard, child) { }
public ModelDecorator(ModelTask guard, params ModelTask[] child) : base(guard, child) { }
public ModelLeaf(ModelTask guard) : base(guard) { }
public ModelSequence(ModelTask guard, params ModelTask[] children) : base(guard, children) { }
public ModelRepeat(ModelTask guard, ModelTask child) : base(guard, child) { }
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); } } }
public ModelSelector(ModelTask guard, params ModelTask[] children) : base(guard, children) { }
public ModelAction(ModelTask guard) : base(guard) { }
public ModelStatusResponder(ModelTask guard, params ModelTask[] children) : base(guard, children) { }