mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-21 16:09:19 +01:00
Add IJobGauges (#1265)
This commit is contained in:
parent
9ebfbb7871
commit
1d5c3cee11
2 changed files with 28 additions and 9 deletions
|
|
@ -5,6 +5,7 @@ using System.Reflection;
|
||||||
using Dalamud.Game.ClientState.JobGauge.Types;
|
using Dalamud.Game.ClientState.JobGauge.Types;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.JobGauge;
|
namespace Dalamud.Game.ClientState.JobGauge;
|
||||||
|
|
@ -15,7 +16,10 @@ namespace Dalamud.Game.ClientState.JobGauge;
|
||||||
[PluginInterface]
|
[PluginInterface]
|
||||||
[InterfaceVersion("1.0")]
|
[InterfaceVersion("1.0")]
|
||||||
[ServiceManager.BlockingEarlyLoadedService]
|
[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();
|
private Dictionary<Type, JobGaugeBase> cache = new();
|
||||||
|
|
||||||
|
|
@ -27,16 +31,10 @@ public class JobGauges : IServiceType
|
||||||
Log.Verbose($"JobGaugeData address 0x{this.Address.ToInt64():X}");
|
Log.Verbose($"JobGaugeData address 0x{this.Address.ToInt64():X}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// Gets the address of the JobGauge data.
|
|
||||||
/// </summary>
|
|
||||||
public IntPtr Address { get; }
|
public IntPtr Address { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// 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
|
public T Get<T>() where T : JobGaugeBase
|
||||||
{
|
{
|
||||||
// This is cached to mitigate the effects of using activator for instantiation.
|
// This is cached to mitigate the effects of using activator for instantiation.
|
||||||
|
|
|
||||||
21
Dalamud/Plugin/Services/IJobGauges.cs
Normal file
21
Dalamud/Plugin/Services/IJobGauges.cs
Normal 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;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue