public static Node[] GetAllParentNodes(Node node) { List<Node> parentNodes = new List<Node>(); var cons = GetAllInputConnections(node); if (cons.Length == 0) return null; for (int i = 0; i < cons.Length; i++) { parentNodes.Add(cons[i].startSocket.parentNode); } return parentNodes.ToArray(); }
public static Connection[] GetAllOutputConnections(Node node) { List<Connection> connections = new List<Connection>(); if (node.Outputs.Count > 0) { for (int i = 0; i < node.Outputs.Count; i++) { if (node.Outputs[i].connections.Count > 0) { for (int x = 0; x < node.Outputs[i].connections.Count; x++) { connections.Add(node.Outputs[i].connections[x]); } } } } return connections.ToArray(); }
public static Node[] GetConnectedNodes(Node node) { List<Node> nodes = new List<Node>(); var connections = GetAllOutputConnections(node); if(connections != null && connections.Length > 0) for (int i = 0; i < connections.Length; i++) { nodes.Add(connections[i].endSocket.parentNode); } return nodes.ToArray(); }
private static bool RekursivLoopingCheck(SocketIn inSocket, Connection connection, Node node) { var connections = GetAllOutputConnections(node); if (connections == null || connections.Length == 0) return false; bool isLooping = false; for (int i = 0; i < connections.Length; i++) { if (connections[i].endSocket.parentNode == connection.startSocket.parentNode) { isLooping = true; break; } else isLooping = RekursivLoopingCheck(inSocket, connection, connections[i].endSocket.parentNode); } return isLooping; }
public static bool IsSelectedNode(Node node) { if (node == selectedNode) return true; else return false; }
public static bool IsHoveredNode(Node node) { if (node == hoveredNode) return true; else return false; }
public Socket GetSocketFromMousePos(Node node, Vector2 mousePos) { for (int i = 0; i < node.Inputs.Count; i++) { var absoluteRect = GUIRectToScreenRect(node.Inputs[i].rect, node.rect); if (absoluteRect.Contains(mousePos)) return node.Inputs[i]; } for (int i = 0; i < node.Outputs.Count; i++) { var absoluteRect = GUIRectToScreenRect(node.Outputs[i].rect, node.rect); if (absoluteRect.Contains(mousePos)) return node.Outputs[i]; } return null; }