public void OnNodeDeselect(BTEditorGraphNode node) { if (m_selection.Remove(node)) { node.OnDeselected(); } }
public void IncreaseEditingDepth(BTEditorGraphNode node) { if (node != null && (node.Node is NodeGroup || node.Node is Root)) { m_rootStack.Push(node); } }
public void OnCopyNode(BTEditorGraphNode source) { if (CanCopy(source)) { BTEditorCanvas.Current.Clipboard = BTUtils.SerializeNode(source.Node); } }
private void SetExistingNode(BehaviourNode node) { DestroyChildren(); m_node = node; m_isSelected = false; if (node is Composite) { Composite composite = node as Composite; for (int i = 0; i < composite.ChildCount; i++) { BehaviourNode childNode = composite.GetChild(i); BTEditorGraphNode graphNode = BTEditorGraphNode.CreateExistingNode(this, childNode); m_children.Add(graphNode); } } else if (node is Decorator) { Decorator decorator = node as Decorator; BehaviourNode childNode = decorator.GetChild(); if (childNode != null) { BTEditorGraphNode graphNode = BTEditorGraphNode.CreateExistingNode(this, childNode); m_children.Add(graphNode); } } }
public BTEditorGraphNode OnInsertChild(int index, BehaviourNode node) { if (node != null && ((m_node is Composite) || (m_node is Decorator))) { BTEditorGraphNode graphNode = null; if (m_node is Composite) { Composite composite = m_node as Composite; composite.InsertChild(index, node); graphNode = BTEditorGraphNode.CreateExistingNode(this, node); m_children.Insert(index, graphNode); } else if (m_node is Decorator) { Decorator decorator = m_node as Decorator; DestroyChildren(); decorator.SetChild(node); graphNode = BTEditorGraphNode.CreateExistingNode(this, node); m_children.Add(graphNode); } BTEditorCanvas.Current.RecalculateSize(node.Position); return(graphNode); } return(null); }
public void OnNodeSelect(BTEditorGraphNode node) { if (BTEditorCanvas.Current.Event.shift && (node.Node is Composite || node.Node is Decorator)) { SelectBranch(node); } else if (BTEditorCanvas.Current.Event.control || SelectionBox.HasValue) { if (!m_selection.Contains(node)) { if (node.Node is NodeGroup && !IsRoot(node)) { SelectEntireNodeGroupAdditive(node); } else { SelectSingleAdditive(node); } } } else { if (node.Node is NodeGroup && !IsRoot(node)) { SelectEntireNodeGroup(node); } else { SelectSingle(node); } } }
public UndoNodeMoved(BTEditorGraphNode node) { m_graph = node.Graph; m_nodeHash = m_graph.GetNodeHash(node); m_startPosition = node.Node.Position; m_endPosition = Vector2.zero; }
public UndoNodeCreated(BTEditorGraphNode node) { m_graph = node.Graph; m_createdNodeHash = m_graph.GetNodeHash(node); m_parentNodeHash = null; m_serializedNode = null; Title = "Created " + node.Node.Title; }
public void OnNodeDelete(BTEditorGraphNode node) { if (node != null) { BTUndoSystem.RegisterUndo(new UndoNodeDeleted(node)); node.OnDelete(); } }
public void OnDelete() { if (m_parent != null) { m_parent.RemoveChild(this); BTEditorGraphNode.DestroyImmediate(this); } }
private void OnDestroy() { m_graph.OnNodeDeselect(this); foreach (var child in m_children) { BTEditorGraphNode.DestroyImmediate(child); } }
public void OnDeleteChild(int index) { BTEditorGraphNode child = GetChild(index); if (child != null) { child.OnDelete(); } }
private static BTEditorGraphNode CreateEmptyNode() { BTEditorGraphNode graphNode = ScriptableObject.CreateInstance <BTEditorGraphNode>(); graphNode.OnCreated(); graphNode.hideFlags = HideFlags.HideAndDontSave; return(graphNode); }
public static void AddChild(GenericMenu menu, BTEditorGraphNode targetNode) { GenericMenu.MenuFunction2 onCreateChild = t => targetNode.Graph.OnNodeCreateChild(targetNode, t as Type); foreach (var item in m_nodeMenuPaths) { menu.AddItem(new GUIContent("Add Child/" + item.Item2), false, onCreateChild, item.Item1); } }
private void OnCreated() { m_masterRoot = null; m_rootStack = new Stack <BTEditorGraphNode>(); m_drawSelectionBox = false; m_isBehaviourTreeReadOnly = false; m_selectionBoxStartPos = Vector2.zero; SelectionBox = null; }
public UndoNodeDeleted(BTEditorGraphNode node, int childIndex) { m_graph = node.Graph; m_parentNodeHash = m_graph.GetNodeHash(node.Parent); m_serializedNode = BTUtils.SerializeNode(node.Node); m_childIndex = childIndex; Title = "Deleted " + node.Node.Title; m_createdNodeHash = null; }
public void OnPushNodeGroup(BTEditorGraphNode node) { if (node != null && node.Node is NodeGroup) { BTUndoSystem.RegisterUndo(new UndoNodeGroupPush(node)); m_rootStack.Push(node); SelectSingle(node); } }
private static BTEditorGraphNode CreateExistingNode(BTEditorGraphNode parent, BehaviourNode node) { BTEditorGraphNode graphNode = BTEditorGraphNode.CreateEmptyNode(); graphNode.m_parent = parent; graphNode.m_graph = parent.Graph; graphNode.SetExistingNode(node); return(graphNode); }
private void SelectBranchRecursive(BTEditorGraphNode node) { m_selection.Add(node); node.OnSelected(); for (int i = 0; i < node.ChildCount; i++) { SelectBranchRecursive(node.GetChild(i)); } }
public void OnNodeDrag(BTEditorGraphNode node, Vector2 position) { if (m_selection.Contains(node)) { for (int i = 0; i < m_selection.Count; i++) { m_selection[i].OnDrag(position); } } }
public void OnNodeCreateChild(BTEditorGraphNode parent, Type childType) { if (parent != null && childType != null) { BTEditorGraphNode child = parent.OnCreateChild(childType); if (child != null) { BTUndoSystem.RegisterUndo(new UndoNodeCreated(child)); } } }
private void DeleteBreakpointsRecursive(BTEditorGraphNode node) { if (node != null && node.Node != null) { node.Node.Breakpoint = Breakpoint.None; for (int i = 0; i < node.ChildCount; i++) { DeleteBreakpointsRecursive(node.GetChild(i)); } } }
public UndoNodeGroupPop(BTEditorGraphNode node) { if (!(node.Node is NodeGroup)) { throw new System.ArgumentException("BT graph node is not of type NodeGroup", "node"); } m_graph = node.Graph; m_nodeGroupHash = m_graph.GetNodeHash(node); Title = "Close " + (string.IsNullOrEmpty(node.Node.Name) ? node.Node.Title : node.Node.Name); }
private void OnEnable() { m_graphNode = target as BTEditorGraphNode; if (m_graphNode != null) { m_nodeInspector = BTNodeInspectorFactory.CreateInspectorForNode(m_graphNode); } else { m_nodeInspector = null; } }
public void OnNodeBeginDrag(BTEditorGraphNode node, Vector2 position) { if (m_selection.Contains(node)) { BTUndoSystem.BeginUndoGroup("Moved node(s)"); for (int i = 0; i < m_selection.Count; i++) { BTUndoSystem.RegisterUndo(new UndoNodeMoved(m_selection[i])); m_selection[i].OnBeginDrag(position); } } }
private void MoveNonSelectedChildren(BTEditorGraphNode node, Vector2 delta) { for (int i = 0; i < node.ChildCount; i++) { var child = node.GetChild(i); if (m_selection.IndexOf(child) < 0) { child.NodePositon = child.NodePositon + delta; MoveNonSelectedChildren(child, delta); } } }
public void OnNodeEndDrag(BTEditorGraphNode node) { if (m_selection.Contains(node)) { for (int i = 0; i < m_selection.Count; i++) { m_selection[i].OnEndDrag(); } BTUndoSystem.EndUndoGroup(); } }
public string GetNodeHash(BTEditorGraphNode node) { List <byte> path = new List <byte>(); for (BTEditorGraphNode n = node; n != null && n.Parent != null; n = n.Parent) { path.Add((byte)n.Parent.GetChildIndex(n)); } path.Reverse(); return(Convert.ToBase64String(path.ToArray())); }
public override void Undo() { if (CanUndo) { BTEditorGraphNode createdNode = m_graph.GetNodeByHash(m_createdNodeHash); m_parentNodeHash = m_graph.GetNodeHash(createdNode.Parent); m_serializedNode = BTUtils.SerializeNode(createdNode.Node); createdNode.OnDelete(); m_createdNodeHash = null; } }
public override void Redo() { if (CanRedo) { BTEditorGraphNode parentNode = m_graph.GetNodeByHash(m_parentNodeHash); BehaviourNode node = BTUtils.DeserializeNode(m_serializedNode); BTEditorGraphNode createdNode = parentNode.OnCreateChild(node); m_createdNodeHash = m_graph.GetNodeHash(createdNode); m_parentNodeHash = null; m_serializedNode = null; } }