feat: backend state machine, Unity URL prod, simplify GameSetup

This commit is contained in:
2026-05-15 09:16:01 +02:00
parent c322793b0d
commit 1e37e44143
6 changed files with 400 additions and 215 deletions

View File

@@ -67,11 +67,11 @@ public class DebugNetworkUI : MonoBehaviour
string name = !string.IsNullOrEmpty(nm.LocalPlayerName) ? nm.LocalPlayerName : "\u2014";
string room = !string.IsNullOrEmpty(nm.RoomId) ? nm.RoomId[..Mathf.Min(8, nm.RoomId.Length)] : "\u2014";
string sess = !string.IsNullOrEmpty(nm.LocalSessionId) ? nm.LocalSessionId[..Mathf.Min(6, nm.LocalSessionId.Length)] : "\u2014";
info = $" {dot} <b>{name}</b> | Room {room} | Sess {sess} | {nm.PlayerCount}P | {nm.serverURL} | {_currentFps:F0} FPS";
info = $" {dot} <b>{name}</b> | Room {room} | Sess {sess} | {nm.PlayerCount}P | {"wss://rolld.io:2567"} | {_currentFps:F0} FPS";
}
else
{
info = $" {dot} {nm.ConnectionStatus} | {nm.serverURL} | {_currentFps:F0} FPS";
info = $" {dot} {nm.ConnectionStatus} | {"wss://rolld.io:2567"} | {_currentFps:F0} FPS";
}
GUI.Label(new Rect(0, 0, Screen.width, h), info, ImGuiSkin.HudLabel);
@@ -93,7 +93,7 @@ public class DebugNetworkUI : MonoBehaviour
GUIStyle statusStyle = nm.IsConnected ? ImGuiSkin.StatusGreen : ImGuiSkin.StatusRed;
GUILayout.Label($"\u25CF {nm.ConnectionStatus}", statusStyle);
ImGuiSkin.DrawField("Server", nm.serverURL);
ImGuiSkin.DrawField("Server", "wss://rolld.io:2567");
ImGuiSkin.DrawField("Room ID", string.IsNullOrEmpty(nm.RoomId) ? "\u2014" : nm.RoomId);
ImGuiSkin.DrawField("Session", string.IsNullOrEmpty(nm.LocalSessionId) ? "\u2014" : nm.LocalSessionId);
ImGuiSkin.DrawField("Players", nm.PlayerCount.ToString());

View File

@@ -327,7 +327,7 @@ public class LobbyUI : MonoBehaviour
if (_isConnecting && !NetworkManager.Instance.IsConnected)
{
_isConnecting = false;
_statusMessage = "Erreur : Timeout de connexion. Vérifiez que le serveur est lancé.";
_statusMessage = "Erreur : Impossible de joindre rolld.io. Réessayez dans quelques instants.";
if (!string.IsNullOrEmpty(NetworkManager.Instance.LastError))
{
_statusMessage += $"\n{NetworkManager.Instance.LastError}";

View File

@@ -12,9 +12,7 @@ public class NetworkManager : MonoBehaviour
{
public static NetworkManager Instance { get; private set; }
[Header("Connection")]
[Tooltip("Colyseus server endpoint (overridden by frontend via SetServerURL)")]
public string serverURL = "ws://localhost:2567";
private const string serverURL = "wss://rolld.io:2567";
[Header("Prefab")]
[Tooltip("Prefab for remote players (must have RemotePlayerController)")]
@@ -94,13 +92,6 @@ public class NetworkManager : MonoBehaviour
}
}
/// <summary>Called from frontend JS via SendMessage to override the server URL.</summary>
public void SetServerURL(string url)
{
serverURL = url;
Debug.Log($"[Network] Server URL set to: {url}");
}
public NetworkPlayer GetLocalPlayerState()
{
if (_room == null || _room.State.players == null || string.IsNullOrEmpty(LocalSessionId)) return null;