(Feat) Add Build
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user