miggor-StreamGraph/rpc_renderer/rpc_signal_layer.gd

46 lines
1.3 KiB
GDScript3
Raw Normal View History

# (c) 2023-present Eroax
# (c) 2023-present Yagich
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
class_name RPCSignalLayer
static var signals := Signals.new()
static func _static_init() -> void:
DeckHolder.signals.deck_added.connect(RPCSignalLayer._on_deck_added)
DeckHolder.signals.deck_closed.connect(
func(deck_id: String):
signals.deck_closed.emit(deck_id)
)
static func _on_deck_added(deck_id: String) -> void:
signals.deck_added.emit(deck_id)
DeckHolder.get_deck(deck_id).node_added.connect(RPCSignalLayer._on_deck_node_added)
static func _on_deck_node_added(node: DeckNode) -> void:
signals.deck_node_added.emit(node._belonging_to.id, node._id)
node.position_updated.connect(RPCSignalLayer._on_node_position_updated.bind(node._belonging_to.id, node._id))
static func _on_node_position_updated(new_position: Dictionary, node_id: String, deck_id: String) -> void:
signals.node_position_updated.emit(deck_id, node_id, new_position)
class Signals:
#region deck holder
signal deck_added(deck_id: String)
signal deck_closed(deck_id: String)
#endregion
#region deck
signal deck_node_added(deck_id: String, node_id: String)
#endregion
#region node
signal node_position_updated(deck_id: String, node_id: String, new_position: Dictionary)
#endregion