Compare commits

...

32 commits

Author SHA1 Message Date
goat
1822ef1808
Merge pull request #2466 from Haselnussbomber/playerstate-ctor-fix
Some checks failed
Build Dalamud / Build on Windows (push) Waiting to run
Build Dalamud / Check API Compatibility (push) Blocked by required conditions
Build Dalamud / Deploy dalamud-distrib staging (push) Blocked by required conditions
Rollup changes to next version / check (api14) (push) Failing after 4s
Tag Build / Tag Build (push) Successful in 2s
Add empty ServiceConstructor to PlayerState
2025-11-17 21:07:10 +01:00
Haselnussbomber
cb441631e1
Add empty ServiceConstructor to PlayerState 2025-11-17 20:58:14 +01:00
goat
05f31265eb
Merge pull request #2422 from Haselnussbomber/playerstate-service
Add IPlayerState service
2025-11-17 20:28:01 +01:00
Haselnussbomber
64d4f7061a
Rename namespace PlayerState to Player 2025-11-17 19:29:48 +01:00
goat
a88247bdfc
Merge pull request #2454 from goatcorp/csupdate-master
[master] Update ClientStructs
2025-11-17 19:17:51 +01:00
goat
596af24e95
Merge pull request #2421 from Haselnussbomber/unlockstate-service
Add IUnlockState service
2025-11-17 18:42:49 +01:00
github-actions[bot]
750fa58147 Update ClientStructs
Some checks are pending
Build Dalamud / Build on Windows (push) Waiting to run
Build Dalamud / Check API Compatibility (push) Blocked by required conditions
Build Dalamud / Deploy dalamud-distrib staging (push) Blocked by required conditions
2025-11-17 12:52:07 +00:00
Haselnussbomber
497e61f699
Remove comment about removed CS enum 2025-11-08 11:58:54 +01:00
Haselnussbomber
5cc327c5f9
Fix obsolete 2025-11-08 11:49:23 +01:00
Haselnussbomber
af8b61f08a
Update to use AgentUpdate event 2025-11-08 11:49:04 +01:00
Haselnussbomber
700aaa4a5d
Fix Unlock event not firing 2025-11-08 11:45:02 +01:00
Haselnussbomber
69caffeb97
Add support for EmjCostume rows 2025-11-08 11:45:02 +01:00
Haselnussbomber
a06c0e3ed2
Add support for EmjVoiceNpc rows 2025-11-08 11:45:01 +01:00
Haselnussbomber
880add5ab3
Add support for MKDLore rows 2025-11-08 11:45:01 +01:00
Haselnussbomber
193d321103
Add support for Soul Shard items 2025-11-08 11:45:01 +01:00
Haselnussbomber
6e8efabc3b
Add support for Occult Record items 2025-11-08 11:45:01 +01:00
Haselnussbomber
68c02caf37
Fix obsolete warnings 2025-11-08 11:45:01 +01:00
Haselnussbomber
878080d660
Fix IsChocoboTaxiStandUnlocked call 2025-11-08 11:45:00 +01:00
Haselnussbomber
986dfa04d0
Mark IUnlockState as experimental 2025-11-08 11:45:00 +01:00
Haselnussbomber
3746c47a84
Ignore RecipeData updates when not logged in
Just to be safe...
2025-11-08 11:45:00 +01:00
Haselnussbomber
c4dd75bdda
Update RecipeData when levels changed 2025-11-08 11:45:00 +01:00
Haselnussbomber
5905afdf10
Cache completed Quests in RecipeData too 2025-11-08 11:45:00 +01:00
Haselnussbomber
62fdd2c60d
Fix IsChocoboTaxiStandUnlocked 2025-11-08 11:45:00 +01:00
Haselnussbomber
ba159f8c5f
Add IsRecipeUnlocked 2025-11-08 11:44:59 +01:00
Haselnussbomber
6ade5b21cf
Add IUnlockState service 2025-11-08 11:44:59 +01:00
Haselnussbomber
2cf869872d
Return IReadOnlyList instead of ReadOnlySpan 2025-10-06 02:08:18 +02:00
Haselnussbomber
bcf651b5c1
Fix FavoriteAetherytes 2025-10-06 01:38:35 +02:00
Haselnussbomber
a55c8ca773
Fix warning 2025-10-05 14:38:50 +02:00
Haselnussbomber
153870a053
Add mentor states 2025-10-05 14:37:22 +02:00
Haselnussbomber
c2fc04c3a8
Improve wording 2025-10-05 14:37:11 +02:00
Haselnussbomber
8cac486249
Add PluginInterface attribute to PlayerState 2025-10-05 14:36:55 +02:00
Haselnussbomber
4422622e1e
Add IPlayerState service 2025-10-05 13:49:25 +02:00
30 changed files with 2681 additions and 115 deletions

View file

@ -77,7 +77,7 @@ internal partial class ChatHandlers : IServiceType
}
// For injections while logged in
if (clientState.LocalPlayer != null && clientState.TerritoryType == 0 && !this.hasSeenLoadingMsg)
if (clientState.IsLoggedIn && clientState.TerritoryType == 0 && !this.hasSeenLoadingMsg)
this.PrintWelcomeMessage();
#if !DEBUG && false

View file

