Merge remote-tracking branch 'origin/master' into api14-rollup
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

This commit is contained in:
github-actions[bot] 2025-11-17 22:05:40 +00:00
commit 63b7ecf0d7
71 changed files with 1283 additions and 312 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;
using CSBuddy = FFXIVClientStructs.FFXIV.Client.Game.UI.Buddy;
using CSBuddyMember = FFXIVClientStructs.FFXIV.Client.Game.UI.Buddy.BuddyMember;
@ -27,7 +29,7 @@ internal sealed partial class BuddyList : IServiceType, IBuddyList
private const uint InvalidEntityId = 0xE0000000;
[ServiceManager.ServiceDependency]
private readonly ClientState clientState = Service<ClientState>.Get();
private readonly PlayerState playerState = Service<PlayerState>.Get();
[ServiceManager.ServiceConstructor]
private BuddyList()

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

@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using Dalamud.Data;
using Dalamud.Game.Player;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Memory;

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;
@ -61,15 +62,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/>

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;
@ -29,14 +30,14 @@ 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;
[ServiceManager.ServiceConstructor]
private unsafe ObjectTable(ClientState clientState)
private unsafe ObjectTable()
{
this.clientState = clientState;
var nativeObjectTable = CSGameObjectManager.Instance()->Objects.IndexSorted;
objectTableLength = nativeObjectTable.Length;
@ -59,6 +60,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();
@ -135,10 +139,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;
@ -26,7 +27,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()

View file

@ -68,6 +68,9 @@ public sealed unsafe partial class StatusList
/// <returns>The status object containing the requested data.</returns>
public static StatusList? CreateStatusListReference(nint 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.
@ -89,9 +92,7 @@ public sealed unsafe partial class StatusList
/// <returns>The status object containing the requested data.</returns>
public static IStatus? CreateStatusReference(nint address)
{
var clientState = Service<ClientState>.Get();
if (clientState.LocalContentId == 0)
if (address == IntPtr.Zero)
return null;
if (address == 0)

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

@ -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

@ -18,7 +18,7 @@ namespace Dalamud.IoC.Internal;
/// Dalamud services are constructed via Service{T}.ConstructObject at the moment.
/// </summary>
[ServiceManager.ProvidedService]
internal class ServiceContainer : IServiceProvider, IServiceType
internal class ServiceContainer : IServiceType
{
private static readonly ModuleLog Log = new("SERVICECONTAINER");
@ -160,10 +160,21 @@ internal class ServiceContainer : IServiceProvider, IServiceType
/// <returns>An implementation of a service scope.</returns>
public IServiceScope GetScope() => new ServiceScopeImpl(this);
/// <inheritdoc/>
object? IServiceProvider.GetService(Type serviceType) => this.GetSingletonService(serviceType);
private async Task<object> GetService(Type serviceType, ServiceScopeImpl? scope, object[] scopedObjects)
/// <summary>
/// Resolves and returns an instance of the specified service type, using either singleton or scoped lifetime as
/// appropriate.
/// </summary>
/// <param name="serviceType">The type of the service to resolve. This must be a concrete or interface type registered with the service
/// manager.</param>
/// <param name="scope">The scope within which to create scoped services. Required if the requested service type is registered as
/// scoped; otherwise, can be null.</param>
/// <param name="scopedObjects">An array of objects available for scoped resolution. Used to locate or create scoped service instances when
/// applicable.</param>
/// <returns>An instance of the requested service type. Returns a singleton instance if available, a scoped instance if
/// required, or an object from the provided scoped objects if it matches the service type.</returns>
/// <exception cref="InvalidOperationException">Thrown if a scoped service is requested but no scope is provided, or if the requested service type cannot be
/// resolved from the scoped objects.</exception>
public async Task<object> GetService(Type serviceType, ServiceScopeImpl? scope, object[] scopedObjects)
{
if (this.interfaceToTypeMap.TryGetValue(serviceType, out var implementingType))
serviceType = implementingType;

View file

@ -1,4 +1,4 @@
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@ -12,7 +12,7 @@ namespace Dalamud.IoC.Internal;
/// <summary>
/// Container enabling the creation of scoped services.
/// </summary>
internal interface IServiceScope : IAsyncDisposable
internal interface IServiceScope : IServiceProvider, IAsyncDisposable
{
/// <summary>
/// Register objects that may be injected to scoped services,
@ -57,6 +57,12 @@ internal class ServiceScopeImpl : IServiceScope
/// <param name="container">The container this scope will use to create services.</param>
public ServiceScopeImpl(ServiceContainer container) => this.container = container;
/// <inheritdoc/>
public object? GetService(Type serviceType)
{
return this.container.GetService(serviceType, this, []).ConfigureAwait(false).GetAwaiter().GetResult();
}
/// <inheritdoc/>
public void RegisterPrivateScopes(params object[] scopes)
{

View file

@ -86,126 +86,73 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
configuration.DalamudConfigurationSaved += this.OnDalamudConfigurationSaved;
}
/// <summary>
/// Event that gets fired when loc is changed
/// </summary>
/// <inheritdoc/>
public event IDalamudPluginInterface.LanguageChangedDelegate? LanguageChanged;
/// <summary>
/// Event that is fired when the active list of plugins is changed.
/// </summary>
/// <inheritdoc/>
public event IDalamudPluginInterface.ActivePluginsChangedDelegate? ActivePluginsChanged;
/// <summary>
/// Gets the reason this plugin was loaded.
/// </summary>
/// <inheritdoc/>
public PluginLoadReason Reason { get; }
/// <summary>
/// Gets a value indicating whether auto-updates have already completed this session.
/// </summary>
/// <inheritdoc/>
public bool IsAutoUpdateComplete => Service<AutoUpdateManager>.GetNullable()?.IsAutoUpdateComplete ?? false;
/// <summary>
/// Gets the repository from which this plugin was installed.
///
/// If a plugin was installed from the official/main repository, this will return the value of
/// <see cref="SpecialPluginSource.MainRepo"/>. Developer plugins will return the value of
/// <see cref="SpecialPluginSource.DevPlugin"/>.
/// </summary>
/// <inheritdoc/>
public string SourceRepository { get; }
/// <summary>
/// Gets the current internal plugin name.
/// </summary>
/// <inheritdoc/>
public string InternalName => this.plugin.InternalName;
/// <summary>
/// Gets the plugin's manifest.
/// </summary>
/// <inheritdoc/>
public IPluginManifest Manifest => this.plugin.Manifest;
/// <summary>
/// Gets a value indicating whether this is a dev plugin.
/// </summary>
/// <inheritdoc/>
public bool IsDev => this.plugin.IsDev;
/// <summary>
/// Gets a value indicating whether this is a testing release of a plugin.
/// </summary>
/// <remarks>
/// Dev plugins have undefined behavior for this value, but can be expected to return <c>false</c>.
/// </remarks>
/// <inheritdoc/>
public bool IsTesting { get; }
/// <summary>
/// Gets the time that this plugin was loaded.
/// </summary>
/// <inheritdoc/>
public DateTime LoadTime { get; }
/// <summary>
/// Gets the UTC time that this plugin was loaded.
/// </summary>
/// <inheritdoc/>
public DateTime LoadTimeUTC { get; }
/// <summary>
/// Gets the timespan delta from when this plugin was loaded.
/// </summary>
/// <inheritdoc/>
public TimeSpan LoadTimeDelta => DateTime.Now - this.LoadTime;
/// <summary>
/// Gets the directory Dalamud assets are stored in.
/// </summary>
/// <inheritdoc/>
public DirectoryInfo DalamudAssetDirectory => Service<Dalamud>.Get().AssetDirectory;
/// <summary>
/// Gets the location of your plugin assembly.
/// </summary>
/// <inheritdoc/>
public FileInfo AssemblyLocation => this.plugin.DllFile;
/// <summary>
/// Gets the directory your plugin configurations are stored in.
/// </summary>
/// <inheritdoc/>
public DirectoryInfo ConfigDirectory => new(this.GetPluginConfigDirectory());
/// <summary>
/// Gets the config file of your plugin.
/// </summary>
/// <inheritdoc/>
public FileInfo ConfigFile => this.configs.GetConfigFile(this.plugin.InternalName);
/// <summary>
/// Gets the <see cref="UiBuilder"/> instance which allows you to draw UI into the game via ImGui draw calls.
/// </summary>
/// <inheritdoc/>
public IUiBuilder UiBuilder { get; private set; }
/// <summary>
/// Gets a value indicating whether Dalamud is running in Debug mode or the /xldev menu is open. This can occur on release builds.
/// </summary>
/// <inheritdoc/>
public bool IsDevMenuOpen => Service<DalamudInterface>.GetNullable() is { IsDevMenuOpen: true }; // Can be null during boot
/// <summary>
/// Gets a value indicating whether a debugger is attached.
/// </summary>
/// <inheritdoc/>
public bool IsDebugging => Debugger.IsAttached;
/// <summary>
/// Gets the current UI language in two-letter iso format.
/// </summary>
/// <inheritdoc/>
public string UiLanguage { get; private set; }
/// <summary>
/// Gets serializer class with functions to remove special characters from strings.
/// </summary>
/// <inheritdoc/>
public ISanitizer Sanitizer { get; }
/// <summary>
/// Gets the chat type used by default for plugin messages.
/// </summary>
/// <inheritdoc/>
public XivChatType GeneralChatType { get; private set; }
/// <summary>
/// Gets a list of installed plugins along with their current state.
/// </summary>
/// <inheritdoc/>
public IEnumerable<IExposedPlugin> InstalledPlugins =>
Service<PluginManager>.Get().InstalledPlugins.Select(p => new ExposedPlugin(p));
@ -214,12 +161,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
/// </summary>
internal UiBuilder LocalUiBuilder => this.uiBuilder;
/// <summary>
/// Opens the <see cref="PluginInstallerWindow"/>, with an optional search term.
/// </summary>
/// <param name="openTo">The page to open the installer to. Defaults to the "All Plugins" page.</param>
/// <param name="searchText">An optional search text to input in the search box.</param>
/// <returns>Returns false if the DalamudInterface was null.</returns>
/// <inheritdoc/>
public bool OpenPluginInstallerTo(PluginInstallerOpenKind openTo = PluginInstallerOpenKind.AllPlugins, string? searchText = null)
{
var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot
@ -234,12 +176,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
return true;
}
/// <summary>
/// Opens the <see cref="SettingsWindow"/>, with an optional search term.
/// </summary>
/// <param name="openTo">The tab to open the settings to. Defaults to the "General" tab.</param>
/// <param name="searchText">An optional search text to input in the search box.</param>
/// <returns>Returns false if the DalamudInterface was null.</returns>
/// <inheritdoc/>
public bool OpenDalamudSettingsTo(SettingsOpenKind openTo = SettingsOpenKind.General, string? searchText = null)
{
var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot
@ -254,10 +191,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
return true;
}
/// <summary>
/// Opens the dev menu bar.
/// </summary>
/// <returns>Returns false if the DalamudInterface was null.</returns>
/// <inheritdoc/>
public bool OpenDeveloperMenu()
{
var dalamudInterface = Service<DalamudInterface>.GetNullable(); // Can be null during boot
@ -296,102 +230,91 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
#region IPC
/// <inheritdoc cref="DataShare.GetOrCreateData{T}"/>
/// <inheritdoc/>
public T GetOrCreateData<T>(string tag, Func<T> dataGenerator) where T : class
=> Service<DataShare>.Get().GetOrCreateData(tag, dataGenerator);
/// <inheritdoc cref="DataShare.RelinquishData"/>
/// <inheritdoc/>
public void RelinquishData(string tag)
=> Service<DataShare>.Get().RelinquishData(tag);
/// <inheritdoc cref="DataShare.TryGetData{T}"/>
/// <inheritdoc/>
public bool TryGetData<T>(string tag, [NotNullWhen(true)] out T? data) where T : class
=> Service<DataShare>.Get().TryGetData(tag, out data);
/// <inheritdoc cref="DataShare.GetData{T}"/>
/// <inheritdoc/>
public T? GetData<T>(string tag) where T : class
=> Service<DataShare>.Get().GetData<T>(tag);
/// <summary>
/// Gets an IPC provider.
/// </summary>
/// <typeparam name="TRet">The return type for funcs. Use object if this is unused.</typeparam>
/// <param name="name">The name of the IPC registration.</param>
/// <returns>An IPC provider.</returns>
/// <exception cref="IpcTypeMismatchError">This is thrown when the requested types do not match the previously registered types are different.</exception>
/// <inheritdoc/>
public ICallGateProvider<TRet> GetIpcProvider<TRet>(string name)
=> new CallGatePubSub<TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/>
/// <inheritdoc/>
public ICallGateProvider<T1, TRet> GetIpcProvider<T1, TRet>(string name)
=> new CallGatePubSub<T1, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/>
/// <inheritdoc/>
public ICallGateProvider<T1, T2, TRet> GetIpcProvider<T1, T2, TRet>(string name)
=> new CallGatePubSub<T1, T2, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/>
/// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, TRet> GetIpcProvider<T1, T2, T3, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/>
/// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, TRet> GetIpcProvider<T1, T2, T3, T4, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/>
/// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, T5, TRet> GetIpcProvider<T1, T2, T3, T4, T5, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/>
/// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, T5, T6, TRet> GetIpcProvider<T1, T2, T3, T4, T5, T6, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/>
/// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, T5, T6, T7, TRet> GetIpcProvider<T1, T2, T3, T4, T5, T6, T7, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, TRet>(name);
/// <inheritdoc cref="ICallGateProvider{TRet}"/>
/// <inheritdoc/>
public ICallGateProvider<T1, T2, T3, T4, T5, T6, T7, T8, TRet> GetIpcProvider<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(name);
/// <summary>
/// Gets an IPC subscriber.
/// </summary>
/// <typeparam name="TRet">The return type for funcs. Use object if this is unused.</typeparam>
/// <param name="name">The name of the IPC registration.</param>
/// <returns>An IPC subscriber.</returns>
/// <inheritdoc/>
public ICallGateSubscriber<TRet> GetIpcSubscriber<TRet>(string name)
=> new CallGatePubSub<TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/>
/// <inheritdoc/>
public ICallGateSubscriber<T1, TRet> GetIpcSubscriber<T1, TRet>(string name)
=> new CallGatePubSub<T1, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/>
/// <inheritdoc/>
public ICallGateSubscriber<T1, T2, TRet> GetIpcSubscriber<T1, T2, TRet>(string name)
=> new CallGatePubSub<T1, T2, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/>
/// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, TRet> GetIpcSubscriber<T1, T2, T3, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/>
/// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, TRet> GetIpcSubscriber<T1, T2, T3, T4, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/>
/// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, T5, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/>
/// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, T5, T6, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, T6, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/>
/// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, T5, T6, T7, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, T6, T7, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, TRet>(name);
/// <inheritdoc cref="ICallGateSubscriber{TRet}"/>
/// <inheritdoc/>
public ICallGateSubscriber<T1, T2, T3, T4, T5, T6, T7, T8, TRet> GetIpcSubscriber<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(string name)
=> new CallGatePubSub<T1, T2, T3, T4, T5, T6, T7, T8, TRet>(name);
@ -399,10 +322,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
#region Configuration
/// <summary>
/// Save a plugin configuration(inheriting IPluginConfiguration).
/// </summary>
/// <param name="currentConfig">The current configuration.</param>
/// <inheritdoc/>
public void SavePluginConfig(IPluginConfiguration? currentConfig)
{
if (currentConfig == null)
@ -411,10 +331,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
this.configs.Save(currentConfig, this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId);
}
/// <summary>
/// Get a previously saved plugin configuration or null if none was saved before.
/// </summary>
/// <returns>A previously saved config or null if none was saved before.</returns>
/// <inheritdoc/>
public IPluginConfiguration? GetPluginConfig()
{
// This is done to support json deserialization of plugin configurations
@ -438,22 +355,22 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
return this.configs.Load(this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId);
}
/// <summary>
/// Get the config directory.
/// </summary>
/// <returns>directory with path of AppData/XIVLauncher/pluginConfig/PluginInternalName.</returns>
/// <inheritdoc/>
public string GetPluginConfigDirectory() => this.configs.GetDirectory(this.plugin.InternalName);
/// <summary>
/// Get the loc directory.
/// </summary>
/// <returns>directory with path of AppData/XIVLauncher/pluginConfig/PluginInternalName/loc.</returns>
/// <inheritdoc/>
public string GetPluginLocDirectory() => this.configs.GetDirectory(Path.Combine(this.plugin.InternalName, "loc"));
#endregion
#region Dependency Injection
/// <inheritdoc/>
public object? GetService(Type serviceType)
{
return this.plugin.ServiceScope.GetService(serviceType);
}
/// <inheritdoc/>
public T? Create<T>(params object[] scopedObjects) where T : class
{
@ -502,8 +419,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
#endregion
/// <summary>Unregister the plugin and dispose all references.</summary>
/// <remarks>Dalamud internal use only.</remarks>
/// <inheritdoc/>
public void Dispose()
{
Service<ChatGui>.Get().RemoveChatLinkHandler(this.plugin.InternalName);

View file

@ -8,8 +8,6 @@ using System.Threading.Tasks;
using Dalamud.Configuration;
using Dalamud.Game.Text;
using Dalamud.Game.Text.Sanitizer;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface;
using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Interface.Internal.Windows.Settings;
@ -24,7 +22,7 @@ namespace Dalamud.Plugin;
/// <summary>
/// This interface acts as an interface to various objects needed to interact with Dalamud and the game.
/// </summary>
public interface IDalamudPluginInterface
public interface IDalamudPluginInterface : IServiceProvider
{
/// <summary>
/// Delegate for localization change with two-letter iso lang code.

View file

@ -1,4 +1,4 @@
using Dalamud.Game.Addon.Events;
using Dalamud.Game.Addon.Events;
using Dalamud.Game.Addon.Events.EventDataTypes;
namespace Dalamud.Plugin.Services;
@ -6,7 +6,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// Service provider for addon event management.
/// </summary>
public interface IAddonEventManager
public interface IAddonEventManager : IDalamudService
{
/// <summary>
/// Delegate to be called when an event is received.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Dalamud.Game.Addon.Lifecycle;
@ -9,7 +9,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This class provides events for in-game addon lifecycles.
/// </summary>
public interface IAddonLifecycle
public interface IAddonLifecycle : IDalamudService
{
/// <summary>
/// Delegate for receiving addon lifecycle event messages.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Game.ClientState.Aetherytes;
@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This collection represents the list of available Aetherytes in the Teleport window.
/// </summary>
public interface IAetheryteList : IReadOnlyCollection<IAetheryteEntry>
public interface IAetheryteList : IDalamudService, IReadOnlyCollection<IAetheryteEntry>
{
/// <summary>
/// Gets the amount of Aetherytes the local player has unlocked.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Game.ClientState.Buddy;
@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services;
/// This collection represents the buddies present in your squadron or trust party.
/// It does not include the local player.
/// </summary>
public interface IBuddyList : IReadOnlyCollection<IBuddyMember>
public interface IBuddyList : IDalamudService, IReadOnlyCollection<IBuddyMember>
{
/// <summary>
/// Gets the amount of battle buddies the local player has.

View file

@ -10,7 +10,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This class handles interacting with the native chat UI.
/// </summary>
public interface IChatGui
public interface IChatGui : IDalamudService
{
/// <summary>
/// A delegate type used with the <see cref="ChatGui.ChatMessage"/> event.

View file

@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This class represents the state of the game client at the time of access.
/// </summary>
public interface IClientState
public interface IClientState : IDalamudService
{
/// <summary>
/// A delegate type used for the <see cref="ClassJobChanged"/> event.
@ -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,4 +1,4 @@
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using Dalamud.Game.Command;
@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This class manages registered in-game slash commands.
/// </summary>
public interface ICommandManager
public interface ICommandManager : IDalamudService
{
/// <summary>
/// Gets a read-only list of all registered commands.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Game.ClientState.Conditions;
@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// Provides access to conditions (generally player state). You can check whether a player is in combat, mounted, etc.
/// </summary>
public interface ICondition
public interface ICondition : IDalamudService
{
/// <summary>
/// A delegate type used with the <see cref="ConditionChange"/> event.

View file

@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Dalamud.Console;
@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services;
/// Provides functions to register console commands and variables.
/// </summary>
[Experimental("Dalamud001")]
public interface IConsole
public interface IConsole : IDalamudService
{
/// <summary>
/// Gets this plugin's namespace prefix, derived off its internal name.

View file

@ -5,7 +5,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This class provides methods for interacting with the game's context menu.
/// </summary>
public interface IContextMenu
public interface IContextMenu : IDalamudService
{
/// <summary>
/// A delegate type used for the <see cref="OnMenuOpened"/> event.

View file

@ -0,0 +1,10 @@
namespace Dalamud.Plugin.Services;
/// <summary>
/// Marker interface for Dalamud services.
/// </summary>
/// <remarks>
/// This interface is implemented by all services provided through Dalamud's
/// dependency injection system.
/// </remarks>
public interface IDalamudService;

View file

@ -14,7 +14,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This class provides data for Dalamud-internal features, but can also be used by plugins if needed.
/// </summary>
public interface IDataManager
public interface IDataManager : IDalamudService
{
/// <summary>
/// Gets the current game client language.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Game.Gui.Dtr;
using Dalamud.Game.Text.SeStringHandling;
@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// Class used to interface with the server info bar.
/// </summary>
public interface IDtrBar
public interface IDtrBar : IDalamudService
{
/// <summary>
/// Gets a read-only copy of the list of all DTR bar entries.

View file

@ -1,9 +1,9 @@
namespace Dalamud.Plugin.Services;
namespace Dalamud.Plugin.Services;
/// <summary>
/// This class represents the state of the currently occupied duty.
/// </summary>
public interface IDutyState
public interface IDutyState : IDalamudService
{
/// <summary>
/// Event that gets fired when the duty starts.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Game.ClientState.Fates;
@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This collection represents the currently available Fate events.
/// </summary>
public interface IFateTable : IReadOnlyCollection<IFate>
public interface IFateTable : IDalamudService, IReadOnlyCollection<IFate>
{
/// <summary>
/// Gets the address of the Fate table.

View file

@ -1,4 +1,4 @@
using Dalamud.Game.Gui.FlyText;
using Dalamud.Game.Gui.FlyText;
using Dalamud.Game.Text.SeStringHandling;
namespace Dalamud.Plugin.Services;
@ -6,7 +6,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This class facilitates interacting with and creating native in-game "fly text".
/// </summary>
public interface IFlyTextGui
public interface IFlyTextGui : IDalamudService
{
/// <summary>
/// The delegate defining the type for the FlyText event.

View file

@ -1,4 +1,4 @@
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -24,7 +24,7 @@ namespace Dalamud.Plugin.Services;
/// <para>See <see cref="TaskSchedulerWidget"/> to see the difference in behaviors, and how would a misuse of these
/// functions result in a deadlock.</para>
/// </remarks>
public interface IFramework
public interface IFramework : IDalamudService
{
/// <summary>
/// A delegate type used with the <see cref="Update"/> event.

View file

@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using Dalamud.Game.Config;
using Dalamud.Plugin.Internal.Types;
@ -17,7 +17,7 @@ namespace Dalamud.Plugin.Services;
/// If property access from the plugin constructor is desired, do the value retrieval asynchronously via
/// <see cref="IFramework.RunOnFrameworkThread{T}(Func{T})"/>; do not wait for the result right away.
/// </remarks>
public interface IGameConfig
public interface IGameConfig : IDalamudService
{
/// <summary>
/// Event which is fired when any game config option is changed.

View file

@ -9,7 +9,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// A class handling many aspects of the in-game UI.
/// </summary>
public unsafe interface IGameGui
public unsafe interface IGameGui : IDalamudService
{
/// <summary>
/// Event which is fired when the game UI hiding is toggled.

View file

@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using Dalamud.Hooking;
using Dalamud.Utility.Signatures;
@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// Service responsible for the creation of hooks.
/// </summary>
public interface IGameInteropProvider
public interface IGameInteropProvider : IDalamudService
{
/// <summary>
/// Available hooking backends.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Game.Inventory;
using Dalamud.Game.Inventory.InventoryEventArgTypes;
@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This class provides events for the in-game inventory.
/// </summary>
public interface IGameInventory
public interface IGameInventory : IDalamudService
{
/// <summary>
/// Delegate function to be called when inventories have been changed.

View file

@ -1,11 +1,11 @@
using System.Threading;
using System.Threading;
namespace Dalamud.Plugin.Services;
/// <summary>
/// Class offering cancellation tokens for common gameplay events.
/// </summary>
public interface IGameLifecycle
public interface IGameLifecycle : IDalamudService
{
/// <summary>
/// Gets a token that is cancelled when Dalamud is unloading.

View file

@ -1,4 +1,4 @@
using Dalamud.Game.Network;
using Dalamud.Game.Network;
namespace Dalamud.Plugin.Services;
@ -6,7 +6,7 @@ namespace Dalamud.Plugin.Services;
/// This class handles interacting with game network events.
/// </summary>
[Obsolete("Will be removed in a future release. Use packet handler hooks instead.", true)]
public interface IGameNetwork
public interface IGameNetwork : IDalamudService
{
// TODO(v9): we shouldn't be passing pointers to the actual data here

View file

@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState.GamePad;
@ -10,7 +10,7 @@ namespace Dalamud.Plugin.Services;
///
/// Will block game's gamepad input if <see cref="ImGuiConfigFlags.NavEnableGamepad"/> is set.
/// </summary>
public interface IGamepadState
public interface IGamepadState : IDalamudService
{
/// <summary>
/// Gets the pointer to the current instance of the GamepadInput struct.

View file

@ -1,11 +1,11 @@
using Dalamud.Game.ClientState.JobGauge.Types;
using Dalamud.Game.ClientState.JobGauge.Types;
namespace Dalamud.Plugin.Services;
/// <summary>
/// This class converts in-memory Job gauge data to structs.
/// </summary>
public interface IJobGauges
public interface IJobGauges : IDalamudService
{
/// <summary>
/// Gets the address of the JobGauge data.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Game.ClientState.Keys;
@ -16,7 +16,7 @@ namespace Dalamud.Plugin.Services;
/// index &amp; 2 = key up (ephemeral).
/// index &amp; 3 = short key press (ephemeral).
/// </remarks>
public interface IKeyState
public interface IKeyState : IDalamudService
{
/// <summary>
/// Get or set the key-pressed state for a given vkCode.

View file

@ -1,11 +1,11 @@
using Dalamud.Game.Network.Structures;
using Dalamud.Game.Network.Structures;
namespace Dalamud.Plugin.Services;
/// <summary>
/// Provides access to market board related events as the client receives/sends them.
/// </summary>
public interface IMarketBoard
public interface IMarketBoard : IDalamudService
{
/// <summary>
/// A delegate type used with the <see cref="HistoryReceived"/> event.

View file

@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// Class used to modify the data used when rendering nameplates.
/// </summary>
public interface INamePlateGui
public interface INamePlateGui : IDalamudService
{
/// <summary>
/// The delegate used for receiving nameplate update events.

View file

@ -3,7 +3,7 @@ using Dalamud.Interface.ImGuiNotification;
namespace Dalamud.Plugin.Services;
/// <summary>Manager for notifications provided by Dalamud using ImGui.</summary>
public interface INotificationManager
public interface INotificationManager : IDalamudService
{
/// <summary>Adds a notification.</summary>
/// <param name="notification">The new notification.</param>

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;
@ -7,7 +8,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This collection represents the currently spawned FFXIV game objects.
/// </summary>
public interface IObjectTable : IEnumerable<IGameObject>
public interface IObjectTable : IDalamudService, IEnumerable<IGameObject>
{
/// <summary>
/// Gets the address of the object table.
@ -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

@ -1,11 +1,11 @@
using Dalamud.Game.Gui.PartyFinder.Types;
using Dalamud.Game.Gui.PartyFinder.Types;
namespace Dalamud.Plugin.Services;
/// <summary>
/// This class handles interacting with the native PartyFinder window.
/// </summary>
public interface IPartyFinderGui
public interface IPartyFinderGui : IDalamudService
{
/// <summary>
/// Event type fired each time the game receives an individual Party Finder listing.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Game.ClientState.Party;
@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This collection represents the actors present in your party or alliance.
/// </summary>
public interface IPartyList : IReadOnlyCollection<IPartyMember>
public interface IPartyList : IDalamudService, IReadOnlyCollection<IPartyMember>
{
/// <summary>
/// Gets the amount of party members the local player has.

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 : IDalamudService
{
/// <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

@ -1,4 +1,4 @@
using Serilog;
using Serilog;
using Serilog.Events;
#pragma warning disable CS1573 // See https://github.com/dotnet/roslyn/issues/40325
@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// An opinionated service to handle logging for plugins.
/// </summary>
public interface IPluginLog
public interface IPluginLog : IDalamudService
{
/// <summary>
/// Gets a Serilog ILogger instance for this plugin. This is the entrypoint for plugins that wish to use more

View file

@ -9,7 +9,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// Defines a service for retrieving localized text for various in-game entities.
/// </summary>
public interface ISeStringEvaluator
public interface ISeStringEvaluator : IDalamudService
{
/// <summary>
/// Evaluates macros in a <see cref="ReadOnlySeString"/>.

View file

@ -2,12 +2,14 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using Dalamud.Plugin.Services;
namespace Dalamud.Game;
/// <summary>
/// A SigScanner facilitates searching for memory signatures in a given ProcessModule.
/// </summary>
public interface ISigScanner
public interface ISigScanner : IDalamudService
{
/// <summary>
/// Gets a value indicating whether the search on this module is performed on a copy.

View file

@ -1,11 +1,12 @@
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Plugin.Services;
namespace Dalamud.Game.ClientState.Objects;
/// <summary>
/// Get and set various kinds of targets for the player.
/// </summary>
public interface ITargetManager
public interface ITargetManager : IDalamudService
{
/// <summary>
/// Gets or sets the current target.

View file

@ -32,7 +32,7 @@ namespace Dalamud.Plugin.Services;
/// <see cref="TexWidget"/>.
/// </para>
/// </remarks>
public interface ITextureProvider
public interface ITextureProvider : IDalamudService
{
/// <summary>Creates an empty texture.</summary>
/// <param name="specs">Texture specifications.</param>

View file

@ -3,14 +3,13 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
namespace Dalamud.Plugin.Services;
/// <summary>Service that grants you to read instances of <see cref="IDalamudTextureWrap"/>.</summary>
public interface ITextureReadbackProvider
public interface ITextureReadbackProvider : IDalamudService
{
/// <summary>Gets the raw data of a texture wrap.</summary>
/// <param name="wrap">The source texture wrap.</param>

View file

@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace Dalamud.Plugin.Services;
/// <summary>
/// Service that grants you the ability to replace texture data that is to be loaded by Dalamud.
/// </summary>
public interface ITextureSubstitutionProvider
public interface ITextureSubstitutionProvider : IDalamudService
{
/// <summary>
/// Delegate describing a function that may be used to intercept and replace texture data.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Interface;
using Dalamud.Interface.Textures;
@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// Interface for class responsible for managing elements in the title screen menu.
/// </summary>
public interface ITitleScreenMenu
public interface ITitleScreenMenu : IDalamudService
{
/// <summary>
/// Gets the list of read only entries in the title screen menu.

View file

@ -1,4 +1,4 @@
using Dalamud.Game.Gui.Toast;
using Dalamud.Game.Gui.Toast;
using Dalamud.Game.Text.SeStringHandling;
namespace Dalamud.Plugin.Services;
@ -6,7 +6,7 @@ namespace Dalamud.Plugin.Services;
/// <summary>
/// This class facilitates interacting with and creating native toast windows.
/// </summary>
public interface IToastGui
public interface IToastGui : IDalamudService
{
/// <summary>
/// A delegate type used when a normal toast window appears.

View file

@ -11,7 +11,7 @@ namespace Dalamud.Plugin.Services;
/// Interface for determining unlock state of various content in the game.
/// </summary>
[Experimental("UnlockState")]
public interface IUnlockState
public interface IUnlockState : IDalamudService
{
/// <summary>
/// A delegate type used for the <see cref="Unlock"/> event.

View file

@ -9,11 +9,14 @@ using System.Threading.Tasks;
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Services;
using Dalamud.Storage;
using Dalamud.Utility;
using Dalamud.Utility.Timing;
using JetBrains.Annotations;
// API10 TODO: Move to Dalamud.Service namespace. Some plugins reflect this... including my own, oops. There's a todo
@ -541,9 +544,11 @@ internal static class ServiceManager
if (attr == null)
return ServiceKind.None;
Debug.Assert(
type.IsAssignableTo(typeof(IServiceType)),
"Service did not inherit from IServiceType");
if (!type.IsAssignableTo(typeof(IServiceType)))
{
Log.Error($"Service {type.Name} did not inherit from IServiceType");
Debug.Fail("Service did not inherit from IServiceType");
}
if (attr.IsAssignableTo(typeof(BlockingEarlyLoadedServiceAttribute)))
return ServiceKind.BlockingEarlyLoadedService;
@ -552,7 +557,16 @@ internal static class ServiceManager
return ServiceKind.EarlyLoadedService;
if (attr.IsAssignableTo(typeof(ScopedServiceAttribute)))
{
if (type.GetCustomAttribute<PluginInterfaceAttribute>() != null
&& !type.IsAssignableTo(typeof(IDalamudService)))
{
Log.Error($"Plugin-scoped service {type.Name} must inherit from IDalamudService");
Debug.Fail("Plugin-scoped service must inherit from IDalamudService");
}
return ServiceKind.ScopedService;
}
return ServiceKind.ProvidedService;
}

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