@using Sandbox.UI @using Sasalka @inherits Sandbox.UI.Panel @namespace Sasalka.Ui @{ var definition = Item?.Definition; var name = definition?.Name; var slot = Item?.Equipped == true ? definition?.GetSlot() : null; var imageUrl = definition?.ImageTexture.IsValid() == true ? definition.ImageTexture.ResourcePath : !string.IsNullOrWhiteSpace( definition?.ImageUrl ) ? definition.ImageUrl : null; var rarityColor = definition?.GetRarityColor() ?? "#ffffff"; var categoryIcon = definition?.GetCategoryIcon() ?? "📦"; }
@if ( !string.IsNullOrEmpty( imageUrl ) ) { @name } else { @categoryIcon }
@name
@if ( definition?.Category != ItemCategory.Misc ) {
@definition?.Category
}
@if ( slot is not null ) {
@GetSlotName( slot.Value )
} @if ( definition?.MaxCount > 1 ) {
@Item?.Count / @definition.MaxCount
} @* @if ( Item?.Equipped == true ) *@ @* { *@ @*
*@ @* } *@
@code { public Sasalka.InventoryItem Item { get; set; } public Action OnItemClick { get; set; } public Action OnItemRightClick { get; set; } string GetSlotName( Inventar.InventorySlot slot ) { return slot switch { Inventar.InventorySlot.LeftHand => "Л.Рука", Inventar.InventorySlot.RightHand => "П.Рука", Inventar.InventorySlot.Head => "Голова", Inventar.InventorySlot.Body => "Тело", Inventar.InventorySlot.Hands => "Руки", Inventar.InventorySlot.Bottom => "Ноги", Inventar.InventorySlot.Feet => "Обувь", _ => "Неизвестно" }; } protected override int BuildHash() { base.BuildHash(); var hash = new HashCode(); hash.Add( Item?.Count ); hash.Add( Item?.Equipped ); hash.Add( Item?.Definition?.Name ); return hash.ToHashCode(); } }