/// <summary>
        /// Add a child to the parent node.
        /// </summary>
        public override void AddChild(BehaviourTreeNode <T> child)
        {
            if (this.ChildNode != null)
            {
                throw new ApplicationException("Can't add more than a single child to SucceederNode!");
            }

            base.AddChild(child);
        }
示例#2
0
        /// <summary>
        /// Splice a sub tree into the parent tree.
        /// </summary>
        public BehaviourTreeBuilder <T> Splice(BehaviourTreeNode <T> subTree)
        {
            if (subTree == null)
            {
                throw new ArgumentNullException("subTree");
            }
            if (_parentNodeStack.Count <= 0)
            {
                throw new ApplicationException("Can't splice an unnested sub-tree, there must be a parent-tree.");
            }

            _parentNodeStack.Peek().AddChild(subTree);
            return(this);
        }
        /// <summary>
        /// Add an action node.
        /// </summary>
        public BehaviourTreeBuilder Do(BehaviourTreeNode node)
        {
            if (_parentNodeStack.Count <= 0)
            {
                throw new ApplicationException("Can't create an unnested ActionNode, it must be a leaf node.");
            }

            var id = ++_idCounter;

            node.Id = id;

            _parentNodeStack.Peek().AddChild(node);

            return(this);
        }
示例#4
0
 /// <summary>
 /// Ends a sequence of children.
 /// </summary>
 public BehaviourTreeBuilder <T> End()
 {
     _curNode = _parentNodeStack.Pop();
     return(this);
 }
示例#5
0
 /// <summary>
 /// Add a child to the parent node.
 /// </summary>
 public virtual void AddChild(BehaviourTreeNode child)
 {
     _children.Add(child);
 }