51 lines
1.3 KiB
GDScript3
51 lines
1.3 KiB
GDScript3
|
|
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
|
||
|
|
lobby_ui.client.start_client(
|
||
|
|
Globals.game_data.game_address,
|
||
|
|
Globals.game_data.game_port
|
||
|
|
)
|
||
|
|
|
||
|
|
@rpc("authority", "call_local", "reliable")
|
||
|
|
func load_game_scene(match_entry: Dictionary, is_player_1: bool) -> void:
|
||
|
|
push_warning("Client load game scene...")
|
||
|
|
lobby_ui.rpc_signals.match_list_entry_load_match.emit(match_entry, is_player_1)
|
||
|
|
|
||
|
|
@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"
|
||
|
|
)
|
||
|
|
|
||
|
|
# NOTE: Needed for hash check to pass between client and server but isn't used by client...
|
||
|
|
@rpc("any_peer", "reliable")
|
||
|
|
func match_list_add_entry(_match_entry: Dictionary) -> void:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@rpc("any_peer", "reliable")
|
||
|
|
func match_list_remove_entry(_match_id: String) -> void:
|
||
|
|
pass
|
||
|
|
|
||
|
|
@rpc("any_peer", "reliable")
|
||
|
|
func match_list_join_entry(_match_id: String) -> void:
|
||
|
|
pass
|