RedLightGreenLightUI.razor
@using Sandbox;
@using Sandbox.UI;
@inherits PanelComponent
@namespace Sandbox

<root>
	<div class="title">@StateText</div>
</root>

@code
{

	[Property] public RedLightGreenLight Game { get; set; }

	[Property] public RedLightPlayer Player { get; set; }

	string StateText
{
    get
    {
		// Player-specific states come first
        if ( Player?.State == RedLightPlayer.PlayerState.GameOver )
            return "GAME OVER";

        if ( Player?.State == RedLightPlayer.PlayerState.Win )
            return "WIN";

        // If the player is Playing, show the global light
        return Game?.State switch
        {
            RedLightGreenLight.GameState.Green => "GREEN",
            RedLightGreenLight.GameState.Red => "RED",
            _ => "WAITING"
        };
    }
}

	protected override int BuildHash()
    => System.HashCode.Combine( Game?.State, Player?.State );
}