Files
Billiards/scenes/data_bridge/lobby_data.gd

34 lines
768 B
GDScript

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
# 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
)
@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"
)