1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 17:26:02 +08:00

Register ConnectionType changes and update existing static NodePorts

This commit is contained in:
Thor Brigsted 2018-01-21 22:45:20 +01:00
parent aa54950611
commit 55fb7586d8

View File

@ -23,12 +23,17 @@ namespace XNode {
} }
// Cleanup port dict - Remove nonexisting static ports - update static port types // Cleanup port dict - Remove nonexisting static ports - update static port types
// Loop through current node ports
foreach (NodePort port in ports.Values.ToList()) { foreach (NodePort port in ports.Values.ToList()) {
// If port still exists, check it it has been changed
if (staticPorts.ContainsKey(port.fieldName)) { if (staticPorts.ContainsKey(port.fieldName)) {
NodePort staticPort = staticPorts[port.fieldName]; NodePort staticPort = staticPorts[port.fieldName];
if (port.IsDynamic || port.direction != staticPort.direction) ports.Remove(port.fieldName); // If port exists but with wrong settings, remove it. Re-add it later.
if (port.connectionType != staticPort.connectionType || port.IsDynamic || port.direction != staticPort.direction) ports.Remove(port.fieldName);
else port.ValueType = staticPort.ValueType; else port.ValueType = staticPort.ValueType;
} else if (port.IsStatic) ports.Remove(port.fieldName); }
// If port doesn't exist anymore, remove it
else if (port.IsStatic) ports.Remove(port.fieldName);
} }
// Add missing ports // Add missing ports
foreach (NodePort staticPort in staticPorts.Values) { foreach (NodePort staticPort in staticPorts.Values) {