public override TreeBaseNode WalkGraphToCreateTree(BehaviourTree.BehaviourTree tree, Context currentContext)
        {
            var node = new TreeSelectorNode(tree, currentContext);

            WalkCompositeNodeChildren(node, tree);
            return(node);
        }
示例#2
0
        public override TreeBaseNode WalkGraphToCreateTree(BehaviourTree.BehaviourTree tree, Context currentContext)
        {
            var treeRoot = new TreeRootNode(tree, null);

            treeRoot.context = new Context(null, treeRoot);

            return(WalkDecoratorNode(tree, treeRoot));
        }
示例#3
0
        public override TreeBaseNode WalkGraphToCreateTree(BehaviourTree.BehaviourTree tree, Context currentContext)
        {
            var node = new TreeLeafDebugNode(tree, currentContext)
            {
                debugMessage = debugNote
            };

            return(node);
        }
        /// <summary>
        /// Generates an executable behaviour tree from this behaviour graph.
        /// </summary>
        /// <param name="executingOn">Which object to create the tree for</param>
        /// <returns>A behaviour tree for the input game object.</returns>
        public BehaviourTree.BehaviourTree GenerateBehaviourTree(GameObject executingOn)
        {
            var          cloneTree = new BehaviourTree.BehaviourTree(executingOn);
            TreeBaseNode treeRoot  = root.WalkGraphToCreateTree(cloneTree, null);

            cloneTree.RuntimeSetup(treeRoot, executingOn);
            treeRoot.Reset();

            return(cloneTree);
        }
        public override TreeBaseNode WalkGraphToCreateTree(BehaviourTree.BehaviourTree tree, Context currentContext)
        {
            RuntimeCondition brtc =
                new RuntimeCondition(conditionalSelector, tree.owner);

            TreeConditionNode node = new TreeConditionNode(tree, currentContext)
            {
                runtimeCondition = brtc
            };

            return(WalkDecoratorNode(tree, node));
        }
示例#6
0
        public override TreeBaseNode WalkGraphToCreateTree(BehaviourTree.BehaviourTree tree, Context currentContext)
        {
            if (AttributeCache <Service> .TryGetCachedMemberViaLookupValue(service.targetMethod,
                                                                           out var method))
            {
                var node = new TreeServiceLeafNode(tree, currentContext)
                {
                    targetMethod = method as MethodInfo
                };
                return(node);
            }

            Debug.LogError("Unable to recover cached member lookup value for service: " + service.targetMethod);
            return(null);
        }
        protected TreeDecoratorNode WalkDecoratorNode(BehaviourTree.BehaviourTree tree, TreeDecoratorNode node)
        {
            var nodePort = GetOutputPort("childNode");

            BaseNode connectionBaseNode = nodePort.Connection.node as BaseNode;

            Debug.Assert(connectionBaseNode != null,
                         nameof(connectionBaseNode) + " != null");

            if (connectionBaseNode == null)
            {
                Debug.LogError("Behaviour graph node: " + this.name +
                               " was not connected to a child.", this);
            }
            node.child = connectionBaseNode.WalkGraphToCreateTree(tree, node.context);
            return(node);
        }
        protected void WalkCompositeNodeChildren(TreeCompositeNode composite, BehaviourTree.BehaviourTree tree)
        {
            var childrenPort = GetOutputPort("children");
            var connections  = childrenPort.GetConnections();
            List <TreeBaseNode> treeNodes = new List <TreeBaseNode>();

            foreach (var connector in connections)
            {
                BaseNode bn = connector.node as BaseNode;
                Debug.Assert(bn != null, nameof(bn) + " != null");
                if (bn == null)
                {
                    Debug.LogError("Behaviour graph node: " + this.name + " was not connected to a child.", this);
                }

                treeNodes.Add(bn.WalkGraphToCreateTree(tree, composite.context));
            }

            composite.SetChildren(treeNodes);
        }
示例#9
0
        public override TreeBaseNode WalkGraphToCreateTree(BehaviourTree.BehaviourTree tree, Context currentContext)
        {
            var node = new TreeInvertNode(tree, currentContext);

            return(WalkDecoratorNode(tree, node));
        }
示例#10
0
 public abstract TreeBaseNode WalkGraphToCreateTree(BehaviourTree.BehaviourTree tree,
                                                    Context currentContext);