2026-08-07 02:50:54 -05:00
|
|
|
class_name LobbyData extends Node
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@onready var lobby_ui: Node
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
|
Globals.lobby_data = self
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc("authority", "reliable")
|
|
|
|
|
func connect_to_game() -> void:
|
|
|
|
|
# NOTE: Leave the lobby
|
|
|
|
|
lobby_ui.client.close_connection()
|
|
|
|
|
|
|
|
|
|
Globals.multiplayer_data.wait_for_connection_close()
|
|
|
|
|
|
|
|
|
|
# NOTE: Join target game server
|
2026-08-08 01:22:54 -05:00
|
|
|
# TODO: Don't use libby client... Use a created game client.
|
2026-08-07 02:50:54 -05:00
|
|
|
lobby_ui.client.start_client(
|
|
|
|
|
Globals.game_data.game_address,
|
|
|
|
|
Globals.game_data.game_port
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@rpc("authority", "reliable")
|
|
|
|
|
func go_back_to_match_screen() -> void:
|
|
|
|
|
if multiplayer.is_server(): return
|
|
|
|
|
|
|
|
|
|
push_warning("Client peer disconnected...")
|
|
|
|
|
|
|
|
|
|
Globals.game_state.set_game_scene(
|
|
|
|
|
"res://scenes/screens/lobby_screen/lobby.tscn"
|
|
|
|
|
)
|