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:
24
billiards.gd
24
billiards.gd
@@ -1,8 +1,8 @@
|
||||
class_name Billiards extends Node
|
||||
|
||||
|
||||
@onready var server_net: Node = $server_net
|
||||
@onready var client_net: ClientNetworking = $client_net
|
||||
@onready var game_server: GameServer = $game_server
|
||||
@onready var game_client: GameClient = $game_client
|
||||
|
||||
|
||||
#
|
||||
@@ -76,18 +76,17 @@ func _set_game_mode(mode: String) -> void:
|
||||
Globals.game_data.GameModeType.SNOOKER
|
||||
|
||||
|
||||
|
||||
|
||||
func server_(arg: String) -> void:
|
||||
var server_port = arg.split("_")[1]
|
||||
|
||||
server_net.start_server("0.0.0.0", int(server_port))
|
||||
game_server.start_server("0.0.0.0", int(server_port))
|
||||
|
||||
func host_(arg: String) -> void:
|
||||
var game_mode = arg.split("_")[1]
|
||||
var match_name = OS.get_cmdline_user_args()[-1]
|
||||
|
||||
Globals.multiplayer_data.wait_for_connection()
|
||||
while not $scene/lobby_screen.client.lobby_fully_connected:
|
||||
await get_tree().process_frame
|
||||
|
||||
$scene/lobby_screen.find_child(game_mode, true, false).emit_signal("pressed")
|
||||
$scene/lobby_screen.find_child("new_match_name_input", true, false).text = match_name
|
||||
@@ -99,13 +98,14 @@ func join_server(_arg: String) -> void:
|
||||
|
||||
Globals.multiplayer_data.set_multiplayer_active()
|
||||
|
||||
# TODO: Need to check if true still...
|
||||
# NOTE: Need to load lobby in order for signals to get bound
|
||||
# which then game server calls on its load to do handoff
|
||||
# which then game server calls on its load to do handoff
|
||||
Globals.game_state.set_game_scene(
|
||||
"res://scenes/screens/lobby_screen/lobby.tscn"
|
||||
)
|
||||
|
||||
client_net.start_client(server_address, int(server_port))
|
||||
game_client.start_client(server_address, int(server_port))
|
||||
|
||||
func client(_arg: String) -> void:
|
||||
Globals.game_state.set_game_scene(
|
||||
@@ -118,17 +118,13 @@ func game(_arg: String) -> void:
|
||||
var game_mode = OS.get_cmdline_user_args()[-1]
|
||||
|
||||
_set_game_mode(game_mode)
|
||||
Globals.multiplayer_data.set_multiplayer_active()
|
||||
|
||||
Globals.game_state.set_game_scene(
|
||||
"res://scenes/game.tscn"
|
||||
)
|
||||
Globals.multiplayer_data.set_multiplayer_active()
|
||||
Globals.game_state.set_game_scene( "res://scenes/game.tscn" )
|
||||
|
||||
func join(_arg: String) -> void:
|
||||
var _match_id = OS.get_cmdline_user_args()[-1]
|
||||
|
||||
Globals.multiplayer_data.wait_for_connection()
|
||||
|
||||
var button = $scene/lobby_screen.find_child("join_bttn", true, false)
|
||||
while not button:
|
||||
await get_tree().process_frame
|
||||
|
||||
Reference in New Issue
Block a user