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>
This commit is contained in:
parent
19e8863f4e
commit
6b1ae4fb76
27 changed files with 875 additions and 20 deletions
31
src/AcDream.Core/Items/ItemCooldownDisplay.cs
Normal file
31
src/AcDream.Core/Items/ItemCooldownDisplay.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue