UI/PlayerHud/Components/WeaponInfoComponent.razor

A Blazor-style Razor UI component for the player HUD that lists the player's equipped items grouped by equipment slot. It displays each equipment name and highlights the currently deployed item with larger white text, and others in smaller dark grey text. It exposes helper methods for CSS classes, slot index, and hashing for change detection.

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

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

<root class="">
	@foreach (var SlotGroup in Inventory.PlayerEquipment.OrderBy(x => x.Slot).GroupBy(x => x.Slot))
	{
		<div class="" style="padding-right: 60px;">
			@foreach (var Equipment in SlotGroup)
			{
				@if (Equipment.IsValid())
				{
					@if (Equipment.IsDeployed)
					{
						<label style="font-size: 26px; color: white; position: absolute; top: 70%; right: 60px;">@Equipment.Name</label>
					}
					else
					{
						<label style="font-size: 18px; color: darkgrey;">@Equipment.Name</label>
					}
				}
			}
		</div>
	}
</root>

@code
{
	public PlayerPawn Player => PlayerState.Local.PlayerPawn;
	public PlayerInventory Inventory => Player.Inventory;
	public Equipment CurrentEquipment => Player?.CurrentEquipment;

	public string GroupClasses(EEquipmentSlot slot)
	{
		var wpn = CurrentEquipment;
		if (!wpn.IsValid()) return "";

		if (wpn.Slot == slot) return "active color-border-right";

		return "";
	}

	public int SlotIndex(EEquipmentSlot slot)
	{
		return (int)slot;
	}

	public int GetSlot(Equipment equipment) => Inventory.PlayerEquipment.ToList().IndexOf(equipment);

	protected override int BuildHash()
	{
		return !Player.IsValid() ? 0 : HashCode.Combine(Inventory.PlayerEquipment.Count(), CurrentEquipment);
	}
}