(Feat) Add Build

This commit is contained in:
2026-07-22 12:56:13 +02:00
parent 3657b870d8
commit 0052b0d98e
244 changed files with 35752 additions and 3112 deletions
@@ -39,5 +39,21 @@ namespace Ashwild.Inventory
DurationFill = durationFill;
DurationText = durationText;
}
/// <summary>
/// Builds the payload for a hovered slot, including the uses bar for items that track
/// durability. Shared by the inventory grid and the hotbar so both describe an item
/// identically — they used to each build this by hand and could drift apart.
/// </summary>
public static ItemDescriptionView From(InventorySlot slot)
{
ItemData item = slot.ItemData;
bool hasDuration = item.HasUses;
float fill = hasDuration && item.MaxUses > 0 ? (float)slot.CurrentUses / item.MaxUses : 0f;
string durationText = hasDuration ? $"{slot.CurrentUses} / {item.MaxUses}" : string.Empty;
return new ItemDescriptionView(item.Icon, item.ItemName, item.Description,
hasDuration, fill, durationText);
}
}
}