1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-02-06 23:34:54 +08:00

Refined NodePort.Disconnect

This commit is contained in:
Thor Brigsted 2017-12-26 00:56:02 +01:00
parent 11a9db199a
commit 0fa9695dc4

View File

@ -206,22 +206,21 @@ namespace XNode {
/// <summary> Disconnect this port from another port </summary>
public void Disconnect(NodePort port) {
NodePort from = direction == IO.Input ? port : this;
NodePort to = direction == IO.Input ? this : port;
// Remove this ports connection to the other
for (int i = connections.Count - 1; i >= 0; i--) {
if (connections[i].Port == port) {
connections.RemoveAt(i);
node.OnRemoveConnection(this);
}
}
// Remove the other ports connection to this port
for (int i = 0; i < port.connections.Count; i++) {
if (port.connections[i].Port == this) {
port.connections.RemoveAt(i);
port.node.OnRemoveConnection(port);
}
}
// Trigger OnRemoveConnection
node.OnRemoveConnection(this);
port.node.OnRemoveConnection(port);
}
public void ClearConnections() {