private void RecreateNodes()
        {
            Nodes.ClearNodes();

            if (TreeAsset && TreeAsset.RootNode != null)
            {
                CreateNodesRecursive(new BehaviourTreeGraphNode(TreeAsset.RootNode));
            }
        }
Example #2
0
        internal void RecreateNodes(ref BehaviourTreeEditorPresenter.Model model)
        {
            if (NodeLookup != null)
            {
                NodeLookup.Clear();
            }
            else
            {
                NodeLookup = new Dictionary <BehaviourTreeNode, BehaviourTreeEditorNode>();
            }

            Nodes.ClearNodes();
            Nodes.ScrollPos = model.TreeAsset.EditorPos;

            foreach (var node in model.TreeAsset.Nodes)
            {
                var editorNode = new BehaviourTreeEditorNode(model.TreeAsset, node, Presenter);
                NodeLookup[node] = editorNode;
                Nodes.AddNode(editorNode);
            }

            foreach (var node in Nodes.AllNodes.Select(n => n as BehaviourTreeEditorNode))
            {
                if (node != null && node.TreeNode.IsParentNode())
                {
                    var childNodes = node.TreeNode.AsParentNode().GetChildNodes();
                    if (childNodes != null)
                    {
                        foreach (var childNode in childNodes)
                        {
                            var foundNode = NodeLookup[childNode];
                            if (GraphNode.CanMakeConnection(node, foundNode))
                            {
                                GraphNode.MakeConnection(node, foundNode);
                            }
                        }
                    }
                }
            }
        }