2026-08-09 18:41:18 -05:00
|
|
|
class_name GameServer extends ServerNetworking
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
setup_signals()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func setup_signals() -> void:
|
|
|
|
|
pass
|
2026-08-10 00:40:45 -05:00
|
|
|
|
|
|
|
|
func server_client_connected(id: int) -> void:
|
|
|
|
|
push_warning("Client Connected... ID: ", id)
|
|
|
|
|
|
|
|
|
|
if not Globals.game_data.client1:
|
|
|
|
|
Globals.game_data.client1 = id
|
|
|
|
|
elif not Globals.game_data.client2:
|
|
|
|
|
Globals.game_data.client2 = id
|
|
|
|
|
|
|
|
|
|
if Globals.game_data.client1 and Globals.game_data.client2:
|
|
|
|
|
Globals.multiplayer_data.init_match()
|
|
|
|
|
|
|
|
|
|
# TODO: Add watch match feature...
|
|
|
|
|
|
|
|
|
|
func server_client_disconnected(id: int) -> void:
|
|
|
|
|
push_warning("Client Disconnected... ID: ", id)
|
|
|
|
|
|
|
|
|
|
MessageBus.emit_propagation_clients_only.rpc("game_peer_disconnected", null)
|
|
|
|
|
|
|
|
|
|
await get_tree().create_timer(5.0).timeout
|
|
|
|
|
# NOTE: Quits game server instance.
|
|
|
|
|
get_tree().quit()
|