mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
remove connection method in deck node, disconnect nodes method in deck
This commit is contained in:
parent
2c4a937a76
commit
c2b04e816b
2 changed files with 22 additions and 0 deletions
|
@ -54,3 +54,8 @@ func connect_nodes(from_node: DeckNode, to_node: DeckNode, from_port: int, to_po
|
|||
|
||||
from_node.add_outgoing_connection(from_port, to_node._id, to_port)
|
||||
return true
|
||||
|
||||
|
||||
func disconnect_nodes(from_node: DeckNode, to_node: DeckNode, from_port: int, to_port: int) -> void:
|
||||
var hash = {to_node._id: to_port}.hash()
|
||||
from_node.remove_outgoing_connection(from_port, hash)
|
||||
|
|
|
@ -39,3 +39,20 @@ func add_outgoing_connection(from_port: int, to_node: String, to_port: int) -> v
|
|||
var port_connections: Array = outgoing_connections.get(from_port, [])
|
||||
port_connections.append({to_node: to_port})
|
||||
outgoing_connections[from_port] = port_connections
|
||||
|
||||
|
||||
func remove_outgoing_connection(from_port: int, connection_hash: int) -> void:
|
||||
var port_connections: Array = (outgoing_connections.get(from_port, []) as Array).duplicate(true)
|
||||
if port_connections.is_empty():
|
||||
return
|
||||
|
||||
var to_remove: int = -1
|
||||
for i in port_connections.size():
|
||||
if port_connections[i].hash() == connection_hash:
|
||||
to_remove = i
|
||||
|
||||
if to_remove == -1:
|
||||
return
|
||||
|
||||
port_connections.remove_at(to_remove)
|
||||
outgoing_connections[from_port] = port_connections
|
||||
|
|
Loading…
Reference in a new issue