UI/Panels/GameHud/WeaponHud/WeaponButton.razor
@using Sandbox;
@using Sandbox.UI;
@namespace Battlebugs
@inherits Panel
@attribute [StyleSheet]

<root class=@GetClass()>
	<div class="icon">
		<img [email protected] />
		<label>@(Value < 0 ? "∞" : $"x{Value}")</label>
	</div>
	<label>@Weapon.Name</label>
	<div class="border" />

	<div class="info-panel">
		<div class="header">
			<img [email protected] />
			<div class="info">
				<label class="name">@Weapon.Name</label>
				<label class="count">Count: @(Value < 0 ? "∞" : Value.ToString())</label>
			</div>
		</div>
		<label>@Weapon.Description</label>
	</div>
</root>

@code
{
	public WeaponResource Weapon { get; set; }

	int Value => BoardManager.Local.WeaponInventory[Weapon];

	string GetClass()
	{
		string str = BoardManager.Local.SelectedWeapon == Weapon ? "selected" : "";
		if (Value == 0)
		{
			str += " disabled";
		}
		return str;
	}
	protected override void OnMouseDown(MousePanelEvent e)
	{
		if (Value == 0) return;

		BoardManager.Local.SelectedWeapon = Weapon;
	}

	protected override int BuildHash() => System.HashCode.Combine(BoardManager.Local.SelectedWeapon, Value);
}