Skip to content

Commit

Permalink
Update gauge logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Taurenkey committed Nov 16, 2024
1 parent 366edbc commit fcf8fbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion XIVSlothCombo/Combos/PvE/WHM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ protected override uint Invoke(uint actionID, uint lastComboMove, float comboTim
}
else ActionFound = StoneGlareList.Contains(actionID); //default handling

Svc.Log.Debug($"HERE");
if (ActionFound)
{
WHMGauge? gauge = GetJobGauge<WHMGauge>();
Expand Down
10 changes: 8 additions & 2 deletions XIVSlothCombo/Data/CustomComboCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using FFXIVClientStructs.FFXIV.Client.Game;
using System;
using System.Collections.Concurrent;
using System.Reflection;
using DalamudStatus = Dalamud.Game.ClientState.Statuses; // conflicts with structs if not defined

namespace XIVSlothCombo.Data
Expand All @@ -26,6 +27,8 @@ internal partial class CustomComboCache : IDisposable

private delegate IntPtr GetActionCooldownSlotDelegate(IntPtr actionManager, int cooldownGroup);

private unsafe IntPtr CSAddress => (nint)(JobGaugeManager.Instance()->CurrentGauge);

/// <inheritdoc/>
public void Dispose() => Svc.Framework.Update -= Framework_Update;

Expand All @@ -34,8 +37,11 @@ internal partial class CustomComboCache : IDisposable
/// <returns> The job gauge. </returns>
internal T GetJobGauge<T>() where T : JobGaugeBase
{
if (!jobGaugeCache.TryGetValue(typeof(T), out JobGaugeBase? gauge))
gauge = jobGaugeCache[typeof(T)] = Svc.Gauges.Get<T>();
//Lifted from Dalamud, using our own cache instead of theirs
if (!this.jobGaugeCache.TryGetValue(typeof(T), out var gauge) || gauge.Address != this.CSAddress)
{
gauge = this.jobGaugeCache[typeof(T)] = (T)Activator.CreateInstance(typeof(T), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { this.CSAddress }, null);
}

return (T)gauge;
}
Expand Down

0 comments on commit fcf8fbc

Please sign in to comment.