<inheritdoc/>

This commit is contained in:
Haselnussbomber 2025-08-05 01:44:44 +02:00
parent 752ed8181c
commit 93edc723e8
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1

View file

@ -16,33 +16,19 @@ namespace Dalamud.Game.PlayerState;
/// </summary> /// </summary>
internal unsafe partial class PlayerState : IInternalDisposableService, IPlayerState internal unsafe partial class PlayerState : IInternalDisposableService, IPlayerState
{ {
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether the local character is loaded.
/// </summary>
/// <remarks>
/// This is equivalent with being logged in.<br/>
/// The actual GameObject will not immediately exist when this changes to true.
/// </remarks>
public bool IsLoaded => CSPlayerState.Instance()->IsLoaded == 1; public bool IsLoaded => CSPlayerState.Instance()->IsLoaded == 1;
/// <summary> /// <inheritdoc/>
/// Gets the name of the local character.
/// </summary>
public string CharacterName => this.IsLoaded ? CSPlayerState.Instance()->CharacterNameString : string.Empty; public string CharacterName => this.IsLoaded ? CSPlayerState.Instance()->CharacterNameString : string.Empty;
/// <summary> /// <inheritdoc/>
/// Gets the entity ID of the local character.
/// </summary>
public uint EntityId => this.IsLoaded ? CSPlayerState.Instance()->EntityId : default; public uint EntityId => this.IsLoaded ? CSPlayerState.Instance()->EntityId : default;
/// <summary> /// <inheritdoc/>
/// Gets the content ID of the local character.
/// </summary>
public ulong ContentId => this.IsLoaded ? CSPlayerState.Instance()->ContentId : default; public ulong ContentId => this.IsLoaded ? CSPlayerState.Instance()->ContentId : default;
/// <summary> /// <inheritdoc/>
/// Gets the World row for the local character's current world.
/// </summary>
public RowRef<World> CurrentWorld public RowRef<World> CurrentWorld
{ {
get get
@ -54,9 +40,7 @@ internal unsafe partial class PlayerState : IInternalDisposableService, IPlayerS
} }
} }
/// <summary> /// <inheritdoc/>
/// Gets the World row for the local character's home world.
/// </summary>
public RowRef<World> HomeWorld public RowRef<World> HomeWorld
{ {
get get
@ -68,109 +52,67 @@ internal unsafe partial class PlayerState : IInternalDisposableService, IPlayerS
} }
} }
/// <summary> /// <inheritdoc/>
/// Gets the sex of the local character.
/// </summary>
public Sex Sex => this.IsLoaded ? (Sex)CSPlayerState.Instance()->Sex : default; public Sex Sex => this.IsLoaded ? (Sex)CSPlayerState.Instance()->Sex : default;
/// <summary> /// <inheritdoc/>
/// Gets the Race row for the local character.
/// </summary>
public RowRef<Race> Race => this.IsLoaded ? LuminaUtils.CreateRef<Race>(CSPlayerState.Instance()->Race) : default; public RowRef<Race> Race => this.IsLoaded ? LuminaUtils.CreateRef<Race>(CSPlayerState.Instance()->Race) : default;
/// <summary> /// <inheritdoc/>
/// Gets the Tribe row for the local character.
/// </summary>
public RowRef<Tribe> Tribe => this.IsLoaded ? LuminaUtils.CreateRef<Tribe>(CSPlayerState.Instance()->Tribe) : default; public RowRef<Tribe> Tribe => this.IsLoaded ? LuminaUtils.CreateRef<Tribe>(CSPlayerState.Instance()->Tribe) : default;
/// <summary> /// <inheritdoc/>
/// Gets the ClassJob row for the local character's current class/job.
/// </summary>
public RowRef<ClassJob> ClassJob => this.IsLoaded ? LuminaUtils.CreateRef<ClassJob>(CSPlayerState.Instance()->CurrentClassJobId) : default; public RowRef<ClassJob> ClassJob => this.IsLoaded ? LuminaUtils.CreateRef<ClassJob>(CSPlayerState.Instance()->CurrentClassJobId) : default;
/// <summary> /// <inheritdoc/>
/// Gets the current class/job's level of the local character.
/// </summary>
public short Level => this.IsLoaded ? CSPlayerState.Instance()->CurrentLevel : default; public short Level => this.IsLoaded ? CSPlayerState.Instance()->CurrentLevel : default;
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether the local character's level is synced.
/// </summary>
public bool IsLevelSynced => this.IsLoaded && CSPlayerState.Instance()->IsLevelSynced == 1; public bool IsLevelSynced => this.IsLoaded && CSPlayerState.Instance()->IsLevelSynced == 1;
/// <summary> /// <inheritdoc/>
/// Gets the effective level of the local character.
/// </summary>
public short EffectiveLevel => this.IsLoaded ? (this.IsLevelSynced ? CSPlayerState.Instance()->SyncedLevel : CSPlayerState.Instance()->CurrentLevel) : default; public short EffectiveLevel => this.IsLoaded ? (this.IsLevelSynced ? CSPlayerState.Instance()->SyncedLevel : CSPlayerState.Instance()->CurrentLevel) : default;
/// <summary> /// <inheritdoc/>
/// Gets the GuardianDeity row for the local character.
/// </summary>
public RowRef<GuardianDeity> GuardianDeity => this.IsLoaded ? LuminaUtils.CreateRef<GuardianDeity>(CSPlayerState.Instance()->GuardianDeity) : default; public RowRef<GuardianDeity> GuardianDeity => this.IsLoaded ? LuminaUtils.CreateRef<GuardianDeity>(CSPlayerState.Instance()->GuardianDeity) : default;
/// <summary> /// <inheritdoc/>
/// Gets the birth month of the local character.
/// </summary>
public byte BirthMonth => this.IsLoaded ? CSPlayerState.Instance()->BirthMonth : default; public byte BirthMonth => this.IsLoaded ? CSPlayerState.Instance()->BirthMonth : default;
/// <summary> /// <inheritdoc/>
/// Gets the birth day of the local character.
/// </summary>
public byte BirthDay => this.IsLoaded ? CSPlayerState.Instance()->BirthDay : default; public byte BirthDay => this.IsLoaded ? CSPlayerState.Instance()->BirthDay : default;
/// <summary> /// <inheritdoc/>
/// Gets the ClassJob row for the local character's starting class.
/// </summary>
public RowRef<ClassJob> FirstClass => this.IsLoaded ? LuminaUtils.CreateRef<ClassJob>(CSPlayerState.Instance()->FirstClass) : default; public RowRef<ClassJob> FirstClass => this.IsLoaded ? LuminaUtils.CreateRef<ClassJob>(CSPlayerState.Instance()->FirstClass) : default;
/// <summary> /// <inheritdoc/>
/// Gets the Town row for the local character's starting town.
/// </summary>
public RowRef<Town> StartTown => this.IsLoaded ? LuminaUtils.CreateRef<Town>(CSPlayerState.Instance()->StartTown) : default; public RowRef<Town> StartTown => this.IsLoaded ? LuminaUtils.CreateRef<Town>(CSPlayerState.Instance()->StartTown) : default;
/// <summary> /// <inheritdoc/>
/// Gets the base strength of the local character.
/// </summary>
public int BaseStrength => this.IsLoaded ? CSPlayerState.Instance()->BaseStrength : default; public int BaseStrength => this.IsLoaded ? CSPlayerState.Instance()->BaseStrength : default;
/// <summary> /// <inheritdoc/>
/// Gets the base dexterity of the local character.
/// </summary>
public int BaseDexterity => this.IsLoaded ? CSPlayerState.Instance()->BaseDexterity : default; public int BaseDexterity => this.IsLoaded ? CSPlayerState.Instance()->BaseDexterity : default;
/// <summary> /// <inheritdoc/>
/// Gets the base vitality of the local character.
/// </summary>
public int BaseVitality => this.IsLoaded ? CSPlayerState.Instance()->BaseVitality : default; public int BaseVitality => this.IsLoaded ? CSPlayerState.Instance()->BaseVitality : default;
/// <summary> /// <inheritdoc/>
/// Gets the base intelligence of the local character.
/// </summary>
public int BaseIntelligence => this.IsLoaded ? CSPlayerState.Instance()->BaseIntelligence : default; public int BaseIntelligence => this.IsLoaded ? CSPlayerState.Instance()->BaseIntelligence : default;
/// <summary> /// <inheritdoc/>
/// Gets the base mind of the local character.
/// </summary>
public int BaseMind => this.IsLoaded ? CSPlayerState.Instance()->BaseMind : default; public int BaseMind => this.IsLoaded ? CSPlayerState.Instance()->BaseMind : default;
/// <summary> /// <inheritdoc/>
/// Gets the piety mind of the local character.
/// </summary>
public int BasePiety => this.IsLoaded ? CSPlayerState.Instance()->BasePiety : default; public int BasePiety => this.IsLoaded ? CSPlayerState.Instance()->BasePiety : default;
/// <summary> /// <inheritdoc/>
/// Gets the GrandCompany row for the local character's current Grand Company affiliation.
/// </summary>
public RowRef<GrandCompany> GrandCompany => this.IsLoaded ? LuminaUtils.CreateRef<GrandCompany>(CSPlayerState.Instance()->GrandCompany) : default; public RowRef<GrandCompany> GrandCompany => this.IsLoaded ? LuminaUtils.CreateRef<GrandCompany>(CSPlayerState.Instance()->GrandCompany) : default;
/// <summary> /// <inheritdoc/>
/// Gets the Aetheryte row for the local character's home aetheryte.
/// </summary>
public RowRef<Aetheryte> HomeAetheryte => this.IsLoaded ? LuminaUtils.CreateRef<Aetheryte>(CSPlayerState.Instance()->HomeAetheryteId) : default; public RowRef<Aetheryte> HomeAetheryte => this.IsLoaded ? LuminaUtils.CreateRef<Aetheryte>(CSPlayerState.Instance()->HomeAetheryteId) : default;
/// <summary> /// <inheritdoc/>
/// Gets a span of Aetheryte rows for the local character's favourite aetherytes.
/// </summary>
public ReadOnlySpan<RowRef<Aetheryte>> FavouriteAetherytes public ReadOnlySpan<RowRef<Aetheryte>> FavouriteAetherytes
{ {
get get
@ -189,43 +131,25 @@ internal unsafe partial class PlayerState : IInternalDisposableService, IPlayerS
} }
} }
/// <summary> /// <inheritdoc/>
/// Gets the Aetheryte row for the local character's free aetheryte.
/// </summary>
public RowRef<Aetheryte> FreeAetheryte => this.IsLoaded ? LuminaUtils.CreateRef<Aetheryte>(CSPlayerState.Instance()->FreeAetheryteId) : default; public RowRef<Aetheryte> FreeAetheryte => this.IsLoaded ? LuminaUtils.CreateRef<Aetheryte>(CSPlayerState.Instance()->FreeAetheryteId) : default;
/// <summary> /// <inheritdoc/>
/// Gets the amount of received player commendations of the local character.
/// </summary>
public uint BaseRestedExperience => this.IsLoaded ? CSPlayerState.Instance()->BaseRestedExperience : default; public uint BaseRestedExperience => this.IsLoaded ? CSPlayerState.Instance()->BaseRestedExperience : default;
/// <summary> /// <inheritdoc/>
/// Gets the amount of received player commendations of the local character.
/// </summary>
public short PlayerCommendations => this.IsLoaded ? CSPlayerState.Instance()->PlayerCommendations : default; public short PlayerCommendations => this.IsLoaded ? CSPlayerState.Instance()->PlayerCommendations : default;
/// <summary> /// <inheritdoc/>
/// Gets the Carrier Level of Delivery Moogle Quests of the local character.
/// </summary>
public byte DeliveryLevel => this.IsLoaded ? CSPlayerState.Instance()->DeliveryLevel : default; public byte DeliveryLevel => this.IsLoaded ? CSPlayerState.Instance()->DeliveryLevel : default;
/// <summary> /// <inheritdoc/>
/// Gets the mentor version of the local character.
/// </summary>
public MentorVersion MentorVersion => this.IsLoaded ? (MentorVersion)CSPlayerState.Instance()->MentorVersion : default; public MentorVersion MentorVersion => this.IsLoaded ? (MentorVersion)CSPlayerState.Instance()->MentorVersion : default;
/// <summary> /// <inheritdoc/>
/// Gets the value of an attribute of the local character.
/// </summary>
/// <param name="attribute">The attribute to check.</param>
/// <returns>The value of the specific attribute.</returns>
public int GetAttribute(PlayerAttribute attribute) => this.IsLoaded ? CSPlayerState.Instance()->Attributes[(int)attribute] : default; public int GetAttribute(PlayerAttribute attribute) => this.IsLoaded ? CSPlayerState.Instance()->Attributes[(int)attribute] : default;
/// <summary> /// <inheritdoc/>
/// Gets the Grand Company rank of the local character.
/// </summary>
/// <param name="grandCompany">The Grand Company to check.</param>
/// <returns>The Grand Company rank of the local character.</returns>
public byte GetGrandCompanyRank(GrandCompany grandCompany) public byte GetGrandCompanyRank(GrandCompany grandCompany)
{ {
var playerState = CSPlayerState.Instance(); var playerState = CSPlayerState.Instance();
@ -241,18 +165,10 @@ internal unsafe partial class PlayerState : IInternalDisposableService, IPlayerS
}; };
} }
/// <summary> /// <inheritdoc/>
/// Gets the level of the local character's class/job.
/// </summary>
/// <param name="classJob">The ClassJob row to check.</param>
/// <returns>The level of the requested class/job.</returns>
public short GetClassJobLevel(ClassJob classJob) => this.IsLoaded ? CSPlayerState.Instance()->ClassJobLevels[classJob.ExpArrayIndex] : default; public short GetClassJobLevel(ClassJob classJob) => this.IsLoaded ? CSPlayerState.Instance()->ClassJobLevels[classJob.ExpArrayIndex] : default;
/// <summary> /// <inheritdoc/>
/// Gets the experience of the local character's class/job.
/// </summary>
/// <param name="classJob">The ClassJob row to check.</param>
/// <returns>The experience of the requested class/job.</returns>
public int GetClassJobExperience(ClassJob classJob) public int GetClassJobExperience(ClassJob classJob)
{ {
var playerState = CSPlayerState.Instance(); var playerState = CSPlayerState.Instance();
@ -262,11 +178,7 @@ internal unsafe partial class PlayerState : IInternalDisposableService, IPlayerS
return playerState->ClassJobExperience[classJob.ExpArrayIndex]; return playerState->ClassJobExperience[classJob.ExpArrayIndex];
} }
/// <summary> /// <inheritdoc/>
/// Gets the desynthesis level of the local character's crafter job.
/// </summary>
/// <param name="classJob">The ClassJob row to check.</param>
/// <returns>The desynthesis level of the requested crafter job.</returns>
public float GetDesynthesisLevel(ClassJob classJob) public float GetDesynthesisLevel(ClassJob classJob)
{ {
if (classJob.ExpArrayIndex == -1) if (classJob.ExpArrayIndex == -1)