diff --git a/XIVSlothCombo/Data/CooldownData.cs b/XIVSlothCombo/Data/CooldownData.cs index 3a370d8e1..8e2387462 100644 --- a/XIVSlothCombo/Data/CooldownData.cs +++ b/XIVSlothCombo/Data/CooldownData.cs @@ -1,4 +1,5 @@ using FFXIVClientStructs.FFXIV.Client.Game; +using System; using XIVSlothCombo.Services; namespace XIVSlothCombo.Data @@ -10,9 +11,7 @@ public bool IsCooldown { get { - return RemainingCharges == MaxCharges - ? false - : CooldownElapsed < CooldownTotal; + return CooldownRemaining > 0; } } @@ -20,17 +19,17 @@ public bool IsCooldown public uint ActionID; /// Gets the elapsed cooldown time. - public unsafe float CooldownElapsed => ActionManager.Instance()->GetRecastGroupDetail(ActionManager.Instance()->GetRecastGroup(1, ActionID))->Elapsed; + public unsafe float CooldownElapsed => ActionManager.Instance()->GetRecastTimeElapsed(ActionType.Action, ActionID); /// Gets the total cooldown time. public unsafe float CooldownTotal => (ActionManager.GetAdjustedRecastTime(ActionType.Action, ActionID) / 1000f) * MaxCharges; /// Gets the cooldown time remaining. - public unsafe float CooldownRemaining => IsCooldown ? CooldownTotal - CooldownElapsed : 0; + public unsafe float CooldownRemaining => CooldownElapsed == 0 ? 0 : Math.Max(0, CooldownTotal - CooldownElapsed); /// Gets the maximum number of charges for an action at the current level. /// Number of charges. - public ushort MaxCharges => Service.ComboCache.GetMaxCharges(ActionID); + public ushort MaxCharges => ActionManager.GetMaxCharges(ActionID, 0); /// Gets a value indicating whether the action has charges, not charges available. public bool HasCharges => MaxCharges > 1; @@ -43,12 +42,6 @@ public float ChargeCooldownRemaining { get { - if (!IsCooldown) - return 0; - - var maxCharges = ActionManager.GetMaxCharges(ActionID, 100); - var timePerCharge = CooldownTotal / maxCharges; - return CooldownRemaining % (CooldownTotal / MaxCharges); } } diff --git a/XIVSlothCombo/Data/CustomComboCache.cs b/XIVSlothCombo/Data/CustomComboCache.cs index c49e564d4..33fdbdef0 100644 --- a/XIVSlothCombo/Data/CustomComboCache.cs +++ b/XIVSlothCombo/Data/CustomComboCache.cs @@ -92,7 +92,7 @@ internal unsafe CooldownData GetCooldown(uint actionID) /// Get the maximum number of charges for an action. /// Action ID to check. /// Max number of charges at current level. - internal unsafe ushort GetMaxCharges(uint actionID) => ActionManager.GetMaxCharges(actionID, 0); + internal unsafe ushort GetMaxCharges(uint actionID) => GetCooldown(actionID).MaxCharges; /// Get the resource cost of an action. /// Action ID to check.