ui/MoneyPanel.razor

A Razor UI panel that shows the player's money as a dollar amount, read from Manager.Instance. The label scales down from 1.5 to 1 with a QuadOut ease over one second after the money changes. BuildHash includes Time.Now while the timer is under a second so the panel rebuilds each frame during that animation and stays static otherwise.

@using Sandbox;
@using Sandbox.UI;
@inherits Panel
@attribute [StyleSheet("MoneyPanel.razor.scss")]

<root>
	<div class="label" style="transform: scale(@(Utils.Map(Manager.Instance.TimeSinceMoneyChanged, 0f, 1f, 1.5f, 1f, EasingType.QuadOut)));">
		@($"${Manager.Instance.Money}")
	</div>
</root>

@code
{
	protected override int BuildHash()
	{
		float moneyChangedHash = Manager.Instance.TimeSinceMoneyChanged < 1f ? Time.Now : 0f;

		return HashCode.Combine(
			Manager.Instance.Money,
			moneyChangedHash
		);
	}
}