/// <summary> /// Splice a sub tree into the parent tree. /// </summary> public BehaviorTreeBuilder Splice(IBehaviorTreeNode subTree) { Debug.Assert(subTree != null, "Subtree is null"); Debug.Assert(subTree is RootNode, "Subtree has to start with a root node"); parentNodeStack.Peek().AddChild(((RootNode)subTree).ExchangeRootNode(rootNode)); return(this); }
public override void AddChild(IBehaviorTreeNode child) { if (AddIfChild) { ifTrue = child; } else { ifFalse = child; } }
public static void Stop(this IBehaviorTreeNode node) { if (node.last_status == BHS.RUNNING) { node.Deinit(); } if (node.last_status != BHS.NONE) { node.Defer(); } node.last_status = BHS.NONE; }
public void SetSlave(IBehaviorTreeNode node) { if (children.Count == 0) { this.AddChild(node); } //NOTE: should we stop the current one? else { children[0] = node; } }
public override BehaviorTreeInternalNode AddChild(IBehaviorTreeNode new_child) { //force DEFER to proceed to the next node var d = new_child as DeferNode; if (d != null) { d.result = BHS.FAILURE; } children.Add(new_child); return(this); }
public static BHS Run(this IBehaviorTreeNode node) { if (node.last_status != BHS.RUNNING) { node.Init(); } node.last_status = node.Execute(); if (node.last_status != BHS.RUNNING) { node.Deinit(); } return(node.last_status); }
public override BehaviorTreeInternalNode AddChild(IBehaviorTreeNode new_child) { //force DEFER to keep running var d = new_child as DeferNode; if (d != null) { d.result = BHS.RUNNING; } children.Add(new_child); return(this); }
void Start() { BehaviorTreeBuilder builder = new BehaviorTreeBuilder(); builder.Sequence("sequence1"); builder.Action("action1", Action01); builder.Action("action2", Action02); builder.Sequence("sequence02"); builder.Action("action03", Action03); builder.Action("action04", Action04); builder.End(); builder.Action("Action05", Action05); builder.Action("Action06", Action06); builder.End(); tree = builder.Build(); }
public static IBehaviorTreeNode WithFightingAI(IBehaviorTreeNode tree, MovingEntity entity) { BehaviorTreeBuilder builder = new BehaviorTreeBuilder(((RootNode)tree).TickFrequency); return(builder .Selector() .LongRunning(() => new FightTask(entity)) .Sequence() .SingleStepResultCached((GameTime gameTime) => { entity.StopWalking(); return BehaviourTreeStatus.Success; }) .Splice(tree) .End() .End() .Build()); }
public BehaviorTreeSelector Add(IBehaviorTreeNode node) { NodeList.Add(node); return(this); }
public void SetIfFalse(IBehaviorTreeNode child) { Debug.Assert(ifFalse == null, "ifFalse was already set!"); ifFalse = child; }
public IBehaviorTreeNode AddChild(IBehaviorTreeNode _node) { children.Add(_node); return(this); }
public void AddChild(IBehaviorTreeNode child) { m_childrens.Add(child); }
public void Proxy(IBehaviorTreeNode _child) { child = _child; }
public void AddChild(IBehaviorTreeNode _node) { children.Add(_node); }
public abstract void AddChild(IBehaviorTreeNode child);
//Finished building a composite node //Removes composite node from the top of parentstacklist public BehaviorTreeBuilder End() { m_currentParentNode = m_parentNodeStack.Pop(); return(this); }
public virtual BehaviorTreeInternalNode AddChild(IBehaviorTreeNode new_child) { children.Add(new_child); return(this); }
public void AddChild(IBehaviorTreeNode child) { childNode = child; }
public override void AddChild(IBehaviorTreeNode child) { children.Add(child); }
public void AddChild(IBehaviorTreeNode root) { this.root = root; }
public void DelChild(IBehaviorTreeNode _node) { children.Remove(_node); }
public BehaviorTreeSequence Add(IBehaviorTreeNode node) { NodeList.Add(node); return(this); }
/// <summary> /// Ends a sequence of children. /// </summary> public BehaviorTreeBuilder End() { curNode = parentNodeStack.Pop(); return(this); }
public IBehaviorTreeNode AddChild(IBehaviorTreeNode _child) { child = _child; return(this); }
public IBehaviorTreeNode AddChild(IBehaviorTreeNode root) { this.root = root; return(this); }