public Socket(Node parent, Color type, SocketDirection direciton)
 {
     Parent = parent;
     Type = type;
     _boxRect.width = BonConfig.SocketSize;
     _boxRect.height = BonConfig.SocketSize;
     Direction = direciton;
 }
 public void AddNode(Node node)
 {
     _nodes.Add(node);
     if (_listener != null && TriggerEvents)
     {
         node.RegisterListener(_listener);
         _listener.OnNodeAdded(node);
     }
 }
 public void OnNodeRemoved(Node node)
 {
     //Debug.Log("OnNodeRemoved: Node " + node.GetType() + " with id " + node.Id);
     UpdateNodes();
 }
 public static List<Node> CreateUpperNodesList(Node node)
 {
     List<Node> upperNodes = new List<Node>();
     AddUpperNodes(node, ref upperNodes);
     return upperNodes;
 }
 private bool HasCicle(Node node)
 {
     if (node.VisitFlag) return true;
     node.VisitFlag = true;
     foreach (Socket s in node.Sockets)
     {
         if (s.Direction == SocketDirection.Output && s.Edge != null)
         {
             return HasCicle(s.Edge.Input.Parent);
         }
     }
     return false;
 }
 private static void AddUpperNodes(Node node, ref List<Node> upperNodesList)
 {
     foreach (Socket s in node.Sockets)
     {
         if (s.Direction == SocketDirection.Input && s.Edge != null)
         {
             Socket connected = s.GetConnectedSocket();
             upperNodesList.Add(connected.Parent);
             AddUpperNodes(connected.Parent, ref upperNodesList);
         }
     }
 }
        public void RemoveNode(Node node)
        {
            if (node == null) return;

            foreach (var socket in node.Sockets)
            {
                if (socket.Edge != null)
                {
                    UnLink(socket);
                }
            }

            _nodes.Remove(node);
            if (_listener != null && TriggerEvents)
            {
                _listener.OnNodeRemoved(node);
            }
            node.RegisterListener(null);
        }