mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 05:43:40 +01:00
Implement service locator
This commit is contained in:
parent
06b1163a52
commit
ff1d7f2829
101 changed files with 1614 additions and 1436 deletions
|
|
@ -3,6 +3,8 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using JetBrains.Annotations;
|
||||
using Serilog;
|
||||
|
||||
|
|
@ -11,22 +13,21 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// <summary>
|
||||
/// This collection represents the actors present in your party or alliance.
|
||||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
public sealed unsafe partial class PartyList
|
||||
{
|
||||
private const int GroupLength = 8;
|
||||
private const int AllianceLength = 20;
|
||||
|
||||
private readonly Dalamud dalamud;
|
||||
private readonly ClientStateAddressResolver address;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PartyList"/> class.
|
||||
/// </summary>
|
||||
/// <param name="dalamud">The <see cref="dalamud"/> instance.</param>
|
||||
/// <param name="addressResolver">Client state address resolver.</param>
|
||||
internal PartyList(Dalamud dalamud, ClientStateAddressResolver addressResolver)
|
||||
internal PartyList(ClientStateAddressResolver addressResolver)
|
||||
{
|
||||
this.dalamud = dalamud;
|
||||
this.address = addressResolver;
|
||||
|
||||
Log.Verbose($"Group manager address 0x{this.address.GroupManager.ToInt64():X}");
|
||||
|
|
@ -114,13 +115,15 @@ namespace Dalamud.Game.ClientState.Party
|
|||
[CanBeNull]
|
||||
public PartyMember CreatePartyMemberReference(IntPtr address)
|
||||
{
|
||||
if (this.dalamud.ClientState.LocalContentId == 0)
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
if (clientState.LocalContentId == 0)
|
||||
return null;
|
||||
|
||||
if (address == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
return new PartyMember(address, this.dalamud);
|
||||
return new PartyMember(address);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -144,13 +147,15 @@ namespace Dalamud.Game.ClientState.Party
|
|||
[CanBeNull]
|
||||
public PartyMember CreateAllianceMemberReference(IntPtr address)
|
||||
{
|
||||
if (this.dalamud.ClientState.LocalContentId == 0)
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
if (clientState.LocalContentId == 0)
|
||||
return null;
|
||||
|
||||
if (address == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
return new PartyMember(address, this.dalamud);
|
||||
return new PartyMember(address);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Game.ClientState.Resolvers;
|
||||
using Dalamud.Game.ClientState.Statuses;
|
||||
|
|
@ -15,17 +16,13 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// </summary>
|
||||
public unsafe class PartyMember
|
||||
{
|
||||
private Dalamud dalamud;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PartyMember"/> class.
|
||||
/// </summary>
|
||||
/// <param name="address">Address of the party member.</param>
|
||||
/// <param name="dalamud">Dalamud itself.</param>
|
||||
internal PartyMember(IntPtr address, Dalamud dalamud)
|
||||
internal PartyMember(IntPtr address)
|
||||
{
|
||||
this.Address = address;
|
||||
this.dalamud = dalamud;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -36,7 +33,7 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// <summary>
|
||||
/// Gets a list of buffs or debuffs applied to this party member.
|
||||
/// </summary>
|
||||
public StatusList Statuses => new(&this.Struct->StatusManager, this.dalamud);
|
||||
public StatusList Statuses => new(&this.Struct->StatusManager);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the position of the party member.
|
||||
|
|
@ -60,7 +57,7 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// This iterates the actor table, it should be used with care.
|
||||
/// </remarks>
|
||||
[CanBeNull]
|
||||
public GameObject GameObject => this.dalamud.ClientState.Objects.SearchByID(this.ObjectId);
|
||||
public GameObject GameObject => Service<ObjectTable>.Get().SearchByID(this.ObjectId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current HP of this party member.
|
||||
|
|
@ -85,12 +82,12 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// <summary>
|
||||
/// Gets the territory this party member is located in.
|
||||
/// </summary>
|
||||
public ExcelResolver<Lumina.Excel.GeneratedSheets.TerritoryType> Territory => new(this.Struct->TerritoryType, this.dalamud);
|
||||
public ExcelResolver<Lumina.Excel.GeneratedSheets.TerritoryType> Territory => new(this.Struct->TerritoryType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the World this party member resides in.
|
||||
/// </summary>
|
||||
public ExcelResolver<Lumina.Excel.GeneratedSheets.World> World => new(this.Struct->HomeWorld, this.dalamud);
|
||||
public ExcelResolver<Lumina.Excel.GeneratedSheets.World> World => new(this.Struct->HomeWorld);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the displayname of this party member.
|
||||
|
|
@ -105,7 +102,7 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// <summary>
|
||||
/// Gets the classjob of this party member.
|
||||
/// </summary>
|
||||
public ExcelResolver<Lumina.Excel.GeneratedSheets.ClassJob> ClassJob => new(this.Struct->ClassJob, this.dalamud);
|
||||
public ExcelResolver<Lumina.Excel.GeneratedSheets.ClassJob> ClassJob => new(this.Struct->ClassJob);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the level of this party member.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue