2023-11-22 05:26:11 +01:00
|
|
|
extends DeckNode
|
|
|
|
|
|
|
|
var input_count: int:
|
|
|
|
get:
|
|
|
|
return get_all_ports().size() - 1
|
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
name = "Group output"
|
|
|
|
node_type = "group_output"
|
|
|
|
props_to_serialize = [&"input_count"]
|
2023-11-23 07:38:10 +01:00
|
|
|
appears_in_search = false
|
2023-11-22 05:26:11 +01:00
|
|
|
|
|
|
|
add_input_port(
|
2023-11-26 23:07:15 +01:00
|
|
|
DeckType.Types.ANY,
|
2023-11-22 05:26:11 +01:00
|
|
|
"Output 0"
|
|
|
|
)
|
|
|
|
|
|
|
|
incoming_connection_added.connect(_on_incoming_connection_added)
|
|
|
|
incoming_connection_removed.connect(_on_incoming_connection_removed)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_incoming_connection_added(port_idx: int) -> void:
|
|
|
|
if port_idx + 1 < get_all_ports().size():
|
|
|
|
return
|
|
|
|
|
|
|
|
add_input_port(
|
2023-11-26 23:07:15 +01:00
|
|
|
DeckType.Types.ANY,
|
2023-11-22 05:26:11 +01:00
|
|
|
"Output %s" % (get_all_ports().size())
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_incoming_connection_removed(port_idx: int) -> void:
|
|
|
|
var last_connected_port := 0
|
|
|
|
for port: int in incoming_connections.keys().slice(1):
|
|
|
|
if !(incoming_connections[port] as Dictionary).is_empty():
|
|
|
|
last_connected_port = port
|
|
|
|
|
|
|
|
prints("l:", last_connected_port, "p:", port_idx)
|
|
|
|
|
|
|
|
if port_idx < last_connected_port:
|
|
|
|
return
|
|
|
|
|
|
|
|
var s := get_all_ports().slice(0, last_connected_port + 2)
|
|
|
|
ports.assign(s)
|
|
|
|
ports_updated.emit()
|
|
|
|
|
|
|
|
|
|
|
|
func _pre_connection() -> void:
|
|
|
|
for i in input_count + 1:
|
|
|
|
add_input_port(
|
2023-11-26 23:07:15 +01:00
|
|
|
DeckType.Types.ANY,
|
2023-11-22 05:26:11 +01:00
|
|
|
"Output %s" % (i + 1)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func _post_load() -> void:
|
|
|
|
# ensure we have enough ports after connections
|
|
|
|
var last_connected_port := 0
|
|
|
|
for port: int in incoming_connections:
|
|
|
|
last_connected_port = port if incoming_connections.has(port) else last_connected_port
|
|
|
|
|
|
|
|
if ports.size() <= last_connected_port:
|
|
|
|
for i in last_connected_port:
|
|
|
|
add_input_port(
|
2023-11-26 23:07:15 +01:00
|
|
|
DeckType.Types.ANY,
|
2023-11-22 05:26:11 +01:00
|
|
|
"Output %s" % get_input_ports().size()
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-11-26 23:07:15 +01:00
|
|
|
func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void:
|
2023-11-22 05:26:11 +01:00
|
|
|
var group_node := _belonging_to._belonging_to.get_node(_belonging_to.group_node)
|
|
|
|
group_node.send(group_node.get_output_ports()[to_input_port].index_of_type, data, extra_data)
|