コード例 #1
0
        private void ShowNodeContextMenu(BehaviourTreeEditorNode node)
        {
            GenericMenu menu = new GenericMenu();

            if (node.connectedTo.Any())
            {
                foreach (var info in node.connectedTo)
                {
                    menu.AddItem
                    (
                        new GUIContent($"Disconnect.../{info.Node.Name}"),
                        false,
                        () => View.DisconnectNodes(node, info.Node as BehaviourTreeEditorNode)
                    );
                }
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Disconnect..."));
            }

            menu.AddItem(new GUIContent("Delete"), false, () => View.DeleteNode(node));
            menu.AddItem(new GUIContent("Set as Root"), false, () =>
            {
                Undo.RecordObject(TreeAsset, "Set root node");
                TreeAsset.RootNode = node.TreeNode;
            });

            menu.ShowAsContext();
        }
コード例 #2
0
 public void OnNodeDisconnected(BehaviourTreeEditorNode parent, BehaviourTreeEditorNode child)
 {
     if (parent.TreeNode.IsParentNode())
     {
         parent.TreeNode.AsParentNode().GetChildNodes().Remove(child.TreeNode);
     }
 }
コード例 #3
0
 public void TryBeginConnection(BehaviourTreeEditorNode source, Vector2 position)
 {
     if (source.TreeNode.IsParentNode())
     {
         Nodes.StartConnection(source, position);
     }
 }
コード例 #4
0
        internal GraphNode OnNodeAdded(BehaviourTree asset, BehaviourTreeNode node)
        {
            var newNode = new BehaviourTreeEditorNode(asset, node, Presenter);

            Nodes.AddNode(newNode);

            return(newNode);
        }
コード例 #5
0
        private void DeleteFromAsset(BehaviourTreeEditorNode node)
        {
            Undo.RecordObject(TreeAsset, $"Removed {node.Name}");

            foreach (BehaviourTreeNode treeNode in TreeAsset.Nodes)
            {
                if (treeNode.IsParentNode())
                {
                    treeNode.AsParentNode().GetChildNodes().Remove(node.TreeNode);
                }
            }

            TreeAsset.Nodes.Remove(node.TreeNode);
        }
コード例 #6
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);
                            }
                        }
                    }
                }
            }
        }
コード例 #7
0
        public void DisconnectNodes(BehaviourTreeEditorNode parent, BehaviourTreeEditorNode toRemove)
        {
//            parent.RemoveConnection(toRemove);
            Presenter.OnNodeDisconnected(parent, toRemove);
        }
コード例 #8
0
 public void DeleteNode(BehaviourTreeEditorNode node)
 {
     Nodes.OnDeleteNode.Post().Node = node;
 }
コード例 #9
0
        public void TryBeginConnection(BehaviourTreeEditorNode source, Vector2 position)
        {
//            if (source.TreeNode.IsParentNode())
//                Nodes.StartConnection(source, position);
            throw new NotImplementedException("TODO!");
        }
コード例 #10
0
 public void OnNodeDeleted(BehaviourTreeEditorNode node)
 {
     DeleteFromAsset(node);
 }
コード例 #11
0
 public void OnEmptyDotClicked(BehaviourTreeEditorNode source, Vector2 position)
 {
     View.TryBeginConnection(source, position);
 }
コード例 #12
0
 public void OnNodeRightClick(BehaviourTreeEditorNode node, Vector2 mousePos)
 {
     ShowNodeContextMenu(node);
 }