Esempio n. 1
0
        BehaviourTree CheckInstance()
        {
            if (subTree == currentInstance)
            {
                return(currentInstance);
            }
            //-----------------------Custom NestedGraphOwner
            if (NestedGraphOwner.value != null)
            {
                graph.agent = NestedGraphOwner.value;
            }
            else
            {
                NestedGraphOwner.value = graph.agent.transform;
            }
            BehaviourTree instance = null;

            if (!instances.TryGetValue(subTree, out instance))
            {
                instance           = Graph.Clone <BehaviourTree>(subTree);
                instances[subTree] = instance;
                for (var i = 0; i < instance.allNodes.Count; i++)
                {
                    instance.allNodes[i].OnGraphStarted();
                }
            }

            instance.agent      = graphAgent;
            instance.blackboard = graphBlackboard;
            instance.UpdateReferences(graphAgent, graphBlackboard);
            subTree = instance;
            return(instance);
        }
Esempio n. 2
0
        BehaviourTree CheckInstance()
        {
            if (subTree == currentInstance)
            {
                return(currentInstance);
            }

            BehaviourTree instance = null;

            if (!instances.TryGetValue(subTree, out instance))
            {
                instance           = Graph.Clone <BehaviourTree>(subTree);
                instances[subTree] = instance;
                for (var i = 0; i < instance.allNodes.Count; i++)
                {
                    instance.allNodes[i].OnGraphStarted();
                }
            }

            instance.agent      = graphAgent;
            instance.blackboard = graphBlackboard;
            instance.UpdateReferences();
            subTree = instance;
            return(instance);
        }
Esempio n. 3
0
        public void Init()
        {
            if (bt == null)
            {
                return;
            }

            bt.agent      = graphAgent;
            bt.blackboard = graphBlackboard;
            bt.UpdateReferences();

            for (var i = 0; i < bt.allNodes.Count; i++)
            {
                bt.allNodes[i].OnGraphStarted();
            }
        }