Ejemplo n.º 1
0
 public void OnNodeDelete(BTEditorGraphNode node)
 {
     if (node != null)
     {
         BTUndoSystem.RegisterUndo(new UndoNodeDeleted(node));
         node.OnDelete();
     }
 }
Ejemplo n.º 2
0
        public void OnDeleteChild(int index)
        {
            BTEditorGraphNode child = GetChild(index);

            if (child != null)
            {
                child.OnDelete();
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        public void OnNodeSwitchType(BTEditorGraphNode target, Type newType)
        {
            if (target == null || newType == null)
            {
                return;
            }

            BTEditorGraphNode parentNode  = target.Parent;
            Vector2           oldPosition = target.NodePosition;
            int oldIndex = target.Parent.GetChildIndex(target);

            BehaviourNode node = BTUtils.CreateNode(newType);

            if (node != null)
            {
                node.Constraints.AddRange(target.Node.Constraints);

                if (node is Decorator)
                {
                    Decorator original  = target.Node as Decorator;
                    Decorator decorator = node as Decorator;

                    decorator.SetChild(original.GetChild());
                }
                else if (node is Composite)
                {
                    Composite original  = target.Node as Composite;
                    Composite composite = node as Composite;

                    for (int i = 0; i < original.ChildCount; i++)
                    {
                        composite.AddChild(original.GetChild(i));
                    }
                }

                BTUndoSystem.BeginUndoGroup("Changed node type");
                BTUndoSystem.RegisterUndo(new UndoNodeDeleted(target));
                target.OnDelete();

                BTEditorGraphNode newNode = parentNode.OnInsertChild(oldIndex, node);
                if (newNode != null)
                {
                    newNode.NodePosition = oldPosition;
                    BTUndoSystem.RegisterUndo(new UndoNodeCreated(newNode));
                }

                BTUndoSystem.EndUndoGroup();
            }
        }