diff --git a/Dalamud/Game/ClientState/JobGauge/JobGauges.cs b/Dalamud/Game/ClientState/JobGauge/JobGauges.cs index bf5c4b525..683f5c61f 100644 --- a/Dalamud/Game/ClientState/JobGauge/JobGauges.cs +++ b/Dalamud/Game/ClientState/JobGauge/JobGauges.cs @@ -5,6 +5,7 @@ using System.Reflection; using Dalamud.Game.ClientState.JobGauge.Types; using Dalamud.IoC; using Dalamud.IoC.Internal; +using Dalamud.Plugin.Services; using Serilog; namespace Dalamud.Game.ClientState.JobGauge; @@ -15,7 +16,10 @@ namespace Dalamud.Game.ClientState.JobGauge; [PluginInterface] [InterfaceVersion("1.0")] [ServiceManager.BlockingEarlyLoadedService] -public class JobGauges : IServiceType +#pragma warning disable SA1015 +[ResolveVia] +#pragma warning restore SA1015 +public class JobGauges : IServiceType, IJobGauges { private Dictionary cache = new(); @@ -27,16 +31,10 @@ public class JobGauges : IServiceType Log.Verbose($"JobGaugeData address 0x{this.Address.ToInt64():X}"); } - /// - /// Gets the address of the JobGauge data. - /// + /// public IntPtr Address { get; } - /// - /// Get the JobGauge for a given job. - /// - /// A JobGauge struct from ClientState.Structs.JobGauge. - /// A JobGauge. + /// public T Get() where T : JobGaugeBase { // This is cached to mitigate the effects of using activator for instantiation. diff --git a/Dalamud/Plugin/Services/IJobGauges.cs b/Dalamud/Plugin/Services/IJobGauges.cs new file mode 100644 index 000000000..4489a7be7 --- /dev/null +++ b/Dalamud/Plugin/Services/IJobGauges.cs @@ -0,0 +1,21 @@ +using Dalamud.Game.ClientState.JobGauge.Types; + +namespace Dalamud.Plugin.Services; + +/// +/// This class converts in-memory Job gauge data to structs. +/// +public interface IJobGauges +{ + /// + /// Gets the address of the JobGauge data. + /// + public nint Address { get; } + + /// + /// Get the JobGauge for a given job. + /// + /// A JobGauge struct from ClientState.Structs.JobGauge. + /// A JobGauge. + public T Get() where T : JobGaugeBase; +}