namespace AcDream.Core.Items;
///
/// Retail item-cooldown projection shared by inventory, equipment, and shortcut
/// UIItems.
///
///
/// Port of UIElement_UIItem::UpdateCooldownDisplay @ 0x004E1E20.
/// The remaining fraction selects one of ten authored radial overlays.
///
///
public static class ItemCooldownDisplay
{
///
/// Retail's exact ten-step display formula:
/// trunc((remaining / itemDuration) * 10 + 1). Results 1..9 select
/// the 10%..90% art, while 10 or above selects the 100% art.
///
public static int GetOverlayStep(double itemDuration, double remaining)
{
if (!(itemDuration > 0d) || !(remaining > 0d))
return 0;
double step = Math.Truncate((remaining / itemDuration) * 10d + 1d);
if (!(step >= 1d))
return 0;
if (step >= 10d)
return 10;
return (int)step;
}
}