# (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) extends RPCScope func _init() -> void: name = "deck" operation_types = { "add_node": add_node, } RPCSignalLayer.signals.deck_node_added.connect(_on_deck_node_added) func add_node(r: RPCRequest) -> void: reconnect( RPCSignalLayer.signals.deck_node_added, _on_deck_node_added, func(): var deck := DeckHolder.get_deck(r.operation.condition.deck_id) var node := deck.add_node_type(r.operation.payload.node_type) var node_partial := RPCNodePartial.new() node_partial.deck_id = deck.id node_partial.id = node._id var resp := create_response(r, node_partial) resp.create_event_counterpart(node_partial) response.emit(resp) ) func _on_deck_node_added(deck_id: String, node_id: String) -> void: event.emit(create_event("node_added", {"node_id": node_id}, {"deck_id": deck_id}))