class_name Lobby extends LobbyBase @onready var rpc_signals: Node = $rpc_signals func _ready() -> void: Globals.lobby_data.lobby_ui = self setup_signals() func _exit_tree() -> void: if server.peer: server.close_connection() func setup_signals() -> void: MessageBus.subscribe("match_list_add_entry", _on_match_list_entry_added) MessageBus.subscribe("match_list_remove_entry", _on_match_list_entry_removed) MessageBus.subscribe("match_list_join_entry", _on_match_list_join_entry) func _server_host_started() -> void: host_start_bttn.visible = false host_stop_bttn.visible = true func _on_match_list_entry_added(match_entry: Dictionary) -> void: Globals.lobby_data.match_list_add_entry(match_entry) if not match_entry.has("match_id"): return push_warning("Client Added Match List Entry... ", match_entry) _create_match_entry(match_entry) MessageBus.emit_propagation_clients_only.rpc( "match_list_add_entry", match_entry ) MessageBus.emit_propagation_clients_only.rpc_id( multiplayer.get_remote_sender_id(), "match_list_activate_entry", match_entry.match_id ) func _on_match_list_entry_removed(match_id: String) -> void: Globals.lobby_data.match_list_remove_entry(match_id) if Globals.lobby_data.match_pool.has(match_id): return push_warning("Removed Match List Entry... ", match_id) MessageBus.emit_propagation_clients_only.rpc( "match_list_remove_entry", match_id ) for match_entry in match_list.get_children(): if not match_id == match_entry.match_id: continue match_entry.queue_free() func _on_match_list_join_entry(match_id: String) -> void: Globals.lobby_data.match_list_join_entry(match_id) push_warning("Client Joining Match List Entry... ", match_id) if Globals.lobby_data.match_pool.has(match_id): return _on_match_list_entry_removed(match_id) func _create_match_entry(match_entry: Dictionary) -> void: var container = MATCH_ENTRY.instantiate() match_list.add_child(container) container.name_lbl.text = match_entry.name container.type_lbl.text = match_entry.type container.match_id = match_entry.match_id