refactor: decouple game networking from lobby client

* Replace direct client/server networking references with GameClient/GameServer scenes
* Refactor message bus to support local emission and argument expansion
* Move lobby connection lifecycle handling to message bus events
* Remove multiplayer connection wait helpers and direct lobby client coupling
* Rename Server to ServerNetworking and update lobby client references
* Update scene resources and export configuration
This commit is contained in:
2026-08-09 18:41:18 -05:00
parent 50439bc8e0
commit 93a2be399c
20 changed files with 174 additions and 77 deletions

View File

@@ -1,9 +1,6 @@
class_name LobbyData extends Node
@onready var lobby_ui: Node
func _init() -> void:
Globals.lobby_data = self
@@ -11,15 +8,16 @@ func _init() -> void:
@rpc("authority", "reliable")
func connect_to_game() -> void:
# NOTE: Leave the lobby
lobby_ui.client.close_connection()
Globals.multiplayer_data.wait_for_connection_close()
MessageBus.emit_local("lobby_close_connection", null)
# NOTE: Join target game server
# TODO: Don't use libby client... Use a created game client.
lobby_ui.client.start_client(
Globals.game_data.game_address,
Globals.game_data.game_port
MessageBus.emit_local(
"game_start_client",
[
Globals.game_data.game_address,
Globals.game_data.game_port
],
true
)
@rpc("authority", "reliable")

View File

@@ -44,17 +44,6 @@ func init_match():
true
)
func wait_for_connection() -> void:
while not Globals.lobby_data.lobby_ui.client.peer:
await get_tree().process_frame
while Globals.lobby_data.lobby_ui.client.peer.get_connection_status() != 2:
await get_tree().process_frame
func wait_for_connection_close() -> void:
while Globals.lobby_data.lobby_ui.client.peer:
await get_tree().process_frame
func set_multiplayer_inactive() -> void:
is_multiplayer_active = false