lobby/LobbyBoard.razor

A UI Razor component that shows a lobby board. It displays a launch countdown when a LobbyManager is launching, otherwise lists players by iterating PlayerReadyState components and showing each player's DisplayName and ready state indicator.

@using Sandbox
@using Sandbox.UI
@using System.Linq
@inherits PanelComponent

<root>
    <div class="board">
        @if (LaunchSeconds > 0)
        {
            <div class="title">Starting in</div>
            <div class="launch-number">@LaunchSeconds</div>
        }
        else
        {
            <div class="title">Players</div>
            <div class="grid">
                @foreach (PlayerReadyState player in Scene.GetAllComponents<PlayerReadyState>())
                {
                    <div class="cell">
                        <div class="name">@player.DisplayName</div>
                        <div class="dot @(player.IsReady ? "ready" : "notready")"></div>
                    </div>
                }
            </div>
        }
    </div>
</root>

@code {
    private int LaunchSeconds
    {
        get
        {
            LobbyManager mgr = LobbyManager.Current;
            if (mgr is null || !mgr.IsLaunching) return 0;
            return System.Math.Max(1, (int)System.MathF.Ceiling(mgr.LaunchSecondsRemaining));
        }
    }

    protected override int BuildHash()
    {
        IEnumerable<string> parts = Scene.GetAllComponents<PlayerReadyState>()
            .Select(p => $"{p.DisplayName}:{p.IsReady}");
        return System.HashCode.Combine(string.Join(",", parts), LaunchSeconds);
    }
}