refactor: reorganize networking and data bridge scenes

* Move networking scenes under `controllers/networking`
* Move data bridge scene under `scenes/data`
* Rename the bridge node to `data_bridge`
* Update lobby UI scene path
* Remove unused lobby RPC node/script
This commit is contained in:
2026-08-12 16:52:16 -05:00
parent 84b3600044
commit 09369d3dd4
21 changed files with 14 additions and 21 deletions

View File

@@ -0,0 +1,42 @@
class_name GameClient extends ClientNetworking
func _ready() -> void:
setup_signals()
func setup_signals() -> void:
MessageBus.subscribe("game_start_client", _start_client)
MessageBus.subscribe("game_wait_for_connection", _wait_for_connection)
MessageBus.subscribe("game_close_connection", _wait_close_connection)
MessageBus.subscribe("game_peer_disconnected", _on_game_peer_disconnected)
func _start_client(address: String = "127.0.0.1", port: int = 8080) -> void:
if peer: return
start_client(address, port)
func _on_game_peer_disconnected() -> void:
close_connection()
Globals.multiplayer_data.reset()
Globals.lobby_data.go_back_to_match_screen()
MessageBus.clear_voided_listeners()
func client_connected_to_server() -> void:
push_warning("Connected to server!")
func close_connection() -> void:
if not peer: return
push_warning("Disconnected from, server...")
unset_client()
func client_disconnected_from_server() -> void:
push_warning("Disconnected from, server...")
func client_connection_failed_to_server() -> void:
push_warning("Connection failed!")
unset_client()

View File

@@ -0,0 +1 @@
uid://cjtu1d1j35r32

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cbvv2msu13vr2"]
[ext_resource type="Script" uid="uid://cjtu1d1j35r32" path="res://controllers/networking/game_client.gd" id="1_tea1p"]
[node name="client_net" type="Node"]
script = ExtResource("1_tea1p")

View File

@@ -0,0 +1,31 @@
class_name GameServer extends ServerNetworking
func _ready() -> void:
setup_signals()
func setup_signals() -> void:
pass
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()

View File

@@ -0,0 +1 @@
uid://bndylf4rwtlkn

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://bss61m8hfvab3"]
[ext_resource type="Script" uid="uid://bndylf4rwtlkn" path="res://controllers/networking/game_server.gd" id="1_3xapr"]
[node name="server_net" type="Node"]
script = ExtResource("1_3xapr")