UI/PlayerMenu/ClassSelect.razor

A Razor UI panel for class selection in the game's player menu. It renders a centered table of class buttons from the active ClassList, highlights the locally requested class, shows a spawn countdown label, and toggles mouse visibility when active.

NetworkingFile Access
@using System;
@using Sandbox.UI;

@namespace KOTH.UI
@inherits Panel

@attribute [StyleSheet]

<style>
	button:hover {
		background-color: #BEBECC33;
		border-radius: 12px;
	}

	.requested {
		background-color: #A3ABFF22;
		border-radius: 12px;
	}
</style>

<root class="hidden flex absolute inset-0 align-center justify-center">
	<table class="with-padding-lg layout" style="background-color: #BEBEBE22;">
		<div class="title" style="font-size: 24px;">
			Select Class
		</div>

		@foreach (CharacterDefinition Class in ActiveClassList.ClassDefinitions)
		{
			<button class="@(Class == PlayerState.Local.RequestedCharacterDefinition ? "requested" : "")" onclick="@(() => SelectClass(Class))" style="cursor: pointer; padding: 50px;">@Class.CharacterName | @Class.Description</button>
		}
	</table>

	@if (PlayerState.Local.TimeTilAttemptedSpawn != -1)
	{
		<label style="position: absolute; top: 5%; font-size: 50px; color: antiquewhite;">@(Math.Round(PlayerState.Local.TimeTilAttemptedSpawn))</label>
	}
</root>

@code
{
	public static bool IsActive { get; set; } = true;

	protected override int BuildHash()
	{
		return HashCode.Combine(Time.Now);
	}

	public ClassList ActiveClassList { get => GameMode.Instance.Components.Get<ClassList>(); }

	private void SelectClass(CharacterDefinition Class)
	{
		PlayerState.Local.RequestCharacterDefinition(Class);
	}

	public override void Tick()
	{
		base.Tick();

		SetClass("visible", IsActive);

		Mouse.Visibility = IsActive ? MouseVisibility.Visible : MouseVisibility.Hidden;
	}
}