Moving some of lobby to use MessageBus

This commit is contained in:
2026-08-08 01:20:58 -05:00
parent de0da3de6e
commit 5ab970aec5
6 changed files with 109 additions and 66 deletions

View File

@@ -13,26 +13,56 @@ func _exit_tree() -> void:
server.close_connection()
func setup_signals() -> void:
rpc_signals.server_host_started.connect(_server_host_started)
rpc_signals.match_list_entry_added.connect(_on_match_list_entry_added)
rpc_signals.match_list_entry_removed.connect(_on_match_list_entry_removed)
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:
push_warning("Client: Added Match List Entry... ", match_entry)
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:
push_warning("Client: Removed Match List Entry... ", match_id)
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)