public override Node Create(Vector2 pos) { //GUITestNode node = CreateInstance<GUITestNode>(); var sIn = new SocketIn(); sIn.ID = 0; sIn.Create(this, new TypeData(new FloatType()));// Inputs.Add(sIn); sIn = new SocketIn(); sIn.ID = 1; sIn.Create(this, new TypeData(new Vector3Type()));//, new TypeData(new FloatType()) Inputs.Add(sIn); var sOut = new SocketOut(); sOut.ID = 2; sOut.Create(this, new TypeData(new FloatType()));//, new TypeData(new FloatType()) Outputs.Add(sOut); sOut = new SocketOut(); sOut.ID = 3; sOut.Create(this, new TypeData(new Vector3Type()));//, new TypeData(new FloatType()) Outputs.Add(sOut); rect = new Rect(pos.x, pos.y, 155, (Inputs.Count + Outputs.Count) * GUIx.I.socketStyle.fixedHeight + 20 + 24); return this; }
public NodeMonitor(Point location) { Location = location; _inputObject = new SocketIn(typeof(object), "Input", this, false); Name = "Monitor"; NodeType = GetType().ToString().Split('.').Last(); Description = "Monitor node."; BaseColor = Color.FromArgb(CommonStates.NodeColorAlpha, 31, 36, 42); HeaderColor = Color.FromArgb(168, 72, 88); FooterHeight = 50; Sockets.Add(_inputObject); }
// main constructor public MathAvgNode(Point location) { Location = location; _numberHub = new SocketIn(typeof(double), "Numbers", this, true); _result = new SocketOut(typeof(double), "Result", this); Name = "Number Average"; NodeType = GetType().ToString().Split('.').Last(); Description = "This node calculates the average of the numbers on the input."; BaseColor = Color.FromArgb(CommonStates.NodeColorAlpha, 31, 36, 42); HeaderColor = Color.FromArgb(62, 88, 140); _result.UpdateValue(0d); Sockets.Add(_numberHub); Sockets.Add(_result); }
public void Connect(SocketOut from, SocketIn to) { Wire wire = null; try { wire = new Wire(from, to); to.Connect(wire); from.Connect(wire); _connections.Add(wire); wire.Flow(); } catch (Exception e) { wire?.Disconnect(); Console.WriteLine(e); } ValidateConnections(); }
// main constructor public MathSumNode(Point location) { Location = location; _numberA = new SocketIn(typeof(double), "Number A", this, false); _numberB = new SocketIn(typeof(double), "Number B", this, false); _resultOut = new SocketOut(typeof(double), "Result", this); Name = "Sample Node"; NodeType = GetType().ToString().Split('.').Last(); Description = "This node encodes string on input with XOR function."; BaseColor = Color.FromArgb(CommonStates.NodeColorAlpha, 31, 36, 42); HeaderColor = Color.FromArgb(62, 88, 140); _resultOut.UpdateValue(0d); Sockets.Add(_numberA); Sockets.Add(_numberB); Sockets.Add(_resultOut); }
public NodeStringXOR(Point location) { Location = location; _inputString = new SocketIn(typeof(string), "Input string", this, false); _inputKey = new SocketIn(typeof(char), "Input key", this, false); _inputEnabled = new SocketIn(typeof(bool), "Input enabled", this, false); _outputString = new SocketOut(typeof(string), "Output string", this); Name = "String XOR"; NodeType = GetType().ToString().Split('.').Last(); Description = "This node encodes string on input with XOR function."; BaseColor = Color.FromArgb(CommonStates.NodeColorAlpha, 31, 36, 42); HeaderColor = Color.FromArgb(61, 115, 99); _outputString.UpdateValue(DefaultOutputValue); Sockets.Add(_inputString); Sockets.Add(_inputKey); Sockets.Add(_inputEnabled); Sockets.Add(_outputString); }
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 IsDoubleConnection(SocketIn inSocket, SocketOut outSocket) { for (int i = 0; i < inSocket.connections.Count; i++) { if (inSocket.connections[i].startSocket == outSocket) return true; } return false; }
public static bool IsConnectionLoop(SocketIn inSocket, Connection connection) { if (inSocket.parentNode == connection.startSocket.parentNode) return true; else { //var nodes = GetAllOutputConnections(inSocket.parentNode); return RekursivLoopingCheck(inSocket, connection, inSocket.parentNode); } }