public void Link(CConnection c) { if (pointer == null && c.pointer == null) { pointer = c; pointer.pointer = this; } }
public void Draw() { if (to == null && from == null) { Debug.Log("ERROR EMPTY LINK"); return; } // Just draw a line if one of the connections are not set if ((to != null && from == null) || (to == null && from != null)) { CConnection n = from; if (n == null) { n = to; } Color col = LStyle.connectionColors [from.Type]; Handles.DrawBezier(n.position, TangyTexturesEditor.mousePos, n.position, TangyTexturesEditor.mousePos, col, null, 3f); CNodeManager.ForceRepaint = true; } if (to != null && from != null) { float t = 0.5f; Color col = LStyle.connectionColors [from.Type]; center.x = t * (from.position.x) + (1 - t) * (to.position.x); center.y = t * (from.position.y) + (1 - t) * (to.position.y); t = 0.2f; centerA.x = t * (center.x) + (1 - t) * (to.position.x); centerA.y = t * (center.y) + (1 - t) * (from.position.y); t = 0.2f; centerB.x = t * (center.x) + (1 - t) * (from.position.x); centerB.y = t * (center.y) + (1 - t) * (to.position.y); if (drawType == 1) { centerA.x = t * (center.x) + (1 - t) * (from.position.x); centerA.y = t * (center.y) + (1 - t) * (to.position.y); centerB.x = t * (center.x) + (1 - t) * (to.position.x); centerB.y = t * (center.y) + (1 - t) * (from.position.y); } Handles.DrawBezier(from.position, to.position, centerA, centerB, col, null, width); } }
public void Break() { if (pointer != null) { pointer.pointer = null; } pointer = null; }
private void mouseClick() { if (Event.current.type == EventType.mouseUp && Event.current.modifiers != EventModifiers.Shift) { { link = null; if (connection != null) { connection.Break(); connection = null; } } } }
// get a link node protected CNode getNode(ArrayList l, int i) { CConnection c = ((CConnection)l [i]); if (c == null) { return(null); } if (c.pointer == null) { return(null); } return(c.pointer.parent); }
private static void createLinks(ArrayList sn, ArrayList nodes, int Add) { //verifyConnectionID(sn, Add); foreach (CSerializedNode s in sn) { for (int i = 0; i < s.Outputs.Count; i++) { int I = (int)s.Inputs [i] + Add * 100; int O = (int)s.Outputs [i] + Add * 100; CConnection a = findConnection(I, nodes); CConnection b = findConnection(O, nodes); if (a == null || b == null) { // you know. Just in case. Debug.Log("ERROR NODE NOT FOUND BY LOADING; SHOULD NEVER HAPPEN!"); return; } if (a != b) { a.Link(b); } } } }
public bool verifyConnection(CConnection b) { if (parent == b.parent) { //Debug.Log("Aborted: same parent"); return(false); } if (parent.Inputs.Contains(this) && b.parent.Inputs.Contains(b)) { //Debug.Log("Aborted: both are inputs"); return(false); } if (parent.Outputs.Contains(this) && b.parent.Outputs.Contains(b)) { //Debug.Log("Aborted: both are outputs"); return(false); } if (parent.Tops.Contains(this) && b.parent.Tops.Contains(b)) { //Debug.Log("Aborted: both are tops"); return(false); } if (parent.Bottoms.Contains(this) && b.parent.Bottoms.Contains(b)) { //Debug.Log("Aborted: both are bottoms"); return(false); } if (Type != b.Type) { //Debug.Log("Aborted: Incorrect type"); return(false); } return(true); }
public CConnection Click(CConnection c) { // First, what if completely blank: Create new link if (c == null && pointer == null) { c = this; CLink l = new CLink(); l.from = c; l.to = null; //Debug.Log ("Created new link from empty"); CNodeManager.link = l; //PropagateChange(); return(c); } // Attatch existing string to connection if (c != null && pointer == null) { // is this valid? if (!verifyConnection(c)) { return(c); } Link(c); // PropagateChange(); //Debug.Log ("Attatched link to empty"); CNodeManager.link = null; return(null); } // if clicked on existing link if (c == null && pointer != null) { c = pointer; CLink l = new CLink(); l.from = c; l.to = null; //Debug.Log ("Created new link from existing"); CNodeManager.link = l; //PropagateChange(); Break(); return(c); } // SWAP! if (c != null && pointer != null) { if (!verifyConnection(c)) { return(c); } // Basically: Swap connections CConnection old = pointer; old.Break(); //Break(); Link(c); CLink l = new CLink(); l.from = old; l.to = null; CNodeManager.link = l; // PropagateChange(); return(old); } CNodeManager.link = null; return(null); }