Пример #1
0
 //---------------------------------------------------------------------------------------------------------------
 public EditorConnection(EditorNode a, EditorNode b, connectDir dir=connectDir.both, bool force=false)
 {
     this.nodeA = a;
     this.nodeB = b;
     this.dir = dir;
     this.forceConnection = force;
 }
Пример #2
0
 void ToggleSupressConnection(EditorNode a, EditorNode b)
 {
     EditorConnection c = edges.Find(x=> x.containsNodes(a, b));
     if(c != null)
     {
         c.supressConnection = !c.supressConnection;
     }
 }
Пример #3
0
 void SetNodeOnHover(EditorNode node)
 {
     if(node != nodeOnHover)
     {
         nodeOnHover = node;
     }
 }
Пример #4
0
    void onMouseUp(Event e)
    {
        if(e.button == 0)
        {
            if(e.control && nodeOnHover != null)
            {
                if(nodeOnHandle != null)
                {
                    CreateConnection(nodeOnHover, nodeOnHandle, connectDir.both, true);
                }
            }
            else if(e.shift)
            {
                EditorNode toDelete = nodeOnHover;
                SetNodeOnHover(null);
                stateChanger.Add(()=> {
                    if(toDelete != null)
                    {
                        DeleteNodeConnections(toDelete.ID);
                        DeleteNode(toDelete);
                    }
                });

            }
            else if(nodeOnHandle != null)
            {
                stateChanger.Add(()=> {
                    AutoConnect(nodeOnHandle);
                });
            }
        }

        connectMode = false;
        nodeOnHandle = null;
    }
Пример #5
0
    void onMouseDown(Event e)
    {
        if(e.button == 0)
        {
            if(e.shift)
            {
                if(connectionOnHover != null)
                {
                    connectionOnHover.NextMode();
                    isDirty = true;
                }
            }
            else if(e.control)
            {
                connectMode = true;
            }
            else if(nodeOnHover == null)
            {
                connectionOnHover = null;
                stateChanger.Add(()=> {
                    nodeOnHover = CreateNode(currGroundP);
                });
                e.Use();
            }
        }

        if(nodeOnHover != null)
        {
            nodeOnHandle = nodeOnHover;
        }
    }
Пример #6
0
 void DeleteNode(EditorNode node)
 {
     if(node != null)
     {
         node.DestroyObj();
         nodes.Remove(node);
         isDirty = true;
     }
 }
Пример #7
0
 void DeleteConnection(EditorNode a, EditorNode b)
 {
     EditorConnection c = edges.Find(x=> x.containsNodes(a, b));
     if(c != null)
     {
         edges.Remove(c);
         isDirty = true;
     }
 }
Пример #8
0
 EditorNode CreateNode(Vector3 p, bool autoconnect=true)
 {
     if(p != NULLPOS)
     {
         EditorNode node = new EditorNode(getFreeNodeID(), p);
         nodes.Add(node);
         if(autoconnect)
             AutoConnect(node);
         isDirty = true;
         return node;
     }
     return null;
 }
Пример #9
0
 EditorConnection CreateConnection(EditorNode a, EditorNode b, graphConnection gc)
 {
     EditorConnection c = CreateConnection(a, b, gc.dir, gc.forced);
     if(c != null)
         c.supressConnection = gc.supressed;
     return c;
 }
Пример #10
0
    EditorConnection CreateConnection(EditorNode a, EditorNode b, connectDir dir, bool forced)
    {
        if(a != b && a != null && b != null)
        {
            if(areConnected(a, b))
            {
                EditorConnection c = edges.Find(x=> x.containsNodes(a, b));

                if(!c.forceConnection)
                {
                    c.supressConnection = c.magnitude <= data.autoConnectionDist;
                }
                else
                    c.supressConnection = !c.supressConnection;
                c.forceConnection = true;
                isDirty = true;
                return c;
            }
            else
            {
                EditorConnection c = new EditorConnection(a, b, dir, forced);
                c.supressConnection = false;
                edges.Add(c);
                isDirty = true;
                return c;
            }
        }
        return null;
    }
Пример #11
0
 //---------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// autoconnect a newly placed node to all nodes around it
 /// </summary>
 void AutoConnect(EditorNode node)
 {
     if(node != null)
     {
         foreach(EditorNode n in nodes)
         {
             if(n != node && n != null && !areConnected(n, node))
             {
                 float mag = Vector3.Distance(n.position, node.position);
                 if(mag <= data.autoConnectionDist)
                 {
                     CreateConnection(n, node, connectDir.both, false);
                 }
             }
         }
     }
 }
Пример #12
0
 bool areConnected(EditorNode nodeA, EditorNode nodeB)
 {
     return edges.Exists( x=> x.containsNodes(nodeA, nodeB) );
 }
Пример #13
0
 public bool containsNode(EditorNode node)
 {
     return node != null && (nodeA == node || nodeB == node);
 }
Пример #14
0
 public bool containsNodes(EditorNode a, EditorNode b)
 {
     return a != null && b != null && ((nodeA == a && nodeB == b) || (nodeA == b && nodeB == a));
 }