@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using Dalamud.Game.ClientState.Objects;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
@ -22,7 +23,7 @@ namespace Dalamud.Game.ClientState.Aetherytes;
internal sealed unsafe partial class AetheryteList : IServiceType, IAetheryteList
{
[ServiceManager.ServiceDependency]
private readonly ClientState clientState = Service<ClientState>.Get();
private readonly ObjectTable objectTable = Service<ObjectTable>.Get();
private readonly Telepo* telepoInstance = Telepo.Instance();
@ -37,7 +38,7 @@ internal sealed unsafe partial class AetheryteList : IServiceType, IAetheryteLis
{
get
{
if (this.clientState.LocalPlayer == null)
if (this.objectTable.LocalPlayer == null)
return 0;
this.Update();
@ -59,7 +60,7 @@ internal sealed unsafe partial class AetheryteList : IServiceType, IAetheryteLis
return null;
}
if (this.clientState.LocalPlayer == null)
if (this.objectTable.LocalPlayer == null)
return null;
return new AetheryteEntry(this.telepoInstance->TeleportList[index]);
@ -69,7 +70,7 @@ internal sealed unsafe partial class AetheryteList : IServiceType, IAetheryteLis
private void Update()
{
// this is very very important as otherwise it crashes
if (this.clientState.LocalPlayer == null)
if (this.objectTable.LocalPlayer == null)
return;
this.telepoInstance->UpdateAetheryteList();

View file

@ -2,11 +2,13 @@ using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Dalamud.Game.Player;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using CSBuddy = FFXIVClientStructs.FFXIV.Client.Game.UI.Buddy;
using CSUIState = FFXIVClientStructs.FFXIV.Client.Game.UI.UIState;
namespace Dalamud.Game.ClientState.Buddy;
@ -24,7 +26,7 @@ internal sealed partial class BuddyList : IServiceType, IBuddyList
private const uint InvalidObjectID = 0xE0000000;
[ServiceManager.ServiceDependency]
private readonly ClientState clientState = Service<ClientState>.Get();
private readonly PlayerState playerState = Service<PlayerState>.Get();
[ServiceManager.ServiceConstructor]
private BuddyList()
@ -69,7 +71,7 @@ internal sealed partial class BuddyList : IServiceType, IBuddyList
}
}
private unsafe FFXIVClientStructs.FFXIV.Client.Game.UI.Buddy* BuddyListStruct => &UIState.Instance()->Buddy;
private unsafe CSBuddy* BuddyListStruct => &CSUIState.Instance()->Buddy;
/// <inheritdoc/>
public IBuddyMember? this[int index]
@ -105,10 +107,10 @@ internal sealed partial class BuddyList : IServiceType, IBuddyList
/// <inheritdoc/>
public IBuddyMember? CreateBuddyMemberReference(IntPtr address)
{
if (this.clientState.LocalContentId == 0)
if (address == IntPtr.Zero)
return null;
if (address == IntPtr.Zero)
if (!this.playerState.IsLoaded)
return null;
var buddy = new BuddyMember(address);

View file

@ -6,6 +6,7 @@ using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.Gui;
using Dalamud.Game.Network.Internal;
using Dalamud.Game.Player;
using Dalamud.Hooking;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
@ -15,7 +16,6 @@ using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Application.Network;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.Network;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
@ -23,6 +23,7 @@ using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using Lumina.Excel.Sheets;
using Action = System.Action;
using CSUIState = FFXIVClientStructs.FFXIV.Client.Game.UI.UIState;
namespace Dalamud.Game.ClientState;
@ -46,6 +47,12 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
[ServiceManager.ServiceDependency]
private readonly NetworkHandlers networkHandlers = Service<NetworkHandlers>.Get();
[ServiceManager.ServiceDependency]
private readonly PlayerState playerState = Service<PlayerState>.Get();
[ServiceManager.ServiceDependency]
private readonly ObjectTable objectTable = Service<ObjectTable>.Get();
private Hook<LogoutCallbackInterface.Delegates.OnLogout> onLogoutHook;
private bool initialized;
private ushort territoryTypeId;
@ -184,10 +191,10 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
}
/// <inheritdoc/>
public IPlayerCharacter? LocalPlayer => Service<ObjectTable>.GetNullable()?[0] as IPlayerCharacter;
public IPlayerCharacter? LocalPlayer => this.objectTable.LocalPlayer;
/// <inheritdoc/>
public unsafe ulong LocalContentId => PlayerState.Instance()->ContentId;
public unsafe ulong LocalContentId => this.playerState.ContentId;
/// <inheritdoc/>
public unsafe bool IsLoggedIn
@ -241,7 +248,7 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
public bool IsClientIdle(out ConditionFlag blockingFlag)
{
blockingFlag = 0;
if (this.LocalPlayer is null) return true;
if (this.objectTable.LocalPlayer is null) return true;
var condition = Service<Conditions.Condition>.GetNullable();
@ -280,7 +287,7 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
this.TerritoryType = (ushort)GameMain.Instance()->CurrentTerritoryTypeId;
this.MapId = AgentMap.Instance()->CurrentMapId;
this.Instance = UIState.Instance()->PublicInstance.InstanceId;
this.Instance = CSUIState.Instance()->PublicInstance.InstanceId;
this.initialized = true;
@ -369,7 +376,7 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
if (condition == null || gameGui == null || data == null)
return;
if (condition.Any() && this.lastConditionNone && this.LocalPlayer != null)
if (condition.Any() && this.lastConditionNone && this.objectTable.LocalPlayer != null)
{
Log.Debug("Is login");
this.lastConditionNone = false;

View file

@ -1,6 +1,7 @@
using System.Numerics;
using Dalamud.Data;
using Dalamud.Game.Player;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Memory;
@ -150,15 +151,11 @@ internal unsafe partial class Fate
/// <returns>True or false.</returns>
public static bool IsValid(Fate fate)
{
var clientState = Service<ClientState>.GetNullable();
if (fate == null || clientState == null)
if (fate == null)
return false;
if (clientState.LocalContentId == 0)
return false;
return true;
var playerState = Service<PlayerState>.Get();
return playerState.IsLoaded == true;
}
/// <summary>

View file

@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using Dalamud.Game.Player;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
@ -60,15 +61,11 @@ internal sealed partial class FateTable : IServiceType, IFateTable
/// <inheritdoc/>
public bool IsValid(IFate fate)
{
var clientState = Service<ClientState>.GetNullable();
if (fate == null || clientState == null)
if (fate == null)
return false;
if (clientState.LocalContentId == 0)
return false;
return true;
var playerState = Service<PlayerState>.Get();
return playerState.IsLoaded == true;
}
/// <inheritdoc/>
@ -87,12 +84,11 @@ internal sealed partial class FateTable : IServiceType, IFateTable
/// <inheritdoc/>
public IFate? CreateFateReference(IntPtr offset)
{
var clientState = Service<ClientState>.Get();
if (clientState.LocalContentId == 0)
if (offset == IntPtr.Zero)
return null;
if (offset == IntPtr.Zero)
var playerState = Service<PlayerState>.Get();
if (!playerState.IsLoaded)
return null;
return new Fate(offset);

View file

@ -5,6 +5,7 @@ using System.Runtime.CompilerServices;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Player;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
@ -31,16 +32,16 @@ internal sealed partial class ObjectTable : IServiceType, IObjectTable
{
private static int objectTableLength;
private readonly ClientState clientState;
[ServiceManager.ServiceDependency]
private readonly PlayerState playerState = Service<PlayerState>.Get();
private readonly CachedEntry[] cachedObjectTable;
private readonly Enumerator?[] frameworkThreadEnumerators = new Enumerator?[4];
[ServiceManager.ServiceConstructor]
private unsafe ObjectTable(ClientState clientState)
private unsafe ObjectTable()
{
this.clientState = clientState;
var nativeObjectTable = CSGameObjectManager.Instance()->Objects.IndexSorted;
objectTableLength = nativeObjectTable.Length;
@ -66,6 +67,9 @@ internal sealed partial class ObjectTable : IServiceType, IObjectTable
/// <inheritdoc/>
public int Length => objectTableLength;
/// <inheritdoc/>
public IPlayerCharacter? LocalPlayer => this[0] as IPlayerCharacter;
/// <inheritdoc/>
public IEnumerable<IBattleChara> PlayerObjects => this.GetPlayerObjects();
@ -142,10 +146,10 @@ internal sealed partial class ObjectTable : IServiceType, IObjectTable
{
ThreadSafety.AssertMainThread();
if (this.clientState.LocalContentId == 0)
if (address == nint.Zero)
return null;
if (address == nint.Zero)
if (!this.playerState.IsLoaded)
return null;
var obj = (CSGameObject*)address;

View file

@ -1,9 +1,8 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.Player;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Memory;
namespace Dalamud.Game.ClientState.Objects.Types;
@ -170,15 +169,11 @@ internal partial class GameObject
/// <returns>True or false.</returns>
public static bool IsValid(IGameObject? actor)
{
var clientState = Service<ClientState>.GetNullable();
if (actor is null || clientState == null)
if (actor == null)
return false;
if (clientState.LocalContentId == 0)
return false;
return true;
var playerState = Service<PlayerState>.Get();
return playerState.IsLoaded == true;
}
/// <summary>

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Dalamud.Game.Player;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
@ -25,7 +26,7 @@ internal sealed unsafe partial class PartyList : IServiceType, IPartyList
private const int AllianceLength = 20;
[ServiceManager.ServiceDependency]
private readonly ClientState clientState = Service<ClientState>.Get();
private readonly PlayerState playerState = Service<PlayerState>.Get();
[ServiceManager.ServiceConstructor]
private PartyList()
@ -91,10 +92,7 @@ internal sealed unsafe partial class PartyList : IServiceType, IPartyList
/// <inheritdoc/>
public IPartyMember? CreatePartyMemberReference(IntPtr address)
{
if (this.clientState.LocalContentId == 0)
return null;
if (address == IntPtr.Zero)
if (address == IntPtr.Zero || !this.playerState.IsLoaded)
return null;
return new PartyMember(address);
@ -112,10 +110,7 @@ internal sealed unsafe partial class PartyList : IServiceType, IPartyList
/// <inheritdoc/>
public IPartyMember? CreateAllianceMemberReference(IntPtr address)
{
if (this.clientState.LocalContentId == 0)
return null;
if (address == IntPtr.Zero)
if (address == IntPtr.Zero || !this.playerState.IsLoaded)
return null;
return new PartyMember(address);

View file

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Dalamud.Game.Player;
namespace Dalamud.Game.ClientState.Statuses;
/// <summary>
@ -66,15 +68,14 @@ public sealed unsafe partial class StatusList
/// <returns>The status object containing the requested data.</returns>
public static StatusList? CreateStatusListReference(IntPtr address)
{
if (address == IntPtr.Zero)
return null;
// The use case for CreateStatusListReference and CreateStatusReference to be static is so
// fake status lists can be generated. Since they aren't exposed as services, it's either
// here or somewhere else.
var clientState = Service<ClientState>.Get();
if (clientState.LocalContentId == 0)
return null;
if (address == IntPtr.Zero)
var playerState = Service<PlayerState>.Get();
if (!playerState.IsLoaded)
return null;
return new StatusList(address);
@ -87,12 +88,11 @@ public sealed unsafe partial class StatusList
/// <returns>The status object containing the requested data.</returns>
public static Status? CreateStatusReference(IntPtr address)
{
var clientState = Service<ClientState>.Get();
if (clientState.LocalContentId == 0)
if (address == IntPtr.Zero)
return null;
if (address == IntPtr.Zero)
var playerState = Service<PlayerState>.Get();
if (!playerState.IsLoaded)
return null;
return new Status(address);

View file

@ -11,18 +11,18 @@ using Dalamud.Game.Gui;
using Dalamud.Game.Network.Internal.MarketBoardUploaders;
using Dalamud.Game.Network.Internal.MarketBoardUploaders.Universalis;
using Dalamud.Game.Network.Structures;
using Dalamud.Game.Player;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Hooking;
using Dalamud.Networking.Http;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Game.Control;
using FFXIVClientStructs.FFXIV.Client.Game.InstanceContent;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.Network;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Client.UI.Info;
using Lumina.Excel.Sheets;
using Serilog;
namespace Dalamud.Game.Network.Internal;
@ -269,29 +269,8 @@ internal unsafe class NetworkHandlers : IInternalDisposableService
private static (ulong UploaderId, uint WorldId) GetUploaderInfo()
{
var agentLobby = AgentLobby.Instance();
var uploaderId = agentLobby->LobbyData.ContentId;
if (uploaderId == 0)
{
var playerState = PlayerState.Instance();
if (playerState->IsLoaded)
{
uploaderId = playerState->ContentId;
}
}
var worldId = agentLobby->LobbyData.CurrentWorldId;
if (worldId == 0)
{
var localPlayer = Control.GetLocalPlayer();
if (localPlayer != null)
{
worldId = localPlayer->CurrentWorld;
}
}
return (uploaderId, worldId);
var playerState = Service<PlayerState>.Get();
return (playerState.ContentId, playerState.CurrentWorld.RowId);
}
private unsafe nint CfPopDetour(PublicContentDirector.EnterContentInfoPacket* packetData)

View file

@ -0,0 +1,27 @@
namespace Dalamud.Game.Player;
/// <summary>
/// Specifies the mentor certification version for a player.
/// </summary>
public enum MentorVersion : byte
{
/// <summary>
/// Indicates that the player has never held mentor status in any expansion.
/// </summary>
None = 0,
/// <summary>
/// Indicates that the player was last a mentor during the <c>Shadowbringers</c> expansion.
/// </summary>
Shadowbringers = 1,
/// <summary>
/// Indicates that the player was last a mentor during the <c>Endwalker</c> expansion.
/// </summary>
Endwalker = 2,
/// <summary>
/// Indicates that the player was last a mentor during the <c>Dawntrail</c> expansion.
/// </summary>
Dawntrail = 3,
}

View file

@ -0,0 +1,489 @@
namespace Dalamud.Game.Player;
/// <summary>
/// Represents a player's attribute.
/// </summary>
public enum PlayerAttribute
{
/// <summary>
/// Strength.
/// </summary>
/// <remarks>
/// Affects physical damage dealt by gladiator's arms, marauder's arms, dark knight's arms, gunbreaker's arms, pugilist's arms, lancer's arms, samurai's arms, reaper's arms, thaumaturge's arms, arcanist's arms, red mage's arms, pictomancer's arms, conjurer's arms, astrologian's arms, sage's arms, and blue mage's arms.
/// </remarks>
Strength = 1,
/// <summary>
/// Dexterity.
/// </summary>
/// <remarks>
/// Affects physical damage dealt by rogue's arms, viper's arms, archer's arms, machinist's arms, and dancer's arms.
/// </remarks>
Dexterity = 2,
/// <summary>
/// Vitality.
/// </summary>
/// <remarks>
/// Affects maximum HP.
/// </remarks>
Vitality = 3,
/// <summary>
/// Intelligence.
/// </summary>
/// <remarks>
/// Affects attack magic potency when role is DPS.
/// </remarks>
Intelligence = 4,
/// <summary>
/// Mind.
/// </summary>
/// <remarks>
/// Affects healing magic potency. Also affects attack magic potency when role is Healer.
/// </remarks>
Mind = 5,
/// <summary>
/// Piety.
/// </summary>
/// <remarks>
/// Affects MP regeneration. Regeneration rate is determined by piety. Only applicable when in battle and role is Healer.
/// </remarks>
Piety = 6,
/// <summary>
/// Health Points.
/// </summary>
HP = 7,
/// <summary>
/// Mana Points.
/// </summary>
MP = 8,
/// <summary>
/// Tactical Points.
/// </summary>
TP = 9,
/// <summary>
/// Gathering Point.
/// </summary>
GP = 10,
/// <summary>
/// Crafting Points.
/// </summary>
CP = 11,
/// <summary>
/// Physical Damage.
/// </summary>
PhysicalDamage = 12,
/// <summary>
/// Magic Damage.
/// </summary>
MagicDamage = 13,
/// <summary>
/// Delay.
/// </summary>
Delay = 14,
/// <summary>
/// Additional Effect.
/// </summary>
AdditionalEffect = 15,
/// <summary>
/// Attack Speed.
/// </summary>
AttackSpeed = 16,
/// <summary>
/// Block Rate.
/// </summary>
BlockRate = 17,
/// <summary>
/// Block Strength.
/// </summary>
BlockStrength = 18,
/// <summary>
/// Tenacity.
/// </summary>
/// <remarks>
/// Affects the amount of physical and magic damage dealt and received, as well as HP restored. The higher the value, the more damage dealt, the more HP restored, and the less damage taken. Only applicable when role is Tank.
/// </remarks>
Tenacity = 19,
/// <summary>
/// Attack Power.
/// </summary>
/// <remarks>
/// Affects amount of damage dealt by physical attacks. The higher the value, the more damage dealt.
/// </remarks>
AttackPower = 20,
/// <summary>
/// Defense.
/// </summary>
/// <remarks>
/// Affects the amount of damage taken by physical attacks. The higher the value, the less damage taken.
/// </remarks>
Defense = 21,
/// <summary>
/// Direct Hit Rate.
/// </summary>
/// <remarks>
/// Affects the rate at which your physical and magic attacks land direct hits, dealing slightly more damage than normal hits. The higher the value, the higher the frequency with which your hits will be direct. Higher values will also result in greater damage for actions which guarantee direct hits.
/// </remarks>
DirectHitRate = 22,
/// <summary>
/// Evasion.
/// </summary>
Evasion = 23,
/// <summary>
/// Magic Defense.
/// </summary>
/// <remarks>
/// Affects the amount of damage taken by magic attacks. The higher the value, the less damage taken.
/// </remarks>
MagicDefense = 24,
/// <summary>
/// Critical Hit Power.
/// </summary>
CriticalHitPower = 25,
/// <summary>
/// Critical Hit Resilience.
/// </summary>
CriticalHitResilience = 26,
/// <summary>
/// Critical Hit.
/// </summary>
/// <remarks>
/// Affects the amount of physical and magic damage dealt, as well as HP restored. The higher the value, the higher the frequency with which your hits will be critical/higher the potency of critical hits.
/// </remarks>
CriticalHit = 27,
/// <summary>
/// Critical Hit Evasion.
/// </summary>
CriticalHitEvasion = 28,
/// <summary>
/// Slashing Resistance.
/// </summary>
/// <remarks>
/// Decreases damage done by slashing attacks.
/// </remarks>
SlashingResistance = 29,
/// <summary>
/// Piercing Resistance.
/// </summary>
/// <remarks>
/// Decreases damage done by piercing attacks.
/// </remarks>
PiercingResistance = 30,
/// <summary>
/// Blunt Resistance.
/// </summary>
/// <remarks>
/// Decreases damage done by blunt attacks.
/// </remarks>
BluntResistance = 31,
/// <summary>
/// Projectile Resistance.
/// </summary>
ProjectileResistance = 32,
/// <summary>
/// Attack Magic Potency.
/// </summary>
/// <remarks>
/// Affects the amount of damage dealt by magic attacks.
/// </remarks>
AttackMagicPotency = 33,
/// <summary>
/// Healing Magic Potency.
/// </summary>
/// <remarks>
/// Affects the amount of HP restored via healing magic.
/// </remarks>
HealingMagicPotency = 34,
/// <summary>
/// Enhancement Magic Potency.
/// </summary>
EnhancementMagicPotency = 35,
/// <summary>
/// Elemental Bonus.
/// </summary>
ElementalBonus = 36,
/// <summary>
/// Fire Resistance.
/// </summary>
/// <remarks>
/// Decreases fire-aspected damage.
/// </remarks>
FireResistance = 37,
/// <summary>
/// Ice Resistance.
/// </summary>
/// <remarks>
/// Decreases ice-aspected damage.
/// </remarks>
IceResistance = 38,
/// <summary>
/// Wind Resistance.
/// </summary>
/// <remarks>
/// Decreases wind-aspected damage.
/// </remarks>
WindResistance = 39,
/// <summary>
/// Earth Resistance.
/// </summary>
/// <remarks>
/// Decreases earth-aspected damage.
/// </remarks>
EarthResistance = 40,
/// <summary>
/// Lightning Resistance.
/// </summary>
/// <remarks>
/// Decreases lightning-aspected damage.
/// </remarks>
LightningResistance = 41,
/// <summary>
/// Water Resistance.
/// </summary>
/// <remarks>
/// Decreases water-aspected damage.
/// </remarks>
WaterResistance = 42,
/// <summary>
/// Magic Resistance.
/// </summary>
MagicResistance = 43,
/// <summary>
/// Determination.
/// </summary>
/// <remarks>
/// Affects the amount of damage dealt by both physical and magic attacks, as well as the amount of HP restored by healing spells.
/// </remarks>
Determination = 44,
/// <summary>
/// Skill Speed.
/// </summary>
/// <remarks>
/// Affects both the casting and recast timers, as well as the damage over time potency for weaponskills and auto-attacks. The higher the value, the shorter the timers/higher the potency.
/// </remarks>
SkillSpeed = 45,
/// <summary>
/// Spell Speed.
/// </summary>
/// <remarks>
/// Affects both the casting and recast timers for spells. The higher the value, the shorter the timers. Also affects a spell's damage over time or healing over time potency.
/// </remarks>
SpellSpeed = 46,
/// <summary>
/// Haste.
/// </summary>
Haste = 47,
/// <summary>
/// Morale.
/// </summary>
/// <remarks>
/// In PvP, replaces physical and magical defense in determining damage inflicted by other players. Also influences the amount of damage dealt to other players.
/// </remarks>
Morale = 48,
/// <summary>
/// Enmity.
/// </summary>
Enmity = 49,
/// <summary>
/// Enmity Reduction.
/// </summary>
EnmityReduction = 50,
/// <summary>
/// Desynthesis Skill Gain.
/// </summary>
DesynthesisSkillGain = 51,
/// <summary>
/// EXP Bonus.
/// </summary>
EXPBonus = 52,
/// <summary>
/// Regen.
/// </summary>
Regen = 53,
/// <summary>
/// Special Attribute.
/// </summary>
SpecialAttribute = 54,
/// <summary>
/// Main Attribute.
/// </summary>
MainAttribute = 55,
/// <summary>
/// Secondary Attribute.
/// </summary>
SecondaryAttribute = 56,
/// <summary>
/// Slow Resistance.
/// </summary>
/// <remarks>
/// Shortens the duration of slow.
/// </remarks>
SlowResistance = 57,
/// <summary>
/// Petrification Resistance.
/// </summary>
PetrificationResistance = 58,
/// <summary>
/// Paralysis Resistance.
/// </summary>
ParalysisResistance = 59,
/// <summary>
/// Silence Resistance.
/// </summary>
/// <remarks>
/// Shortens the duration of silence.
/// </remarks>
SilenceResistance = 60,
/// <summary>
/// Blind Resistance.
/// </summary>
/// <remarks>
/// Shortens the duration of blind.
/// </remarks>
BlindResistance = 61,
/// <summary>
/// Poison Resistance.
/// </summary>
/// <remarks>
/// Shortens the duration of poison.
/// </remarks>
PoisonResistance = 62,
/// <summary>
/// Stun Resistance.
/// </summary>
/// <remarks>
/// Shortens the duration of stun.
/// </remarks>
StunResistance = 63,
/// <summary>
/// Sleep Resistance.
/// </summary>
/// <remarks>
/// Shortens the duration of sleep.
/// </remarks>
SleepResistance = 64,
/// <summary>
/// Bind Resistance.
/// </summary>
/// <remarks>
/// Shortens the duration of bind.
/// </remarks>
BindResistance = 65,
/// <summary>
/// Heavy Resistance.
/// </summary>
/// <remarks>
/// Shortens the duration of heavy.
/// </remarks>
HeavyResistance = 66,
/// <summary>
/// Doom Resistance.
/// </summary>
DoomResistance = 67,
/// <summary>
/// Reduced Durability Loss.
/// </summary>
ReducedDurabilityLoss = 68,
/// <summary>
/// Increased Spiritbond Gain.
/// </summary>
IncreasedSpiritbondGain = 69,
/// <summary>
/// Craftsmanship.
/// </summary>
/// <remarks>
/// Affects the amount of progress achieved in a single synthesis step.
/// </remarks>
Craftsmanship = 70,
/// <summary>
/// Control.
/// </summary>
/// <remarks>
/// Affects the amount of quality improved in a single synthesis step.
/// </remarks>
Control = 71,
/// <summary>
/// Gathering.
/// </summary>
/// <remarks>
/// Affects the rate at which items are gathered.
/// </remarks>
Gathering = 72,
/// <summary>
/// Perception.
/// </summary>
/// <remarks>
/// Affects item yield when gathering as a botanist or miner, and the size of fish when fishing or spearfishing.
/// </remarks>
Perception = 73,
}

View file

@ -0,0 +1,232 @@
using System.Collections.Generic;
using Dalamud.Data;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using CSPlayerState = FFXIVClientStructs.FFXIV.Client.Game.UI.PlayerState;
using GrandCompany = Lumina.Excel.Sheets.GrandCompany;
namespace Dalamud.Game.Player;
/// <summary>
/// This class contains the PlayerState wrappers.
/// </summary>
[PluginInterface]
[ServiceManager.EarlyLoadedService]
[ResolveVia<IPlayerState>]
internal unsafe class PlayerState : IServiceType, IPlayerState
{
[ServiceManager.ServiceConstructor]
private PlayerState()
{
}
/// <inheritdoc/>
public bool IsLoaded => CSPlayerState.Instance()->IsLoaded;
/// <inheritdoc/>
public string CharacterName => this.IsLoaded ? CSPlayerState.Instance()->CharacterNameString : string.Empty;
/// <inheritdoc/>
public uint EntityId => this.IsLoaded ? CSPlayerState.Instance()->EntityId : default;
/// <inheritdoc/>
public ulong ContentId => this.IsLoaded ? CSPlayerState.Instance()->ContentId : default;
/// <inheritdoc/>
public RowRef<World> CurrentWorld
{
get
{
var agentLobby = AgentLobby.Instance();
return agentLobby->IsLoggedIn
? LuminaUtils.CreateRef<World>(agentLobby->LobbyData.CurrentWorldId)
: default;
}
}
/// <inheritdoc/>
public RowRef<World> HomeWorld
{
get
{
var agentLobby = AgentLobby.Instance();
return agentLobby->IsLoggedIn
? LuminaUtils.CreateRef<World>(agentLobby->LobbyData.HomeWorldId)
: default;
}
}
/// <inheritdoc/>
public Sex Sex => this.IsLoaded ? (Sex)CSPlayerState.Instance()->Sex : default;
/// <inheritdoc/>
public RowRef<Race> Race => this.IsLoaded ? LuminaUtils.CreateRef<Race>(CSPlayerState.Instance()->Race) : default;
/// <inheritdoc/>
public RowRef<Tribe> Tribe => this.IsLoaded ? LuminaUtils.CreateRef<Tribe>(CSPlayerState.Instance()->Tribe) : default;
/// <inheritdoc/>
public RowRef<ClassJob> ClassJob => this.IsLoaded ? LuminaUtils.CreateRef<ClassJob>(CSPlayerState.Instance()->CurrentClassJobId) : default;
/// <inheritdoc/>
public short Level => this.IsLoaded ? CSPlayerState.Instance()->CurrentLevel : default;
/// <inheritdoc/>
public bool IsLevelSynced => this.IsLoaded && CSPlayerState.Instance()->IsLevelSynced;
/// <inheritdoc/>
public short EffectiveLevel => this.IsLoaded ? (this.IsLevelSynced ? CSPlayerState.Instance()->SyncedLevel : CSPlayerState.Instance()->CurrentLevel) : default;
/// <inheritdoc/>
public RowRef<GuardianDeity> GuardianDeity => this.IsLoaded ? LuminaUtils.CreateRef<GuardianDeity>(CSPlayerState.Instance()->GuardianDeity) : default;
/// <inheritdoc/>
public byte BirthMonth => this.IsLoaded ? CSPlayerState.Instance()->BirthMonth : default;
/// <inheritdoc/>
public byte BirthDay => this.IsLoaded ? CSPlayerState.Instance()->BirthDay : default;
/// <inheritdoc/>
public RowRef<ClassJob> FirstClass => this.IsLoaded ? LuminaUtils.CreateRef<ClassJob>(CSPlayerState.Instance()->FirstClass) : default;
/// <inheritdoc/>
public RowRef<Town> StartTown => this.IsLoaded ? LuminaUtils.CreateRef<Town>(CSPlayerState.Instance()->StartTown) : default;
/// <inheritdoc/>
public int BaseStrength => this.IsLoaded ? CSPlayerState.Instance()->BaseStrength : default;
/// <inheritdoc/>
public int BaseDexterity => this.IsLoaded ? CSPlayerState.Instance()->BaseDexterity : default;
/// <inheritdoc/>
public int BaseVitality => this.IsLoaded ? CSPlayerState.Instance()->BaseVitality : default;
/// <inheritdoc/>
public int BaseIntelligence => this.IsLoaded ? CSPlayerState.Instance()->BaseIntelligence : default;
/// <inheritdoc/>
public int BaseMind => this.IsLoaded ? CSPlayerState.Instance()->BaseMind : default;
/// <inheritdoc/>
public int BasePiety => this.IsLoaded ? CSPlayerState.Instance()->BasePiety : default;
/// <inheritdoc/>
public RowRef<GrandCompany> GrandCompany => this.IsLoaded ? LuminaUtils.CreateRef<GrandCompany>(CSPlayerState.Instance()->GrandCompany) : default;
/// <inheritdoc/>
public RowRef<Aetheryte> HomeAetheryte => this.IsLoaded ? LuminaUtils.CreateRef<Aetheryte>(CSPlayerState.Instance()->HomeAetheryteId) : default;
/// <inheritdoc/>
public IReadOnlyList<RowRef<Aetheryte>> FavoriteAetherytes
{
get
{
var playerState = CSPlayerState.Instance();
if (!playerState->IsLoaded)
return default;
var count = playerState->FavouriteAetheryteCount;
if (count == 0)
return default;
var array = new RowRef<Aetheryte>[count];
for (var i = 0; i < count; i++)
array[i] = LuminaUtils.CreateRef<Aetheryte>(playerState->FavouriteAetherytes[i]);
return array;
}
}
/// <inheritdoc/>
public RowRef<Aetheryte> FreeAetheryte => this.IsLoaded ? LuminaUtils.CreateRef<Aetheryte>(CSPlayerState.Instance()->FreeAetheryteId) : default;
/// <inheritdoc/>
public uint BaseRestedExperience => this.IsLoaded ? CSPlayerState.Instance()->BaseRestedExperience : default;
/// <inheritdoc/>
public short PlayerCommendations => this.IsLoaded ? CSPlayerState.Instance()->PlayerCommendations : default;
/// <inheritdoc/>
public byte DeliveryLevel => this.IsLoaded ? CSPlayerState.Instance()->DeliveryLevel : default;
/// <inheritdoc/>
public MentorVersion MentorVersion => this.IsLoaded ? (MentorVersion)CSPlayerState.Instance()->MentorVersion : default;
/// <inheritdoc/>
public bool IsMentor => this.IsLoaded && CSPlayerState.Instance()->IsMentor();
/// <inheritdoc/>
public bool IsBattleMentor => this.IsLoaded && CSPlayerState.Instance()->IsBattleMentor();
/// <inheritdoc/>
public bool IsTradeMentor => this.IsLoaded && CSPlayerState.Instance()->IsTradeMentor();
/// <inheritdoc/>
public bool IsNovice => this.IsLoaded && CSPlayerState.Instance()->IsNovice();
/// <inheritdoc/>
public bool IsReturner => this.IsLoaded && CSPlayerState.Instance()->IsReturner();
/// <inheritdoc/>
public int GetAttribute(PlayerAttribute attribute) => this.IsLoaded ? CSPlayerState.Instance()->Attributes[(int)attribute] : default;
/// <inheritdoc/>
public byte GetGrandCompanyRank(GrandCompany grandCompany)
{
if (!this.IsLoaded)
return default;
return grandCompany.RowId switch
{
1 => CSPlayerState.Instance()->GCRankMaelstrom,
2 => CSPlayerState.Instance()->GCRankTwinAdders,
3 => CSPlayerState.Instance()->GCRankImmortalFlames,
_ => default,
};
}
/// <inheritdoc/>
public short GetClassJobLevel(ClassJob classJob)
{
if (classJob.ExpArrayIndex == -1)
return default;
if (!this.IsLoaded)
return default;
return CSPlayerState.Instance()->ClassJobLevels[classJob.ExpArrayIndex];
}
/// <inheritdoc/>
public int GetClassJobExperience(ClassJob classJob)
{
if (classJob.ExpArrayIndex == -1)
return default;
if (!this.IsLoaded)
return default;
return CSPlayerState.Instance()->ClassJobExperience[classJob.ExpArrayIndex];
}
/// <inheritdoc/>
public float GetDesynthesisLevel(ClassJob classJob)
{
if (classJob.DohDolJobIndex == -1)
return default;
if (!this.IsLoaded)
return default;
return CSPlayerState.Instance()->DesynthesisLevels[classJob.DohDolJobIndex] / 100f;
}
}

View file

@ -0,0 +1,17 @@
namespace Dalamud.Game.Player;
/// <summary>
/// Represents the sex of a character.
/// </summary>
public enum Sex : byte
{
/// <summary>
/// Male sex.
/// </summary>
Male = 0,
/// <summary>
/// Female sex.
/// </summary>
Female = 1,
}

View file

@ -8,6 +8,7 @@ using Dalamud.Configuration.Internal;
using Dalamud.Data;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.Config;
using Dalamud.Game.Player;
using Dalamud.Game.Text.Evaluator.Internal;
using Dalamud.Game.Text.Noun;
using Dalamud.Game.Text.Noun.Enums;
@ -35,7 +36,6 @@ using Lumina.Text.Payloads;
using Lumina.Text.ReadOnly;
using AddonSheet = Lumina.Excel.Sheets.Addon;
using PlayerState = FFXIVClientStructs.FFXIV.Client.Game.UI.PlayerState;
using StatusSheet = Lumina.Excel.Sheets.Status;
namespace Dalamud.Game.Text.Evaluator;
@ -68,6 +68,9 @@ internal class SeStringEvaluator : IServiceType, ISeStringEvaluator
[ServiceManager.ServiceDependency]
private readonly SheetRedirectResolver sheetRedirectResolver = Service<SheetRedirectResolver>.Get();
[ServiceManager.ServiceDependency]
private readonly PlayerState playerState = Service<PlayerState>.Get();
private readonly ConcurrentDictionary<StringCacheKey<ActionKind>, string> actStrCache = [];
private readonly ConcurrentDictionary<StringCacheKey<ObjectKind>, string> objStrCache = [];
@ -564,7 +567,7 @@ internal class SeStringEvaluator : IServiceType, ISeStringEvaluator
return false;
// the game uses LocalPlayer here, but using PlayerState seems more safe.
return this.ResolveStringExpression(in context, PlayerState.Instance()->EntityId == entityId ? eTrue : eFalse);
return this.ResolveStringExpression(in context, this.playerState.EntityId == entityId ? eTrue : eFalse);
}
private bool TryResolveColor(in SeStringContext context, in ReadOnlySePayloadSpan payload)

View file

@ -0,0 +1,95 @@
using Lumina.Excel.Sheets;
namespace Dalamud.Game.UnlockState;
/// <summary>
/// Enum for <see cref="ItemAction.Type"/>.
/// </summary>
internal enum ItemActionType : ushort
{
/// <summary>
/// No item action.
/// </summary>
None = 0,
/// <summary>
/// Unlocks a companion (minion).
/// </summary>
Companion = 853,
/// <summary>
/// Unlocks a chocobo companion barding.
/// </summary>
BuddyEquip = 1013,
/// <summary>
/// Unlocks a mount.
/// </summary>
Mount = 1322,
/// <summary>
/// Unlocks recipes from a crafting recipe book.
/// </summary>
SecretRecipeBook = 2136,
/// <summary>
/// Unlocks various types of content (e.g. Riding Maps, Blue Mage Totems, Emotes, Hairstyles).
/// </summary>
UnlockLink = 2633,
/// <summary>
/// Unlocks a Triple Triad Card.
/// </summary>
TripleTriadCard = 3357,
/// <summary>
/// Unlocks gathering nodes of a Folklore Tome.
/// </summary>
FolkloreTome = 4107,
/// <summary>
/// Unlocks an Orchestrion Roll.
/// </summary>
OrchestrionRoll = 25183,
/// <summary>
/// Unlocks portrait designs.
/// </summary>
FramersKit = 29459,
/// <summary>
/// Unlocks Bozjan Field Notes.
/// </summary>
/// <remarks> These are server-side but are cached client-side. </remarks>
FieldNotes = 19743,
/// <summary>
/// Unlocks an Ornament (fashion accessory).
/// </summary>
Ornament = 20086,
/// <summary>
/// Unlocks Glasses.
/// </summary>
Glasses = 37312,
/// <summary>
/// Company Seal Vouchers, which convert the item into Company Seals when used.
/// </summary>
CompanySealVouchers = 41120,
/// <summary>
/// Unlocks Occult Records in Occult Crescent.
/// </summary>
OccultRecords = 43141,
/// <summary>
/// Unlocks Phantom Jobs in Occult Crescent.
/// </summary>
SoulShards = 43142,
/// <summary>
/// Star Contributor Certificate, which grants the Star Contributor status in Cosmic Exploration.
/// </summary>
StarContributorCertificate = 45189,
}

View file

@ -0,0 +1,283 @@
using System.Linq;
using CommunityToolkit.HighPerformance;
using Dalamud.Data;
using Dalamud.Game.Gui;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.Interop;
using Lumina.Excel.Sheets;
namespace Dalamud.Game.UnlockState;
/// <summary>
/// Represents recipe-related data for all crafting classes.
/// </summary>
[ServiceManager.EarlyLoadedService]
internal unsafe class RecipeData : IInternalDisposableService
{
[ServiceManager.ServiceDependency]
private readonly DataManager dataManager = Service<DataManager>.Get();
[ServiceManager.ServiceDependency]
private readonly ClientState.ClientState clientState = Service<ClientState.ClientState>.Get();
[ServiceManager.ServiceDependency]
private readonly GameGui gameGui = Service<GameGui>.Get();
private readonly ushort[] craftTypeLevels;
private readonly byte[] unlockedNoteBookDivisionsCount;
private readonly byte[] unlockedSecretNoteBookDivisionsCount;
private readonly ushort[,] noteBookDivisionIds;
private byte[]? cachedUnlockedSecretRecipeBooks;
private byte[]? cachedUnlockLinks;
private byte[]? cachedCompletedQuests;
/// <summary>
/// Initializes a new instance of the <see cref="RecipeData"/> class.
/// </summary>
[ServiceManager.ServiceConstructor]
public RecipeData()
{
var numCraftTypes = this.dataManager.GetExcelSheet<CraftType>().Count();
var numSecretNotBookDivisions = this.dataManager.GetExcelSheet<NotebookDivision>().Count(row => row.RowId is >= 1000 and < 2000);
this.unlockedNoteBookDivisionsCount = new byte[numCraftTypes];
this.unlockedSecretNoteBookDivisionsCount = new byte[numCraftTypes];
this.noteBookDivisionIds = new ushort[numCraftTypes, numSecretNotBookDivisions];
this.craftTypeLevels = new ushort[numCraftTypes];
this.clientState.Login += this.Update;
this.clientState.Logout += this.OnLogout;
this.clientState.LevelChanged += this.OnlevelChanged;
this.gameGui.AgentUpdate += this.OnAgentUpdate;
}
/// <inheritdoc/>
void IInternalDisposableService.DisposeService()
{
this.clientState.Login -= this.Update;
this.clientState.Logout -= this.OnLogout;
this.clientState.LevelChanged -= this.OnlevelChanged;
this.gameGui.AgentUpdate -= this.OnAgentUpdate;
}
/// <summary>
/// Determines whether the specified Recipe is unlocked.
/// </summary>
/// <param name="row">The Recipe row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
public bool IsRecipeUnlocked(Recipe row)
{
// E8 ?? ?? ?? ?? 48 63 76 (2025.09.04)
var division = row.RecipeNotebookList.RowId != 0 && row.RecipeNotebookList.IsValid
? (row.RecipeNotebookList.RowId - 1000) / 8 + 1000
: ((uint)row.RecipeLevelTable.Value.ClassJobLevel - 1) / 5;
// E8 ?? ?? ?? ?? 33 ED 84 C0 75 (2025.09.04)
foreach (var craftTypeRow in this.dataManager.GetExcelSheet<CraftType>())
{
var craftType = (byte)craftTypeRow.RowId;
if (division < this.unlockedNoteBookDivisionsCount[craftType])
return true;
if (this.unlockedNoteBookDivisionsCount[craftType] == 0)
continue;
if (division is 5000 or 5001)
return true;
if (division < 1000)
continue;
if (this.unlockedSecretNoteBookDivisionsCount[craftType] == 0)
continue;
if (this.noteBookDivisionIds.GetRowSpan(craftType).Contains((ushort)division))
return true;
}
return false;
}
private void OnLogout(int type, int code)
{
this.cachedUnlockedSecretRecipeBooks = null;
this.cachedUnlockLinks = null;
this.cachedCompletedQuests = null;
}
private void OnlevelChanged(uint classJobId, uint level)
{
if (this.dataManager.GetExcelSheet<ClassJob>().TryGetRow(classJobId, out var classJobRow) &&
classJobRow.ClassJobCategory.RowId == 33) // Crafter
{
this.Update();
}
}
private void OnAgentUpdate(AgentUpdateFlag agentUpdateFlag)
{
if (agentUpdateFlag.HasFlag(AgentUpdateFlag.UnlocksUpdate))
this.Update();
}
private void Update()
{
// based on Client::Game::UI::RecipeNote.InitializeStructs
if (!this.clientState.IsLoggedIn || !this.NeedsUpdate())
return;
Array.Clear(this.unlockedNoteBookDivisionsCount, 0, this.unlockedNoteBookDivisionsCount.Length);
Array.Clear(this.unlockedSecretNoteBookDivisionsCount, 0, this.unlockedSecretNoteBookDivisionsCount.Length);
Array.Clear(this.noteBookDivisionIds, 0, this.noteBookDivisionIds.Length);
foreach (var craftTypeRow in this.dataManager.GetExcelSheet<CraftType>())
{
var craftType = (byte)craftTypeRow.RowId;
var craftTypeLevel = RecipeNote.Instance()->GetCraftTypeLevel(craftType);
if (craftTypeLevel == 0)
continue;
var noteBookDivisionIndex = -1;
foreach (var noteBookDivisionRow in this.dataManager.GetExcelSheet<NotebookDivision>())
{
if (noteBookDivisionRow.RowId < 1000)
{
if (craftTypeLevel >= noteBookDivisionRow.CraftOpeningLevel)
this.unlockedNoteBookDivisionsCount[craftType]++;
}
else if (noteBookDivisionRow.RowId < 2000)
{
noteBookDivisionIndex++;
// For future Lumina.Excel update, replace with:
// if (!notebookDivisionRow.AllowedCraftTypes[craftType])
// continue;
switch (craftTypeRow.RowId)
{
case 0 when !noteBookDivisionRow.CRPCraft: continue;
case 1 when !noteBookDivisionRow.BSMCraft: continue;
case 2 when !noteBookDivisionRow.ARMCraft: continue;
case 3 when !noteBookDivisionRow.GSMCraft: continue;
case 4 when !noteBookDivisionRow.LTWCraft: continue;
case 5 when !noteBookDivisionRow.WVRCraft: continue;
case 6 when !noteBookDivisionRow.ALCCraft: continue;
case 7 when !noteBookDivisionRow.CULCraft: continue;
}
if (noteBookDivisionRow.GatheringOpeningLevel != byte.MaxValue)
continue;
// For future Lumina.Excel update, replace with:
// if (notebookDivisionRow.RequiresSecretRecipeBookGroupUnlock)
if (noteBookDivisionRow.Unknown1)
{
var secretRecipeBookUnlocked = false;
// For future Lumina.Excel update, iterate over notebookDivisionRow.SecretRecipeBookGroups
for (var i = 0; i < 2; i++)
{
// For future Lumina.Excel update, replace with:
// if (secretRecipeBookGroup.RowId == 0 || !secretRecipeBookGroup.IsValid)
// continue;
var secretRecipeBookGroupRowId = i switch
{
0 => noteBookDivisionRow.Unknown2,
1 => noteBookDivisionRow.Unknown2,
_ => default,
};
if (secretRecipeBookGroupRowId == 0)
continue;
if (!this.dataManager.GetExcelSheet<SecretRecipeBookGroup>().TryGetRow(secretRecipeBookGroupRowId, out var secretRecipeBookGroupRow))
continue;
// For future Lumina.Excel update, replace with:
// var bitIndex = secretRecipeBookGroup.Value.UnlockBitIndex[craftType];
var bitIndex = craftType switch
{
0 => secretRecipeBookGroupRow.Unknown0,
1 => secretRecipeBookGroupRow.Unknown1,
2 => secretRecipeBookGroupRow.Unknown2,
3 => secretRecipeBookGroupRow.Unknown3,
4 => secretRecipeBookGroupRow.Unknown4,
5 => secretRecipeBookGroupRow.Unknown5,
6 => secretRecipeBookGroupRow.Unknown6,
7 => secretRecipeBookGroupRow.Unknown7,
_ => default,
};
if (PlayerState.Instance()->UnlockedSecretRecipeBooksBitArray.Get(bitIndex))
{
secretRecipeBookUnlocked = true;
break;
}
}
if (noteBookDivisionRow.CraftOpeningLevel > craftTypeLevel && !secretRecipeBookUnlocked)
continue;
}
else if (craftTypeLevel < noteBookDivisionRow.CraftOpeningLevel)
{
continue;
}
else if (noteBookDivisionRow.QuestUnlock.RowId != 0 && !UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(noteBookDivisionRow.QuestUnlock.RowId))
{
continue;
}
this.unlockedSecretNoteBookDivisionsCount[craftType]++;
this.noteBookDivisionIds[craftType, noteBookDivisionIndex] = (ushort)noteBookDivisionRow.RowId;
}
}
}
}
private bool NeedsUpdate()
{
var changed = false;
foreach (var craftTypeRow in this.dataManager.GetExcelSheet<CraftType>())
{
var craftType = (byte)craftTypeRow.RowId;
var craftTypeLevel = RecipeNote.Instance()->GetCraftTypeLevel(craftType);
if (this.craftTypeLevels[craftType] != craftTypeLevel)
{
this.craftTypeLevels[craftType] = craftTypeLevel;
changed |= true;
}
}
if (this.cachedUnlockedSecretRecipeBooks == null || !PlayerState.Instance()->UnlockedSecretRecipeBooks.SequenceEqual(this.cachedUnlockedSecretRecipeBooks))
{
this.cachedUnlockedSecretRecipeBooks = PlayerState.Instance()->UnlockedSecretRecipeBooks.ToArray();
changed |= true;
}
if (this.cachedUnlockLinks == null || !UIState.Instance()->UnlockLinks.SequenceEqual(this.cachedUnlockLinks))
{
this.cachedUnlockLinks = UIState.Instance()->UnlockLinks.ToArray();
changed |= true;
}
if (this.cachedCompletedQuests == null || !QuestManager.Instance()->CompletedQuests.SequenceEqual(this.cachedCompletedQuests))
{
this.cachedCompletedQuests = QuestManager.Instance()->CompletedQuests.ToArray();
changed |= true;
}
return changed;
}
}

View file

@ -0,0 +1,858 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using Dalamud.Data;
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.InstanceContent;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Component.Exd;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using ActionSheet = Lumina.Excel.Sheets.Action;
using InstanceContentSheet = Lumina.Excel.Sheets.InstanceContent;
using PublicContentSheet = Lumina.Excel.Sheets.PublicContent;
namespace Dalamud.Game.UnlockState;
#pragma warning disable UnlockState
/// <summary>
/// This class provides unlock state of various content in the game.
/// </summary>
[ServiceManager.EarlyLoadedService]
internal unsafe class UnlockState : IInternalDisposableService, IUnlockState
{
private static readonly ModuleLog Log = new(nameof(UnlockState));
private readonly ConcurrentDictionary<Type, HashSet<uint>> cachedUnlockedRowIds = [];
[ServiceManager.ServiceDependency]
private readonly DataManager dataManager = Service<DataManager>.Get();
[ServiceManager.ServiceDependency]
private readonly ClientState.ClientState clientState = Service<ClientState.ClientState>.Get();
[ServiceManager.ServiceDependency]
private readonly GameGui gameGui = Service<GameGui>.Get();
[ServiceManager.ServiceDependency]
private readonly RecipeData recipeData = Service<RecipeData>.Get();
[ServiceManager.ServiceConstructor]
private UnlockState()
{
this.clientState.Login += this.OnLogin;
this.clientState.Logout += this.OnLogout;
this.gameGui.AgentUpdate += this.OnAgentUpdate;
}
/// <inheritdoc/>
public event IUnlockState.UnlockDelegate Unlock;
private bool IsLoaded => PlayerState.Instance()->IsLoaded;
/// <inheritdoc/>
void IInternalDisposableService.DisposeService()
{
this.clientState.Login -= this.OnLogin;
this.clientState.Logout -= this.OnLogout;
this.gameGui.AgentUpdate -= this.OnAgentUpdate;
}
/// <inheritdoc/>
public bool IsActionUnlocked(ActionSheet row)
{
return this.IsUnlockLinkUnlocked(row.UnlockLink.RowId);
}
/// <inheritdoc/>
public bool IsAetherCurrentUnlocked(AetherCurrent row)
{
if (!this.IsLoaded)
return false;
return PlayerState.Instance()->IsAetherCurrentUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsAetherCurrentCompFlgSetUnlocked(AetherCurrentCompFlgSet row)
{
if (!this.IsLoaded)
return false;
return PlayerState.Instance()->IsAetherCurrentZoneComplete(row.RowId);
}
/// <inheritdoc/>
public bool IsAozActionUnlocked(AozAction row)
{
if (!this.IsLoaded)
return false;
if (row.RowId == 0 || !row.Action.IsValid)
return false;
return UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(row.Action.Value.UnlockLink.RowId);
}
/// <inheritdoc/>
public bool IsBannerBgUnlocked(BannerBg row)
{
return row.UnlockCondition.IsValid && this.IsBannerConditionUnlocked(row.UnlockCondition.Value);
}
/// <inheritdoc/>
public bool IsBannerConditionUnlocked(BannerCondition row)
{
if (row.RowId == 0)
return false;
if (!this.IsLoaded)
return false;
var rowPtr = ExdModule.GetBannerConditionByIndex(row.RowId);
if (rowPtr == null)
return false;
return ExdModule.GetBannerConditionUnlockState(rowPtr) == 0;
}
/// <inheritdoc/>
public bool IsBannerDecorationUnlocked(BannerDecoration row)
{
return row.UnlockCondition.IsValid && this.IsBannerConditionUnlocked(row.UnlockCondition.Value);
}
/// <inheritdoc/>
public bool IsBannerFacialUnlocked(BannerFacial row)
{
return row.UnlockCondition.IsValid && this.IsBannerConditionUnlocked(row.UnlockCondition.Value);
}
/// <inheritdoc/>
public bool IsBannerFrameUnlocked(BannerFrame row)
{
return row.UnlockCondition.IsValid && this.IsBannerConditionUnlocked(row.UnlockCondition.Value);
}
/// <inheritdoc/>
public bool IsBannerTimelineUnlocked(BannerTimeline row)
{
return row.UnlockCondition.IsValid && this.IsBannerConditionUnlocked(row.UnlockCondition.Value);
}
/// <inheritdoc/>
public bool IsBuddyActionUnlocked(BuddyAction row)
{
return this.IsUnlockLinkUnlocked(row.UnlockLink);
}
/// <inheritdoc/>
public bool IsBuddyEquipUnlocked(BuddyEquip row)
{
if (!this.IsLoaded)
return false;
return UIState.Instance()->Buddy.CompanionInfo.IsBuddyEquipUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsCharaMakeCustomizeUnlocked(CharaMakeCustomize row)
{
return row.IsPurchasable && this.IsUnlockLinkUnlocked(row.UnlockLink);
}
/// <inheritdoc/>
public bool IsChocoboTaxiStandUnlocked(ChocoboTaxiStand row)
{
if (!this.IsLoaded)
return false;
return UIState.Instance()->IsChocoboTaxiStandUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsCompanionUnlocked(Companion row)
{
if (!this.IsLoaded)
return false;
return UIState.Instance()->IsCompanionUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsCraftActionUnlocked(CraftAction row)
{
return this.IsUnlockLinkUnlocked(row.QuestRequirement.RowId);
}
/// <inheritdoc/>
public bool IsCSBonusContentTypeUnlocked(CSBonusContentType row)
{
return this.IsUnlockLinkUnlocked(row.UnlockLink);
}
/// <inheritdoc/>
public bool IsEmoteUnlocked(Emote row)
{
return this.IsUnlockLinkUnlocked(row.UnlockLink);
}
/// <inheritdoc/>
public bool IsEmjVoiceNpcUnlocked(EmjVoiceNpc row)
{
return this.IsUnlockLinkUnlocked(row.Unknown26);
}
/// <inheritdoc/>
public bool IsEmjCostumeUnlocked(EmjCostume row)
{
return this.dataManager.GetExcelSheet<EmjVoiceNpc>().TryGetRow(row.RowId, out var emjVoiceNpcRow)
&& this.IsEmjVoiceNpcUnlocked(emjVoiceNpcRow)
&& QuestManager.IsQuestComplete(row.Unknown1);
}
/// <inheritdoc/>
public bool IsGeneralActionUnlocked(GeneralAction row)
{
return this.IsUnlockLinkUnlocked(row.UnlockLink);
}
/// <inheritdoc/>
public bool IsGlassesUnlocked(Glasses row)
{
if (!this.IsLoaded)
return false;
return PlayerState.Instance()->IsGlassesUnlocked((ushort)row.RowId);
}
/// <inheritdoc/>
public bool IsHowToUnlocked(HowTo row)
{
if (!this.IsLoaded)
return false;
return UIState.Instance()->IsHowToUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsInstanceContentUnlocked(InstanceContentSheet row)
{
if (!this.IsLoaded)
return false;
return UIState.IsInstanceContentUnlocked(row.RowId);
}
/// <inheritdoc/>
public unsafe bool IsItemUnlocked(Item row)
{
if (row.ItemAction.RowId == 0)
return false;
if (!this.IsLoaded)
return false;
// To avoid the ExdModule.GetItemRowById call, which can return null if the excel page
// is not loaded, we're going to imitate the IsItemActionUnlocked call first:
switch ((ItemActionType)row.ItemAction.Value.Type)
{
case ItemActionType.Companion:
return UIState.Instance()->IsCompanionUnlocked(row.ItemAction.Value.Data[0]);
case ItemActionType.BuddyEquip:
return UIState.Instance()->Buddy.CompanionInfo.IsBuddyEquipUnlocked(row.ItemAction.Value.Data[0]);
case ItemActionType.Mount:
return PlayerState.Instance()->IsMountUnlocked(row.ItemAction.Value.Data[0]);
case ItemActionType.SecretRecipeBook:
return PlayerState.Instance()->IsSecretRecipeBookUnlocked(row.ItemAction.Value.Data[0]);
case ItemActionType.UnlockLink:
case ItemActionType.OccultRecords:
return UIState.Instance()->IsUnlockLinkUnlocked(row.ItemAction.Value.Data[0]);
case ItemActionType.TripleTriadCard when row.AdditionalData.Is<TripleTriadCard>():
return UIState.Instance()->IsTripleTriadCardUnlocked((ushort)row.AdditionalData.RowId);
case ItemActionType.FolkloreTome:
return PlayerState.Instance()->IsFolkloreBookUnlocked(row.ItemAction.Value.Data[0]);
case ItemActionType.OrchestrionRoll when row.AdditionalData.Is<Orchestrion>():
return PlayerState.Instance()->IsOrchestrionRollUnlocked(row.AdditionalData.RowId);
case ItemActionType.FramersKit:
return PlayerState.Instance()->IsFramersKitUnlocked(row.AdditionalData.RowId);
case ItemActionType.Ornament:
return PlayerState.Instance()->IsOrnamentUnlocked(row.ItemAction.Value.Data[0]);
case ItemActionType.Glasses:
return PlayerState.Instance()->IsGlassesUnlocked((ushort)row.AdditionalData.RowId);
case ItemActionType.SoulShards when PublicContentOccultCrescent.GetState() is var occultCrescentState && occultCrescentState != null:
var supportJobId = (byte)row.ItemAction.Value.Data[0];
return supportJobId < occultCrescentState->SupportJobLevels.Length && occultCrescentState->SupportJobLevels[supportJobId] != 0;
case ItemActionType.CompanySealVouchers:
return false;
}
var nativeRow = ExdModule.GetItemRowById(row.RowId);
return nativeRow != null && UIState.Instance()->IsItemActionUnlocked(nativeRow) == 1;
}
/// <inheritdoc/>
public bool IsMcGuffinUnlocked(McGuffin row)
{
return PlayerState.Instance()->IsMcGuffinUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsMJILandmarkUnlocked(MJILandmark row)
{
return this.IsUnlockLinkUnlocked(row.UnlockLink);
}
/// <inheritdoc/>
public bool IsMKDLoreUnlocked(MKDLore row)
{
return this.IsUnlockLinkUnlocked(row.Unknown2);
}
/// <inheritdoc/>
public bool IsMountUnlocked(Mount row)
{
if (!this.IsLoaded)
return false;
return PlayerState.Instance()->IsMountUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsNotebookDivisionUnlocked(NotebookDivision row)
{
return this.IsUnlockLinkUnlocked(row.QuestUnlock.RowId);
}
/// <inheritdoc/>
public bool IsOrchestrionUnlocked(Orchestrion row)
{
if (!this.IsLoaded)
return false;
return PlayerState.Instance()->IsOrchestrionRollUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsOrnamentUnlocked(Ornament row)
{
if (!this.IsLoaded)
return false;
return PlayerState.Instance()->IsOrnamentUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsPerformUnlocked(Perform row)
{
return this.IsUnlockLinkUnlocked((uint)row.UnlockLink);
}
/// <inheritdoc/>
public bool IsPublicContentUnlocked(PublicContentSheet row)
{
if (!this.IsLoaded)
return false;
return UIState.IsPublicContentUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsRecipeUnlocked(Recipe row)
{
return this.recipeData.IsRecipeUnlocked(row);
}
/// <inheritdoc/>
public bool IsSecretRecipeBookUnlocked(SecretRecipeBook row)
{
if (!this.IsLoaded)
return false;
return PlayerState.Instance()->IsSecretRecipeBookUnlocked(row.RowId);
}
/// <inheritdoc/>
public bool IsTraitUnlocked(Trait row)
{
return this.IsUnlockLinkUnlocked(row.Quest.RowId);
}
/// <inheritdoc/>
public bool IsTripleTriadCardUnlocked(TripleTriadCard row)
{
if (!this.IsLoaded)
return false;
return UIState.Instance()->IsTripleTriadCardUnlocked((ushort)row.RowId);
}
/// <inheritdoc/>
public bool IsItemUnlockable(Item row)
{
if (row.ItemAction.RowId == 0)
return false;
return (ItemActionType)row.ItemAction.Value.Type
is ItemActionType.Companion
or ItemActionType.BuddyEquip
or ItemActionType.Mount
or ItemActionType.SecretRecipeBook
or ItemActionType.UnlockLink
or ItemActionType.TripleTriadCard
or ItemActionType.FolkloreTome
or ItemActionType.OrchestrionRoll
or ItemActionType.FramersKit
or ItemActionType.Ornament
or ItemActionType.Glasses
or ItemActionType.OccultRecords
or ItemActionType.SoulShards;
}
/// <inheritdoc/>
public bool IsRowRefUnlocked<T>(RowRef<T> rowRef) where T : struct, IExcelRow<T>
{
return this.IsRowRefUnlocked((RowRef)rowRef);
}
/// <inheritdoc/>
public bool IsRowRefUnlocked(RowRef rowRef)
{
if (!this.IsLoaded || rowRef.IsUntyped)
return false;
if (rowRef.TryGetValue<ActionSheet>(out var actionRow))
return this.IsActionUnlocked(actionRow);
if (rowRef.TryGetValue<AetherCurrent>(out var aetherCurrentRow))
return this.IsAetherCurrentUnlocked(aetherCurrentRow);
if (rowRef.TryGetValue<AetherCurrentCompFlgSet>(out var aetherCurrentCompFlgSetRow))
return this.IsAetherCurrentCompFlgSetUnlocked(aetherCurrentCompFlgSetRow);
if (rowRef.TryGetValue<AozAction>(out var aozActionRow))
return this.IsAozActionUnlocked(aozActionRow);
if (rowRef.TryGetValue<BannerBg>(out var bannerBgRow))
return this.IsBannerBgUnlocked(bannerBgRow);
if (rowRef.TryGetValue<BannerCondition>(out var bannerConditionRow))
return this.IsBannerConditionUnlocked(bannerConditionRow);
if (rowRef.TryGetValue<BannerDecoration>(out var bannerDecorationRow))
return this.IsBannerDecorationUnlocked(bannerDecorationRow);
if (rowRef.TryGetValue<BannerFacial>(out var bannerFacialRow))
return this.IsBannerFacialUnlocked(bannerFacialRow);
if (rowRef.TryGetValue<BannerFrame>(out var bannerFrameRow))
return this.IsBannerFrameUnlocked(bannerFrameRow);
if (rowRef.TryGetValue<BannerTimeline>(out var bannerTimelineRow))
return this.IsBannerTimelineUnlocked(bannerTimelineRow);
if (rowRef.TryGetValue<BuddyAction>(out var buddyActionRow))
return this.IsBuddyActionUnlocked(buddyActionRow);
if (rowRef.TryGetValue<BuddyEquip>(out var buddyEquipRow))
return this.IsBuddyEquipUnlocked(buddyEquipRow);
if (rowRef.TryGetValue<CSBonusContentType>(out var csBonusContentTypeRow))
return this.IsCSBonusContentTypeUnlocked(csBonusContentTypeRow);
if (rowRef.TryGetValue<CharaMakeCustomize>(out var charaMakeCustomizeRow))
return this.IsCharaMakeCustomizeUnlocked(charaMakeCustomizeRow);
if (rowRef.TryGetValue<ChocoboTaxiStand>(out var chocoboTaxiStandRow))
return this.IsChocoboTaxiStandUnlocked(chocoboTaxiStandRow);
if (rowRef.TryGetValue<Companion>(out var companionRow))
return this.IsCompanionUnlocked(companionRow);
if (rowRef.TryGetValue<CraftAction>(out var craftActionRow))
return this.IsCraftActionUnlocked(craftActionRow);
if (rowRef.TryGetValue<Emote>(out var emoteRow))
return this.IsEmoteUnlocked(emoteRow);
if (rowRef.TryGetValue<GeneralAction>(out var generalActionRow))
return this.IsGeneralActionUnlocked(generalActionRow);
if (rowRef.TryGetValue<Glasses>(out var glassesRow))
return this.IsGlassesUnlocked(glassesRow);
if (rowRef.TryGetValue<HowTo>(out var howToRow))
return this.IsHowToUnlocked(howToRow);
if (rowRef.TryGetValue<InstanceContentSheet>(out var instanceContentRow))
return this.IsInstanceContentUnlocked(instanceContentRow);
if (rowRef.TryGetValue<Item>(out var itemRow))
return this.IsItemUnlocked(itemRow);
if (rowRef.TryGetValue<MJILandmark>(out var mjiLandmarkRow))
return this.IsMJILandmarkUnlocked(mjiLandmarkRow);
if (rowRef.TryGetValue<MKDLore>(out var mkdLoreRow))
return this.IsMKDLoreUnlocked(mkdLoreRow);
if (rowRef.TryGetValue<McGuffin>(out var mcGuffinRow))
return this.IsMcGuffinUnlocked(mcGuffinRow);
if (rowRef.TryGetValue<Mount>(out var mountRow))
return this.IsMountUnlocked(mountRow);
if (rowRef.TryGetValue<NotebookDivision>(out var notebookDivisionRow))
return this.IsNotebookDivisionUnlocked(notebookDivisionRow);
if (rowRef.TryGetValue<Orchestrion>(out var orchestrionRow))
return this.IsOrchestrionUnlocked(orchestrionRow);
if (rowRef.TryGetValue<Ornament>(out var ornamentRow))
return this.IsOrnamentUnlocked(ornamentRow);
if (rowRef.TryGetValue<Perform>(out var performRow))
return this.IsPerformUnlocked(performRow);
if (rowRef.TryGetValue<PublicContentSheet>(out var publicContentRow))
return this.IsPublicContentUnlocked(publicContentRow);
if (rowRef.TryGetValue<Recipe>(out var recipeRow))
return this.IsRecipeUnlocked(recipeRow);
if (rowRef.TryGetValue<SecretRecipeBook>(out var secretRecipeBookRow))
return this.IsSecretRecipeBookUnlocked(secretRecipeBookRow);
if (rowRef.TryGetValue<Trait>(out var traitRow))
return this.IsTraitUnlocked(traitRow);
if (rowRef.TryGetValue<TripleTriadCard>(out var tripleTriadCardRow))
return this.IsTripleTriadCardUnlocked(tripleTriadCardRow);
return false;
}
/// <inheritdoc/>
public bool IsUnlockLinkUnlocked(ushort unlockLink)
{
if (!this.IsLoaded)
return false;
if (unlockLink == 0)
return false;
return UIState.Instance()->IsUnlockLinkUnlocked(unlockLink);
}
/// <inheritdoc/>
public bool IsUnlockLinkUnlocked(uint unlockLink)
{
if (!this.IsLoaded)
return false;
if (unlockLink == 0)
return false;
return UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(unlockLink);
}
private void OnLogin()
{
this.Update();
}
private void OnLogout(int type, int code)
{
this.cachedUnlockedRowIds.Clear();
}
private void OnAgentUpdate(AgentUpdateFlag agentUpdateFlag)
{
if (agentUpdateFlag.HasFlag(AgentUpdateFlag.UnlocksUpdate))
this.Update();
}
private void Update()
{
if (!this.IsLoaded)
return;
this.UpdateUnlocksForSheet<ActionSheet>();
this.UpdateUnlocksForSheet<AetherCurrent>();
this.UpdateUnlocksForSheet<AetherCurrentCompFlgSet>();
this.UpdateUnlocksForSheet<AozAction>();
this.UpdateUnlocksForSheet<BannerBg>();
this.UpdateUnlocksForSheet<BannerCondition>();
this.UpdateUnlocksForSheet<BannerDecoration>();
this.UpdateUnlocksForSheet<BannerFacial>();
this.UpdateUnlocksForSheet<BannerFrame>();
this.UpdateUnlocksForSheet<BannerTimeline>();
this.UpdateUnlocksForSheet<BuddyAction>();
this.UpdateUnlocksForSheet<BuddyEquip>();
this.UpdateUnlocksForSheet<CSBonusContentType>();
this.UpdateUnlocksForSheet<CharaMakeCustomize>();
this.UpdateUnlocksForSheet<ChocoboTaxi>();
this.UpdateUnlocksForSheet<Companion>();
this.UpdateUnlocksForSheet<CraftAction>();
this.UpdateUnlocksForSheet<EmjVoiceNpc>();
this.UpdateUnlocksForSheet<Emote>();
this.UpdateUnlocksForSheet<GeneralAction>();
this.UpdateUnlocksForSheet<Glasses>();
this.UpdateUnlocksForSheet<HowTo>();
this.UpdateUnlocksForSheet<InstanceContentSheet>();
this.UpdateUnlocksForSheet<Item>();
this.UpdateUnlocksForSheet<MJILandmark>();
this.UpdateUnlocksForSheet<MKDLore>();
this.UpdateUnlocksForSheet<McGuffin>();
this.UpdateUnlocksForSheet<Mount>();
this.UpdateUnlocksForSheet<NotebookDivision>();
this.UpdateUnlocksForSheet<Orchestrion>();
this.UpdateUnlocksForSheet<Ornament>();
this.UpdateUnlocksForSheet<Perform>();
this.UpdateUnlocksForSheet<PublicContentSheet>();
this.UpdateUnlocksForSheet<Recipe>();
this.UpdateUnlocksForSheet<SecretRecipeBook>();
this.UpdateUnlocksForSheet<Trait>();
this.UpdateUnlocksForSheet<TripleTriadCard>();
// Not implemented:
// - DescriptionPage: quite complex
// - QuestAcceptAdditionCondition: ignored
// For some other day:
// - FishingSpot
// - Spearfishing
// - Adventure (Sightseeing)
// - MinerFolkloreTome
// - BotanistFolkloreTome
// - FishingFolkloreTome
// - VVD or is that unlocked via quest?
// - VVDNotebookContents?
// - FramersKit (is that just an Item?)
// - ... more?
// Subrow sheets, which are incompatible with the current Unlock event, since RowRef doesn't carry the SubrowId:
// - EmjCostume
// Probably not happening, because it requires fetching data from server:
// - Achievements
// - Titles
// - Bozjan Field Notes
// - Support/Phantom Jobs, which require to be in Occult Crescent, because it checks the jobs level for != 0
}
private void UpdateUnlocksForSheet<T>() where T : struct, IExcelRow<T>
{
var unlockedRowIds = this.cachedUnlockedRowIds.GetOrAdd(typeof(T), _ => []);
foreach (var row in this.dataManager.GetExcelSheet<T>())
{
if (unlockedRowIds.Contains(row.RowId))
continue;
var rowRef = LuminaUtils.CreateRef<T>(row.RowId);
if (!this.IsRowRefUnlocked(rowRef))
continue;
unlockedRowIds.Add(row.RowId);
Log.Verbose($"Unlock detected: {typeof(T).Name}#{row.RowId}");
foreach (var action in Delegate.EnumerateInvocationList(this.Unlock))
{
try
{
action((RowRef)rowRef);
}
catch (Exception ex)
{
Log.Error(ex, "Exception during raise of {handler}", action.Method);
}
}
}
}
}
/// <summary>
/// Plugin-scoped version of a <see cref="UnlockState"/> service.
/// </summary>
[PluginInterface]
[ServiceManager.ScopedService]
#pragma warning disable SA1015
[ResolveVia<IUnlockState>]
#pragma warning restore SA1015
internal class UnlockStatePluginScoped : IInternalDisposableService, IUnlockState
{
[ServiceManager.ServiceDependency]
private readonly UnlockState unlockStateService = Service<UnlockState>.Get();
/// <summary>
/// Initializes a new instance of the <see cref="UnlockStatePluginScoped"/> class.
/// </summary>
internal UnlockStatePluginScoped()
{
this.unlockStateService.Unlock += this.UnlockForward;
}
/// <inheritdoc/>
public event IUnlockState.UnlockDelegate? Unlock;
/// <inheritdoc/>
public bool IsActionUnlocked(ActionSheet row) => this.unlockStateService.IsActionUnlocked(row);
/// <inheritdoc/>
public bool IsAetherCurrentCompFlgSetUnlocked(AetherCurrentCompFlgSet row) => this.unlockStateService.IsAetherCurrentCompFlgSetUnlocked(row);
/// <inheritdoc/>
public bool IsAetherCurrentUnlocked(AetherCurrent row) => this.unlockStateService.IsAetherCurrentUnlocked(row);
/// <inheritdoc/>
public bool IsAozActionUnlocked(AozAction row) => this.unlockStateService.IsAozActionUnlocked(row);
/// <inheritdoc/>
public bool IsBannerBgUnlocked(BannerBg row) => this.unlockStateService.IsBannerBgUnlocked(row);
/// <inheritdoc/>
public bool IsBannerConditionUnlocked(BannerCondition row) => this.unlockStateService.IsBannerConditionUnlocked(row);
/// <inheritdoc/>
public bool IsBannerDecorationUnlocked(BannerDecoration row) => this.unlockStateService.IsBannerDecorationUnlocked(row);
/// <inheritdoc/>
public bool IsBannerFacialUnlocked(BannerFacial row) => this.unlockStateService.IsBannerFacialUnlocked(row);
/// <inheritdoc/>
public bool IsBannerFrameUnlocked(BannerFrame row) => this.unlockStateService.IsBannerFrameUnlocked(row);
/// <inheritdoc/>
public bool IsBannerTimelineUnlocked(BannerTimeline row) => this.unlockStateService.IsBannerTimelineUnlocked(row);
/// <inheritdoc/>
public bool IsBuddyActionUnlocked(BuddyAction row) => this.unlockStateService.IsBuddyActionUnlocked(row);
/// <inheritdoc/>
public bool IsBuddyEquipUnlocked(BuddyEquip row) => this.unlockStateService.IsBuddyEquipUnlocked(row);
/// <inheritdoc/>
public bool IsCharaMakeCustomizeUnlocked(CharaMakeCustomize row) => this.unlockStateService.IsCharaMakeCustomizeUnlocked(row);
/// <inheritdoc/>
public bool IsChocoboTaxiStandUnlocked(ChocoboTaxiStand row) => this.unlockStateService.IsChocoboTaxiStandUnlocked(row);
/// <inheritdoc/>
public bool IsCompanionUnlocked(Companion row) => this.unlockStateService.IsCompanionUnlocked(row);
/// <inheritdoc/>
public bool IsCraftActionUnlocked(CraftAction row) => this.unlockStateService.IsCraftActionUnlocked(row);
/// <inheritdoc/>
public bool IsCSBonusContentTypeUnlocked(CSBonusContentType row) => this.unlockStateService.IsCSBonusContentTypeUnlocked(row);
/// <inheritdoc/>
public bool IsEmoteUnlocked(Emote row) => this.unlockStateService.IsEmoteUnlocked(row);
/// <inheritdoc/>
public bool IsEmjVoiceNpcUnlocked(EmjVoiceNpc row) => this.unlockStateService.IsEmjVoiceNpcUnlocked(row);
/// <inheritdoc/>
public bool IsEmjCostumeUnlocked(EmjCostume row) => this.unlockStateService.IsEmjCostumeUnlocked(row);
/// <inheritdoc/>
public bool IsGeneralActionUnlocked(GeneralAction row) => this.unlockStateService.IsGeneralActionUnlocked(row);
/// <inheritdoc/>
public bool IsGlassesUnlocked(Glasses row) => this.unlockStateService.IsGlassesUnlocked(row);
/// <inheritdoc/>
public bool IsHowToUnlocked(HowTo row) => this.unlockStateService.IsHowToUnlocked(row);
/// <inheritdoc/>
public bool IsInstanceContentUnlocked(InstanceContentSheet row) => this.unlockStateService.IsInstanceContentUnlocked(row);
/// <inheritdoc/>
public bool IsItemUnlockable(Item row) => this.unlockStateService.IsItemUnlockable(row);
/// <inheritdoc/>
public bool IsItemUnlocked(Item row) => this.unlockStateService.IsItemUnlocked(row);
/// <inheritdoc/>
public bool IsMcGuffinUnlocked(McGuffin row) => this.unlockStateService.IsMcGuffinUnlocked(row);
/// <inheritdoc/>
public bool IsMJILandmarkUnlocked(MJILandmark row) => this.unlockStateService.IsMJILandmarkUnlocked(row);
/// <inheritdoc/>
public bool IsMKDLoreUnlocked(MKDLore row) => this.unlockStateService.IsMKDLoreUnlocked(row);
/// <inheritdoc/>
public bool IsMountUnlocked(Mount row) => this.unlockStateService.IsMountUnlocked(row);
/// <inheritdoc/>
public bool IsNotebookDivisionUnlocked(NotebookDivision row) => this.unlockStateService.IsNotebookDivisionUnlocked(row);
/// <inheritdoc/>
public bool IsOrchestrionUnlocked(Orchestrion row) => this.unlockStateService.IsOrchestrionUnlocked(row);
/// <inheritdoc/>
public bool IsOrnamentUnlocked(Ornament row) => this.unlockStateService.IsOrnamentUnlocked(row);
/// <inheritdoc/>
public bool IsPerformUnlocked(Perform row) => this.unlockStateService.IsPerformUnlocked(row);
/// <inheritdoc/>
public bool IsPublicContentUnlocked(PublicContentSheet row) => this.unlockStateService.IsPublicContentUnlocked(row);
/// <inheritdoc/>
public bool IsRecipeUnlocked(Recipe row) => this.unlockStateService.IsRecipeUnlocked(row);
/// <inheritdoc/>
public bool IsRowRefUnlocked(RowRef rowRef) => this.unlockStateService.IsRowRefUnlocked(rowRef);
/// <inheritdoc/>
public bool IsRowRefUnlocked<T>(RowRef<T> rowRef) where T : struct, IExcelRow<T> => this.unlockStateService.IsRowRefUnlocked(rowRef);
/// <inheritdoc/>
public bool IsSecretRecipeBookUnlocked(SecretRecipeBook row) => this.unlockStateService.IsSecretRecipeBookUnlocked(row);
/// <inheritdoc/>
public bool IsTraitUnlocked(Trait row) => this.unlockStateService.IsTraitUnlocked(row);
/// <inheritdoc/>
public bool IsTripleTriadCardUnlocked(TripleTriadCard row) => this.unlockStateService.IsTripleTriadCardUnlocked(row);
/// <inheritdoc/>
public bool IsUnlockLinkUnlocked(uint unlockLink) => this.unlockStateService.IsUnlockLinkUnlocked(unlockLink);
/// <inheritdoc/>
public bool IsUnlockLinkUnlocked(ushort unlockLink) => this.unlockStateService.IsUnlockLinkUnlocked(unlockLink);
/// <inheritdoc/>
void IInternalDisposableService.DisposeService()
{
this.unlockStateService.Unlock -= this.UnlockForward;
}
private void UnlockForward(RowRef rowRef) => this.Unlock?.Invoke(rowRef);
}

View file

@ -1,7 +1,7 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.JobGauge;
using Dalamud.Game.ClientState.JobGauge.Types;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Utility;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -29,10 +29,10 @@ internal class GaugeWidget : IDataWindowWidget
/// <inheritdoc/>
public void Draw()
{
var clientState = Service<ClientState>.Get();
var objectTable = Service<ObjectTable>.Get();
var jobGauges = Service<JobGauges>.Get();
var player = clientState.LocalPlayer;
var player = objectTable.LocalPlayer;
if (player == null)
{
ImGui.Text("Player is not present"u8);

View file

@ -4,6 +4,7 @@ using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.Gui;
using Dalamud.Game.Player;
using Dalamud.Utility;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -39,12 +40,13 @@ internal class ObjectTableWidget : IDataWindowWidget
var chatGui = Service<ChatGui>.Get();
var clientState = Service<ClientState>.Get();
var playerState = Service<PlayerState>.Get();
var gameGui = Service<GameGui>.Get();
var objectTable = Service<ObjectTable>.Get();
var stateString = string.Empty;
if (clientState.LocalPlayer == null)
if (objectTable.LocalPlayer == null)
{
ImGui.Text("LocalPlayer null."u8);
}
@ -55,10 +57,10 @@ internal class ObjectTableWidget : IDataWindowWidget
else
{
stateString += $"ObjectTableLen: {objectTable.Length}\n";
stateString += $"LocalPlayerName: {clientState.LocalPlayer.Name}\n";
stateString += $"CurrentWorldName: {(this.resolveGameData ? clientState.LocalPlayer.CurrentWorld.ValueNullable?.Name : clientState.LocalPlayer.CurrentWorld.RowId.ToString())}\n";
stateString += $"HomeWorldName: {(this.resolveGameData ? clientState.LocalPlayer.HomeWorld.ValueNullable?.Name : clientState.LocalPlayer.HomeWorld.RowId.ToString())}\n";
stateString += $"LocalCID: {clientState.LocalContentId:X}\n";
stateString += $"LocalPlayerName: {playerState.CharacterName}\n";
stateString += $"CurrentWorldName: {(this.resolveGameData ? playerState.CurrentWorld.ValueNullable?.Name : playerState.CurrentWorld.RowId.ToString())}\n";
stateString += $"HomeWorldName: {(this.resolveGameData ? playerState.HomeWorld.ValueNullable?.Name : playerState.HomeWorld.RowId.ToString())}\n";
stateString += $"LocalCID: {playerState.ContentId:X}\n";
stateString += $"LastLinkedItem: {chatGui.LastLinkedItemId}\n";
stateString += $"TerritoryType: {clientState.TerritoryType}\n\n";

View file

@ -1,10 +1,10 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Plugin.Ipc;
using Dalamud.Plugin.Ipc.Internal;
using Dalamud.Utility;
using Serilog;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -111,12 +111,12 @@ internal class PluginIpcWidget : IDataWindowWidget
if (ImGui.Button("Action GO"u8))
{
this.ipcSubGo.InvokeAction(Service<ClientState>.Get().LocalPlayer);
this.ipcSubGo.InvokeAction(Service<ObjectTable>.Get().LocalPlayer);
}
if (ImGui.Button("Func GO"u8))
{
this.callGateResponse = this.ipcSubGo.InvokeFunc(Service<ClientState>.Get().LocalPlayer);
this.callGateResponse = this.ipcSubGo.InvokeFunc(Service<ObjectTable>.Get().LocalPlayer);
}
if (!this.callGateResponse.IsNullOrEmpty())

View file

@ -1,4 +1,4 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Interface.Utility;
@ -33,7 +33,7 @@ internal class TargetWidget : IDataWindowWidget
{
ImGui.Checkbox("Resolve GameData"u8, ref this.resolveGameData);
var clientState = Service<ClientState>.Get();
var objectTable = Service<ObjectTable>.Get();
var targetMgr = Service<TargetManager>.Get();
if (targetMgr.Target != null)
@ -80,7 +80,7 @@ internal class TargetWidget : IDataWindowWidget
if (ImGui.Button("Clear FT"u8))
targetMgr.FocusTarget = null;
var localPlayer = clientState.LocalPlayer;
var localPlayer = objectTable.LocalPlayer;
if (localPlayer != null)
{

View file

@ -1,6 +1,7 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.Text.Evaluator;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Plugin.SelfTest;
@ -51,8 +52,8 @@ internal class SeStringEvaluatorSelfTestStep : ISelfTestStep
// that it returned the local players name by using its EntityId,
// and that it didn't include the world name by checking the HomeWorldId against AgentLobby.Instance()->LobbyData.HomeWorldId.
var clientState = Service<ClientState>.Get();
var localPlayer = clientState.LocalPlayer;
var objectTable = Service<ObjectTable>.Get();
var localPlayer = objectTable.LocalPlayer;
if (localPlayer is null)
{
ImGui.Text("You need to be logged in for this step."u8);

View file

@ -109,11 +109,13 @@ public interface IClientState
/// <summary>
/// Gets the local player character, if one is present.
/// </summary>
[Obsolete($"Use {nameof(IPlayerState)} or {nameof(IObjectTable)}.{nameof(IObjectTable.LocalPlayer)} if necessary.")]
public IPlayerCharacter? LocalPlayer { get; }
/// <summary>
/// Gets the content ID of the local character.
/// </summary>
[Obsolete($"Use {nameof(IPlayerState)}.{nameof(IPlayerState.ContentId)}")]
public ulong LocalContentId { get; }
/// <summary>

View file

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
namespace Dalamud.Plugin.Services;
@ -19,6 +20,11 @@ public interface IObjectTable : IEnumerable<IGameObject>
/// </summary>
public int Length { get; }
/// <summary>
/// Gets the local player character, if one is present.
/// </summary>
public IPlayerCharacter? LocalPlayer { get; }
/// <summary>
/// Gets an enumerator for accessing player objects. This will only contain BattleChara objects.
/// Does not contain any mounts, minions, or accessories.

View file

@ -0,0 +1,243 @@
using System.Collections.Generic;
using Dalamud.Game.Player;
using Lumina.Excel;
using Lumina.Excel.Sheets;
namespace Dalamud.Plugin.Services;
#pragma warning disable SA1400 // Access modifier should be declared: Interface members are public by default
/// <summary>
/// Interface for determining the players state.
/// </summary>
public interface IPlayerState
{
/// <summary>
/// Gets a value indicating whether the local players data is loaded.
/// </summary>
/// <remarks>
/// PlayerState is separate from <see cref="IObjectTable.LocalPlayer"/>,
/// and as such the game object might not exist when it's loaded.
/// </remarks>
bool IsLoaded { get; }
/// <summary>
/// Gets the name of the local character.
/// </summary>
string CharacterName { get; }
/// <summary>
/// Gets the entity ID of the local character.
/// </summary>
uint EntityId { get; }
/// <summary>
/// Gets the content ID of the local character.
/// </summary>
ulong ContentId { get; }
/// <summary>
/// Gets the World row for the local character's current world.
/// </summary>
RowRef<World> CurrentWorld { get; }
/// <summary>
/// Gets the World row for the local character's home world.
/// </summary>
RowRef<World> HomeWorld { get; }
/// <summary>
/// Gets the sex of the local character.
/// </summary>
Sex Sex { get; }
/// <summary>
/// Gets the Race row for the local character.
/// </summary>
RowRef<Race> Race { get; }
/// <summary>
/// Gets the Tribe row for the local character.
/// </summary>
RowRef<Tribe> Tribe { get; }
/// <summary>
/// Gets the ClassJob row for the local character's current class/job.
/// </summary>
RowRef<ClassJob> ClassJob { get; }
/// <summary>
/// Gets the current class/job's level of the local character.
/// </summary>
short Level { get; }
/// <summary>
/// Gets a value indicating whether the local character's level is synced.
/// </summary>
bool IsLevelSynced { get; }
/// <summary>
/// Gets the effective level of the local character.
/// </summary>
short EffectiveLevel { get; }
/// <summary>
/// Gets the GuardianDeity row for the local character.
/// </summary>
RowRef<GuardianDeity> GuardianDeity { get; }
/// <summary>
/// Gets the birth month of the local character.
/// </summary>
byte BirthMonth { get; }
/// <summary>
/// Gets the birth day of the local character.
/// </summary>
byte BirthDay { get; }
/// <summary>
/// Gets the ClassJob row for the local character's starting class.
/// </summary>
RowRef<ClassJob> FirstClass { get; }
/// <summary>
/// Gets the Town row for the local character's starting town.
/// </summary>
RowRef<Town> StartTown { get; }
/// <summary>
/// Gets the base strength of the local character.
/// </summary>
int BaseStrength { get; }
/// <summary>
/// Gets the base dexterity of the local character.
/// </summary>
int BaseDexterity { get; }
/// <summary>
/// Gets the base vitality of the local character.
/// </summary>
int BaseVitality { get; }
/// <summary>
/// Gets the base intelligence of the local character.
/// </summary>
int BaseIntelligence { get; }
/// <summary>
/// Gets the base mind of the local character.
/// </summary>
int BaseMind { get; }
/// <summary>
/// Gets the piety mind of the local character.
/// </summary>
int BasePiety { get; }
/// <summary>
/// Gets the GrandCompany row for the local character's current Grand Company affiliation.
/// </summary>
RowRef<GrandCompany> GrandCompany { get; }
/// <summary>
/// Gets the Aetheryte row for the local player's home aetheryte.
/// </summary>
RowRef<Aetheryte> HomeAetheryte { get; }
/// <summary>
/// Gets an array of Aetheryte rows for the local player's favourite aetherytes.
/// </summary>
IReadOnlyList<RowRef<Aetheryte>> FavoriteAetherytes { get; }
/// <summary>
/// Gets the Aetheryte row for the local player's free aetheryte.
/// </summary>
RowRef<Aetheryte> FreeAetheryte { get; }
/// <summary>
/// Gets the amount of received player commendations of the local player.
/// </summary>
uint BaseRestedExperience { get; }
/// <summary>
/// Gets the amount of received player commendations of the local player.
/// </summary>
short PlayerCommendations { get; }
/// <summary>
/// Gets the Carrier Level of Delivery Moogle Quests of the local player.
/// </summary>
byte DeliveryLevel { get; }
/// <summary>
/// Gets the mentor version of the local player.
/// </summary>
MentorVersion MentorVersion { get; }
/// <summary>
/// Gets a value indicating whether the local player is any kind of Mentor (Battle or Trade Mentor).
/// </summary>
bool IsMentor { get; }
/// <summary>
/// Gets a value indicating whether the local player is a Battle Mentor.
/// </summary>
bool IsBattleMentor { get; }
/// <summary>
/// Gets a value indicating whether the local player is a Trade Mentor.
/// </summary>
bool IsTradeMentor { get; }
/// <summary>
/// Gets a value indicating whether the local player is a novice (aka. Sprout or New Adventurer).
/// </summary>
/// <remarks>
/// Can be <see langword="false"/> if <c>/nastatus</c> was used to deactivate it.
/// </remarks>
bool IsNovice { get; }
/// <summary>
/// Gets a value indicating whether the local player is a returner.
/// </summary>
bool IsReturner { get; }
/// <summary>
/// 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>
int GetAttribute(PlayerAttribute attribute);
/// <summary>
/// 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>
byte GetGrandCompanyRank(GrandCompany grandCompany);
/// <summary>
/// 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>
short GetClassJobLevel(ClassJob classJob);
/// <summary>
/// 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>
int GetClassJobExperience(ClassJob classJob);
/// <summary>
/// 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>
float GetDesynthesisLevel(ClassJob classJob);
}

View file

@ -0,0 +1,328 @@
using System.Diagnostics.CodeAnalysis;
using Lumina.Excel;
using Lumina.Excel.Sheets;
namespace Dalamud.Plugin.Services;
#pragma warning disable SA1400 // Access modifier should be declared: Interface members are public by default
/// <summary>
/// Interface for determining unlock state of various content in the game.
/// </summary>
[Experimental("UnlockState")]
public interface IUnlockState
{
/// <summary>
/// A delegate type used for the <see cref="Unlock"/> event.
/// </summary>
/// <param name="rowRef">A RowRef of the unlocked thing.</param>
delegate void UnlockDelegate(RowRef rowRef);
/// <summary>
/// Event triggered when something was unlocked.
/// </summary>
event UnlockDelegate? Unlock;
/// <summary>
/// Determines whether the specified Action is unlocked.
/// </summary>
/// <param name="row">The Action row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsActionUnlocked(Lumina.Excel.Sheets.Action row);
/// <summary>
/// Determines whether the specified AetherCurrentCompFlgSet is unlocked.
/// </summary>
/// <param name="row">The AetherCurrentCompFlgSet row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsAetherCurrentCompFlgSetUnlocked(AetherCurrentCompFlgSet row);
/// <summary>
/// Determines whether the specified AetherCurrent is unlocked.
/// </summary>
/// <param name="row">The AetherCurrent row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsAetherCurrentUnlocked(AetherCurrent row);
/// <summary>
/// Determines whether the specified AozAction (Blue Mage Action) is unlocked.
/// </summary>
/// <param name="row">The AozAction row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsAozActionUnlocked(AozAction row);
/// <summary>
/// Determines whether the specified BannerBg (Portrait Backgrounds) is unlocked.
/// </summary>
/// <param name="row">The BannerBg row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsBannerBgUnlocked(BannerBg row);
/// <summary>
/// Determines whether the specified BannerCondition is unlocked.
/// </summary>
/// <param name="row">The BannerCondition row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsBannerConditionUnlocked(BannerCondition row);
/// <summary>
/// Determines whether the specified BannerDecoration (Portrait Accents) is unlocked.
/// </summary>
/// <param name="row">The BannerDecoration row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsBannerDecorationUnlocked(BannerDecoration row);
/// <summary>
/// Determines whether the specified BannerFacial (Portrait Expressions) is unlocked.
/// </summary>
/// <param name="row">The BannerFacial row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsBannerFacialUnlocked(BannerFacial row);
/// <summary>
/// Determines whether the specified BannerFrame (Portrait Frames) is unlocked.
/// </summary>
/// <param name="row">The BannerFrame row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsBannerFrameUnlocked(BannerFrame row);
/// <summary>
/// Determines whether the specified BannerTimeline (Portrait Poses) is unlocked.
/// </summary>
/// <param name="row">The BannerTimeline row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsBannerTimelineUnlocked(BannerTimeline row);
/// <summary>
/// Determines whether the specified BuddyAction (Action of the players Chocobo Companion) is unlocked.
/// </summary>
/// <param name="row">The BuddyAction row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsBuddyActionUnlocked(BuddyAction row);
/// <summary>
/// Determines whether the specified BuddyEquip (Equipment of the players Chocobo Companion) is unlocked.
/// </summary>
/// <param name="row">The BuddyEquip row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsBuddyEquipUnlocked(BuddyEquip row);
/// <summary>
/// Determines whether the specified CharaMakeCustomize (Hairstyles and Face Paint patterns) is unlocked.
/// </summary>
/// <param name="row">The CharaMakeCustomize row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsCharaMakeCustomizeUnlocked(CharaMakeCustomize row);
/// <summary>
/// Determines whether the specified ChocoboTaxiStand (Chocobokeeps of the Chocobo Porter service) is unlocked.
/// </summary>
/// <param name="row">The ChocoboTaxiStand row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsChocoboTaxiStandUnlocked(ChocoboTaxiStand row);
/// <summary>
/// Determines whether the specified Companion (Minions) is unlocked.
/// </summary>
/// <param name="row">The Companion row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsCompanionUnlocked(Companion row);
/// <summary>
/// Determines whether the specified CraftAction is unlocked.
/// </summary>
/// <param name="row">The CraftAction row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsCraftActionUnlocked(CraftAction row);
/// <summary>
/// Determines whether the specified CSBonusContentType is unlocked.
/// </summary>
/// <param name="row">The CSBonusContentType row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsCSBonusContentTypeUnlocked(CSBonusContentType row);
/// <summary>
/// Determines whether the specified Emote is unlocked.
/// </summary>
/// <param name="row">The Emote row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsEmoteUnlocked(Emote row);
/// <summary>
/// Determines whether the specified EmjVoiceNpc (Doman Mahjong Characters) is unlocked.
/// </summary>
/// <param name="row">The EmjVoiceNpc row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsEmjVoiceNpcUnlocked(EmjVoiceNpc row);
/// <summary>
/// Determines whether the specified EmjCostume (Doman Mahjong Character Costume) is unlocked.
/// </summary>
/// <param name="row">The EmjCostume row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsEmjCostumeUnlocked(EmjCostume row);
/// <summary>
/// Determines whether the specified GeneralAction is unlocked.
/// </summary>
/// <param name="row">The GeneralAction row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsGeneralActionUnlocked(GeneralAction row);
/// <summary>
/// Determines whether the specified Glasses is unlocked.
/// </summary>
/// <param name="row">The Glasses row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsGlassesUnlocked(Glasses row);
/// <summary>
/// Determines whether the specified HowTo is unlocked.
/// </summary>
/// <param name="row">The HowTo row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsHowToUnlocked(HowTo row);
/// <summary>
/// Determines whether the specified InstanceContent is unlocked.
/// </summary>
/// <param name="row">The InstanceContent row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsInstanceContentUnlocked(InstanceContent row);
/// <summary>
/// Determines whether the specified Item is considered unlockable.
/// </summary>
/// <param name="row">The Item row to check.</param>
/// <returns><see langword="true"/> if unlockable; otherwise, <see langword="false"/>.</returns>
bool IsItemUnlockable(Item row);
/// <summary>
/// Determines whether the specified Item is unlocked.
/// </summary>
/// <param name="row">The Item row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsItemUnlocked(Item row);
/// <summary>
/// Determines whether the specified McGuffin is unlocked.
/// </summary>
/// <param name="row">The McGuffin row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsMcGuffinUnlocked(McGuffin row);
/// <summary>
/// Determines whether the specified MJILandmark (Island Sanctuary landmark) is unlocked.
/// </summary>
/// <param name="row">The MJILandmark row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsMJILandmarkUnlocked(MJILandmark row);
/// <summary>
/// Determines whether the specified MKDLore (Occult Record) is unlocked.
/// </summary>
/// <param name="row">The MKDLore row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsMKDLoreUnlocked(MKDLore row);
/// <summary>
/// Determines whether the specified Mount is unlocked.
/// </summary>
/// <param name="row">The Mount row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsMountUnlocked(Mount row);
/// <summary>
/// Determines whether the specified NotebookDivision (Categories in Crafting/Gathering Log) is unlocked.
/// </summary>
/// <param name="row">The NotebookDivision row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsNotebookDivisionUnlocked(NotebookDivision row);
/// <summary>
/// Determines whether the specified Orchestrion roll is unlocked.
/// </summary>
/// <param name="row">The Orchestrion row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsOrchestrionUnlocked(Orchestrion row);
/// <summary>
/// Determines whether the specified Ornament (Fashion Accessories) is unlocked.
/// </summary>
/// <param name="row">The Ornament row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsOrnamentUnlocked(Ornament row);
/// <summary>
/// Determines whether the specified Perform (Performance Instruments) is unlocked.
/// </summary>
/// <param name="row">The Perform row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsPerformUnlocked(Perform row);
/// <summary>
/// Determines whether the specified PublicContent is unlocked.
/// </summary>
/// <param name="row">The PublicContent row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsPublicContentUnlocked(PublicContent row);
/// <summary>
/// Determines whether the specified Recipe is unlocked.
/// </summary>
/// <param name="row">The Recipe row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsRecipeUnlocked(Recipe row);
/// <summary>
/// Determines whether the underlying RowRef type is unlocked.
/// </summary>
/// <param name="rowRef">The RowRef to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsRowRefUnlocked(RowRef rowRef);
/// <summary>
/// Determines whether the underlying RowRef type is unlocked.
/// </summary>
/// <typeparam name="T">The type of the Excel row.</typeparam>
/// <param name="rowRef">The RowRef to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsRowRefUnlocked<T>(RowRef<T> rowRef) where T : struct, IExcelRow<T>;
/// <summary>
/// Determines whether the specified SecretRecipeBook (Master Recipe Books) is unlocked.
/// </summary>
/// <param name="row">The SecretRecipeBook row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsSecretRecipeBookUnlocked(SecretRecipeBook row);
/// <summary>
/// Determines whether the specified Trait is unlocked.
/// </summary>
/// <param name="row">The Trait row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsTraitUnlocked(Trait row);
/// <summary>
/// Determines whether the specified TripleTriadCard is unlocked.
/// </summary>
/// <param name="row">The TripleTriadCard row to check.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsTripleTriadCardUnlocked(TripleTriadCard row);
/// <summary>
/// Determines whether the specified unlock link is unlocked or quest is completed.
/// </summary>
/// <param name="unlockLink">The unlock link id or quest id (quest ids in this case are over 65536).</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsUnlockLinkUnlocked(uint unlockLink);
/// <summary>
/// Determines whether the specified unlock link is unlocked.
/// </summary>
/// <param name="unlockLink">The unlock link id.</param>
/// <returns><see langword="true"/> if unlocked; otherwise, <see langword="false"/>.</returns>
bool IsUnlockLinkUnlocked(ushort unlockLink);
}

View file

@ -22,9 +22,13 @@ using Dalamud.Interface.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Support;
using Lumina.Excel.Sheets;
using Serilog;
using TerraFX.Interop.Windows;
using Windows.Win32.System.Memory;
using Windows.Win32.System.Ole;
using Windows.Win32.UI.WindowsAndMessaging;

@ -1 +1 @@
Subproject commit f6c479b3fa0b452b44403c8ea53d592bec415e1e
Subproject commit 0afa6b67288e5e667da74c1d3ad582e6c964644c