diff --git a/classes/deck/deck.gd b/classes/deck/deck.gd index 703b718..94b9e02 100644 --- a/classes/deck/deck.gd +++ b/classes/deck/deck.gd @@ -307,12 +307,30 @@ func copy_nodes(nodes_to_copy: Array[String]) -> Dictionary: if !(to_node in nodes_to_copy): (d.nodes[node].outgoing_connections[from_port] as Dictionary).erase(to_node) + var outgoing_is_empty: bool = true + for from_port: int in d.nodes[node].outgoing_connections: + if !(d.nodes[node].outgoing_connections[from_port] as Dictionary).is_empty(): + outgoing_is_empty = false + break + + if outgoing_is_empty: + d.nodes[node].outgoing_connections = {} + var incoming_connections: Dictionary = d.nodes[node].incoming_connections.duplicate(true) for to_port: int in incoming_connections: for from_node: String in incoming_connections[to_port]: if !(from_node in nodes_to_copy): (d.nodes[node].incoming_connections[to_port] as Dictionary).erase(from_node) + + var incoming_is_empty: bool = true + for to_port: int in d.nodes[node].incoming_connections: + if !(d.nodes[node].incoming_connections[to_port] as Dictionary).is_empty(): + incoming_is_empty = false + break + + if incoming_is_empty: + d.nodes[node].incoming_connections = {} for node: Dictionary in d.nodes.values().slice(1): node.position.x = node.position.x - d.nodes.values()[0].position.x