mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Add IFateTable (#1263)
This commit is contained in:
parent
1d5c3cee11
commit
a7202096bf
2 changed files with 53 additions and 23 deletions
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Game.ClientState.Fates;
|
||||
|
|
@ -14,7 +15,10 @@ namespace Dalamud.Game.ClientState.Fates;
|
|||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed partial class FateTable : IServiceType
|
||||
#pragma warning disable SA1015
|
||||
[ResolveVia<IFateTable>]
|
||||
#pragma warning enable SA1015
|
||||
public sealed partial class FateTable : IServiceType, IFateTable
|
||||
{
|
||||
private readonly ClientStateAddressResolver address;
|
||||
|
||||
|
|
@ -26,14 +30,10 @@ public sealed partial class FateTable : IServiceType
|
|||
Log.Verbose($"Fate table address 0x{this.address.FateTablePtr.ToInt64():X}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the Fate table.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
public IntPtr Address => this.address.FateTablePtr;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of currently active Fates.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
public unsafe int Length
|
||||
{
|
||||
get
|
||||
|
|
@ -69,11 +69,7 @@ public sealed partial class FateTable : IServiceType
|
|||
|
||||
private unsafe FFXIVClientStructs.FFXIV.Client.Game.Fate.FateManager* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Fate.FateManager*)this.FateTableAddress;
|
||||
|
||||
/// <summary>
|
||||
/// Get an actor at the specified spawn index.
|
||||
/// </summary>
|
||||
/// <param name="index">Spawn index.</param>
|
||||
/// <returns>A <see cref="Fate"/> at the specified spawn index.</returns>
|
||||
/// <inheritdoc/>
|
||||
public Fate? this[int index]
|
||||
{
|
||||
get
|
||||
|
|
@ -83,11 +79,7 @@ public sealed partial class FateTable : IServiceType
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the Fate at the specified index of the fate table.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the Fate.</param>
|
||||
/// <returns>The memory address of the Fate.</returns>
|
||||
/// <inheritdoc/>
|
||||
public unsafe IntPtr GetFateAddress(int index)
|
||||
{
|
||||
if (index >= this.Length)
|
||||
|
|
@ -100,11 +92,7 @@ public sealed partial class FateTable : IServiceType
|
|||
return (IntPtr)this.Struct->Fates.Get((ulong)index).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a reference to a FFXIV actor.
|
||||
/// </summary>
|
||||
/// <param name="offset">The offset of the actor in memory.</param>
|
||||
/// <returns><see cref="Fate"/> object containing requested data.</returns>
|
||||
/// <inheritdoc/>
|
||||
public Fate? CreateFateReference(IntPtr offset)
|
||||
{
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
|
@ -122,7 +110,7 @@ public sealed partial class FateTable : IServiceType
|
|||
/// <summary>
|
||||
/// This collection represents the currently available Fate events.
|
||||
/// </summary>
|
||||
public sealed partial class FateTable : IReadOnlyCollection<Fate>
|
||||
public sealed partial class FateTable
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
int IReadOnlyCollection<Fate>.Count => this.Length;
|
||||
|
|
|
|||
42
Dalamud/Plugin/Services/IFateTable.cs
Normal file
42
Dalamud/Plugin/Services/IFateTable.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using Dalamud.Game.ClientState.Fates;
|
||||
|
||||
namespace Dalamud.Plugin.Services;
|
||||
|
||||
/// <summary>
|
||||
/// This collection represents the currently available Fate events.
|
||||
/// </summary>
|
||||
public interface IFateTable : IReadOnlyCollection<Fate>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the address of the Fate table.
|
||||
/// </summary>
|
||||
public nint Address { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of currently active Fates.
|
||||
/// </summary>
|
||||
public int Length { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get an actor at the specified spawn index.
|
||||
/// </summary>
|
||||
/// <param name="index">Spawn index.</param>
|
||||
/// <returns>A <see cref="Fate"/> at the specified spawn index.</returns>
|
||||
public Fate? this[int index] { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the Fate at the specified index of the fate table.
|
||||
/// </summary>wo
|
||||
/// <param name="index">The index of the Fate.</param>
|
||||
/// <returns>The memory address of the Fate.</returns>
|
||||
public nint GetFateAddress(int index);
|
||||
|
||||
/// <summary>
|
||||
/// Create a reference to a FFXIV actor.
|
||||
/// </summary>
|
||||
/// <param name="offset">The offset of the actor in memory.</param>
|
||||
/// <returns><see cref="Fate"/> object containing requested data.</returns>
|
||||
public Fate? CreateFateReference(nint offset);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue