public void removeNode(DSNode node) { List <DSConnection> connectionsToRemove = new List <DSConnection> (); if (node.isSelectionNode) { DSSelectionNode selectionNode = (DSSelectionNode)node; for (int i = 0; i < _connections.Count; i++) { if (_connections [i].inPoint == selectionNode.inPoint || _connections [i].outPoint == selectionNode.trueOutPoint || _connections [i].outPoint == selectionNode.falseOutPoint) { connectionsToRemove.Add(_connections [i]); } } } else { for (int i = 0; i < _connections.Count; i++) { if (_connections [i].inPoint == node.inPoint || _connections [i].outPoint == node.outPoint) { connectionsToRemove.Add(_connections [i]); } } } if (connectionsToRemove != null && connectionsToRemove.Count > 0) { for (int i = 0; i < connectionsToRemove.Count; i++) { removeConnection(connectionsToRemove [i]); } } _nodes.Remove(node); }
public void simulate() { DSNode currentNode = _nodes.Find(x => x.title.Equals("Start")); while (currentNode != null) { currentNode.execute(); DSConnection next = null; if (currentNode.isSelectionNode) { DSSelectionNode currentSelectionNode = (DSSelectionNode)currentNode; if (currentSelectionNode.result && currentSelectionNode.trueOutPoint != null) { next = _connections.Find(x => x.outPoint == currentSelectionNode.trueOutPoint); } else if (!currentSelectionNode.result && currentSelectionNode.falseOutPoint != null) { next = _connections.Find(x => x.outPoint == currentSelectionNode.falseOutPoint); } else { break; } } else { if (currentNode.outPoint == null) { break; } next = _connections.Find(x => x.outPoint == currentNode.outPoint); } if (next == null) { break; } currentNode = _nodes.Find(x => x.id == next.inPoint.nodeID); } }