A UI Razor component that renders a list of players. It gets the local player from Manager.Instance.LocalPlayer and iterates Manager.Instance.Players, rendering a PlayerIcon component for every player except the local player. It includes a stylesheet and overrides BuildHash to force rebuilds using the current real time.
@namespace Sandbox
@using Sandbox;
@using Sandbox.UI;
@using System;
@inherits Panel
@attribute [StyleSheet("PlayerList.razor.scss")]
<root>
@{
var localPlayer = Manager.Instance.LocalPlayer;
}
@foreach(var otherPlayer in Manager.Instance.Players)
{
if(localPlayer != otherPlayer)
{
<PlayerIcon Player=@otherPlayer />
}
}
</root>
@code {
protected override int BuildHash()
{
return HashCode.Combine(RealTime.Now);
}
}