mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 12:23:39 +01:00
parent
71bf9fdcf2
commit
dd1586d5d6
12 changed files with 52 additions and 107 deletions
|
|
@ -1,10 +1,9 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Game.ClientState.Aetherytes;
|
||||
|
|
@ -15,28 +14,23 @@ namespace Dalamud.Game.ClientState.Aetherytes;
|
|||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed partial class AetheryteList : IServiceType
|
||||
public sealed unsafe partial class AetheryteList : IServiceType
|
||||
{
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly ClientState clientState = Service<ClientState>.Get();
|
||||
private readonly ClientStateAddressResolver address;
|
||||
private readonly UpdateAetheryteListDelegate updateAetheryteListFunc;
|
||||
|
||||
private readonly Telepo* telepoInstance = Telepo.Instance();
|
||||
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private AetheryteList()
|
||||
{
|
||||
this.address = this.clientState.AddressResolver;
|
||||
this.updateAetheryteListFunc = Marshal.GetDelegateForFunctionPointer<UpdateAetheryteListDelegate>(this.address.UpdateAetheryteList);
|
||||
|
||||
Log.Verbose($"Teleport address 0x{this.address.Telepo.ToInt64():X}");
|
||||
Log.Verbose($"Teleport address 0x{((nint)this.telepoInstance).ToInt64():X}");
|
||||
}
|
||||
|
||||
private delegate void UpdateAetheryteListDelegate(IntPtr telepo, byte arg1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of Aetherytes the local player has unlocked.
|
||||
/// </summary>
|
||||
public unsafe int Length
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -45,21 +39,19 @@ public sealed partial class AetheryteList : IServiceType
|
|||
|
||||
this.Update();
|
||||
|
||||
if (TelepoStruct->TeleportList.First == TelepoStruct->TeleportList.Last)
|
||||
if (this.telepoInstance->TeleportList.First == this.telepoInstance->TeleportList.Last)
|
||||
return 0;
|
||||
|
||||
return (int)TelepoStruct->TeleportList.Size();
|
||||
return (int)this.telepoInstance->TeleportList.Size();
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe FFXIVClientStructs.FFXIV.Client.Game.UI.Telepo* TelepoStruct => (FFXIVClientStructs.FFXIV.Client.Game.UI.Telepo*)this.address.Telepo;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Aetheryte Entry at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">Index.</param>
|
||||
/// <returns>A <see cref="AetheryteEntry"/> at the specified index.</returns>
|
||||
public unsafe AetheryteEntry? this[int index]
|
||||
public AetheryteEntry? this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -71,7 +63,7 @@ public sealed partial class AetheryteList : IServiceType
|
|||
if (this.clientState.LocalPlayer == null)
|
||||
return null;
|
||||
|
||||
return new AetheryteEntry(TelepoStruct->TeleportList.Get((ulong)index));
|
||||
return new AetheryteEntry(this.telepoInstance->TeleportList.Get((ulong)index));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +73,7 @@ public sealed partial class AetheryteList : IServiceType
|
|||
if (this.clientState.LocalPlayer == null)
|
||||
return;
|
||||
|
||||
this.updateAetheryteListFunc(this.address.Telepo, 0);
|
||||
this.telepoInstance->UpdateAetheryteList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue