UI/PlayerHud/Components/XHair.razor

Razor UI component for the player's crosshair. It renders a simple circle div when a local PlayerPawn exists and provides BuildHash to indicate when the component should re-render based on the Player and their current equipment.

Native Interop
@namespace KOTH.UI
@inherits Panel
@attribute [StyleSheet]

@if ( !Player.IsValid() )
    return;

<root>
    <div class="circle"></div>
</root>

@code
{
    /// The player
    public PlayerPawn Player => PlayerState.Local.PlayerPawn;

    protected override int BuildHash()
    {
        if ( !Player.IsValid() || !Player.CurrentEquipment.IsValid() )
            return 0;

        return HashCode.Combine(Player, Player.CurrentEquipment);
    }
}