Add IJobGauges (#1265)

This commit is contained in:
MidoriKami 2023-06-24 17:10:53 -07:00 committed by GitHub
parent 9ebfbb7871
commit 1d5c3cee11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 9 deletions

View file

@ -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<IJobGauges>]
#pragma warning restore SA1015
public class JobGauges : IServiceType, IJobGauges
{
private Dictionary<Type, JobGaugeBase> cache = new();
@ -27,16 +31,10 @@ public class JobGauges : IServiceType
Log.Verbose($"JobGaugeData address 0x{this.Address.ToInt64():X}");
}
/// <summary>
/// Gets the address of the JobGauge data.
/// </summary>
/// <inheritdoc/>
public IntPtr Address { get; }
/// <summary>
/// Get the JobGauge for a given job.
/// </summary>
/// <typeparam name="T">A JobGauge struct from ClientState.Structs.JobGauge.</typeparam>
/// <returns>A JobGauge.</returns>
/// <inheritdoc/>
public T Get<T>() where T : JobGaugeBase
{
// This is cached to mitigate the effects of using activator for instantiation.

View file

@ -0,0 +1,21 @@
using Dalamud.Game.ClientState.JobGauge.Types;
namespace Dalamud.Plugin.Services;
/// <summary>
/// This class converts in-memory Job gauge data to structs.
/// </summary>
public interface IJobGauges
{
/// <summary>
/// Gets the address of the JobGauge data.
/// </summary>
public nint Address { get; }
/// <summary>
/// Get the JobGauge for a given job.
/// </summary>
/// <typeparam name="T">A JobGauge struct from ClientState.Structs.JobGauge.</typeparam>
/// <returns>A JobGauge.</returns>
public T Get<T>() where T : JobGaugeBase;
}