A UI Razor panel representing a single lobby slot. It shows a Join button when there is no local player and calls the lobby manager to request the slot index when clicked. It also includes a BuildHash override that combines the slot index and local player validity.
@namespace Sandbox
@using Sandbox;
@using Sandbox.UI;
@using System;
@using System.Text.Json;
@inherits Panel
<root>
@if(!Manager.Instance.LocalPlayer.IsValid())
{
<div class="button" onclick=@ClaimSlot>
<label>Join</label>
</div>
}
</root>
@code
{
public int Index { get; set; }
void ClaimSlot()
{
Manager.Instance?.RequestLobbySlot(Index);
}
protected override int BuildHash() => System.HashCode.Combine(Index, Manager.Instance.LocalPlayer.IsValid());
}