mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-01 05:13:40 +01:00
Load services asynchronously whenever possible (#893)
This commit is contained in:
parent
fba8c7163c
commit
8e7f370ddd
66 changed files with 959 additions and 899 deletions
|
|
@ -14,18 +14,18 @@ namespace Dalamud.Game.ClientState.Aetherytes
|
|||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed partial class AetheryteList
|
||||
{
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly ClientState clientState = Service<ClientState>.Get();
|
||||
private readonly ClientStateAddressResolver address;
|
||||
private readonly UpdateAetheryteListDelegate updateAetheryteListFunc;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AetheryteList"/> class.
|
||||
/// </summary>
|
||||
/// <param name="addressResolver">Client state address resolver.</param>
|
||||
internal AetheryteList(ClientStateAddressResolver addressResolver)
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private AetheryteList()
|
||||
{
|
||||
this.address = addressResolver;
|
||||
this.address = this.clientState.AddressResolver;
|
||||
this.updateAetheryteListFunc = Marshal.GetDelegateForFunctionPointer<UpdateAetheryteListDelegate>(this.address.UpdateAetheryteList);
|
||||
|
||||
Log.Verbose($"Teleport address 0x{this.address.Telepo.ToInt64():X}");
|
||||
|
|
@ -40,9 +40,7 @@ namespace Dalamud.Game.ClientState.Aetherytes
|
|||
{
|
||||
get
|
||||
{
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
if (clientState.LocalPlayer == null)
|
||||
if (this.clientState.LocalPlayer == null)
|
||||
return 0;
|
||||
|
||||
this.Update();
|
||||
|
|
@ -70,9 +68,7 @@ namespace Dalamud.Game.ClientState.Aetherytes
|
|||
return null;
|
||||
}
|
||||
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
if (clientState.LocalPlayer == null)
|
||||
if (this.clientState.LocalPlayer == null)
|
||||
return null;
|
||||
|
||||
return new AetheryteEntry(TelepoStruct->TeleportList.Get((ulong)index));
|
||||
|
|
@ -81,10 +77,8 @@ namespace Dalamud.Game.ClientState.Aetherytes
|
|||
|
||||
private void Update()
|
||||
{
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
// this is very very important as otherwise it crashes
|
||||
if (clientState.LocalPlayer == null)
|
||||
if (this.clientState.LocalPlayer == null)
|
||||
return;
|
||||
|
||||
this.updateAetheryteListFunc(this.address.Telepo, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue