UI/SkateScore.razor

A UI Razor component for the in-game score display. It inherits PanelComponent and updates a single text field to show the local player's total trick score each frame.

Networking
@using Skateboard.Player
@inherits PanelComponent

<root>
	<div class="score">
		<div class="text">@_scoreText</div>
	</div>
</root>

@code
{
	private string _scoreText = "Score: 0";

	protected override void OnUpdate()
	{
		var pawn = SkatePawn.Local;
		var scores = pawn?.TrickScores;
		var next = scores is null ? "Score: 0" : $"Score: {scores.TotalScore}";

		if ( next == _scoreText )
			return;

		_scoreText = next;
		StateHasChanged();
	}
}