acdream/src/AcDream.Core/Items/ItemCooldownDisplay.cs
Erik 6b1ae4fb76 feat(items): port retail shared cooldown overlays
Preserve public shared-cooldown metadata, resolve the authoritative cooldown enchantment with retail expiry semantics, and project the exact ten DAT-authored radial steps through the shared retained item-slot architecture.

Co-authored-by: Codex <codex@openai.com>
2026-07-23 10:41:16 +02:00

31 lines
966 B
C#

namespace AcDream.Core.Items;
/// <summary>
/// Retail item-cooldown projection shared by inventory, equipment, and shortcut
/// UIItems.
///
/// <para>
/// Port of <c>UIElement_UIItem::UpdateCooldownDisplay @ 0x004E1E20</c>.
/// The remaining fraction selects one of ten authored radial overlays.
/// </para>
/// </summary>
public static class ItemCooldownDisplay
{
/// <summary>
/// Retail's exact ten-step display formula:
/// <c>trunc((remaining / itemDuration) * 10 + 1)</c>. Results 1..9 select
/// the 10%..90% art, while 10 or above selects the 100% art.
/// </summary>
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;
}
}