chore: ClientState => IClientState

This commit is contained in:
goat 2023-06-13 22:22:04 +02:00
parent 45f5bb4dbe
commit f1dfaa92c9
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
5 changed files with 147 additions and 91 deletions

View file

@ -26,7 +26,7 @@ csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion csharp_style_var_when_type_is_apparent = true:suggestion
dotnet_code_quality_unused_parameters = non_public dotnet_code_quality_unused_parameters = non_public
dotnet_naming_rule.event_rule.severity = warning dotnet_naming_rule.event_rule.severity = warning
dotnet_naming_rule.event_rule.style = on_upper_camel_case_style dotnet_naming_rule.event_rule.style = upper_camel_case_style
dotnet_naming_rule.event_rule.symbols = event_symbols dotnet_naming_rule.event_rule.symbols = event_symbols
dotnet_naming_rule.private_constants_rule.severity = warning dotnet_naming_rule.private_constants_rule.severity = warning
dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style

View file

@ -15,7 +15,9 @@ namespace Dalamud.Game.ClientState.Aetherytes;
[PluginInterface] [PluginInterface]
[InterfaceVersion("1.0")] [InterfaceVersion("1.0")]
[ServiceManager.BlockingEarlyLoadedService] [ServiceManager.BlockingEarlyLoadedService]
#pragma warning disable SA1015
[ResolveVia<IAetheryteList>] [ResolveVia<IAetheryteList>]
#pragma warning restore SA1015
public sealed unsafe partial class AetheryteList : IServiceType, IAetheryteList public sealed unsafe partial class AetheryteList : IServiceType, IAetheryteList
{ {
[ServiceManager.ServiceDependency] [ServiceManager.ServiceDependency]

View file

@ -9,6 +9,7 @@ using Dalamud.Game.Network.Internal;
using Dalamud.Hooking; using Dalamud.Hooking;
using Dalamud.IoC; using Dalamud.IoC;
using Dalamud.IoC.Internal; using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
using Dalamud.Utility; using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game;
using Serilog; using Serilog;
@ -21,7 +22,10 @@ namespace Dalamud.Game.ClientState;
[PluginInterface] [PluginInterface]
[InterfaceVersion("1.0")] [InterfaceVersion("1.0")]
[ServiceManager.BlockingEarlyLoadedService] [ServiceManager.BlockingEarlyLoadedService]
public sealed class ClientState : IDisposable, IServiceType #pragma warning disable SA1015
[ResolveVia<IClientState>]
#pragma warning restore SA1015
public sealed class ClientState : IDisposable, IServiceType, IClientState
{ {
private readonly GameLifecycle lifecycle; private readonly GameLifecycle lifecycle;
private readonly ClientStateAddressResolver address; private readonly ClientStateAddressResolver address;
@ -59,69 +63,43 @@ public sealed class ClientState : IDisposable, IServiceType
[UnmanagedFunctionPointer(CallingConvention.ThisCall)] [UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate IntPtr SetupTerritoryTypeDelegate(IntPtr manager, ushort terriType); private delegate IntPtr SetupTerritoryTypeDelegate(IntPtr manager, ushort terriType);
/// <summary> /// <inheritdoc/>
/// Event that gets fired when the current Territory changes.
/// </summary>
public event EventHandler<ushort> TerritoryChanged; public event EventHandler<ushort> TerritoryChanged;
/// <summary> /// <inheritdoc/>
/// Event that fires when a character is logging in, and the local character object is available.
/// </summary>
public event EventHandler Login; public event EventHandler Login;
/// <summary> /// <inheritdoc/>
/// Event that fires when a character is logging out.
/// </summary>
public event EventHandler Logout; public event EventHandler Logout;
/// <summary> /// <inheritdoc/>
/// Event that fires when a character is entering PvP.
/// </summary>
public event Action EnterPvP; public event Action EnterPvP;
/// <summary> /// <inheritdoc/>
/// Event that fires when a character is leaving PvP.
/// </summary>
public event Action LeavePvP; public event Action LeavePvP;
/// <summary> /// <inheritdoc/>
/// Event that gets fired when a duty is ready.
/// </summary>
public event EventHandler<Lumina.Excel.GeneratedSheets.ContentFinderCondition> CfPop; public event EventHandler<Lumina.Excel.GeneratedSheets.ContentFinderCondition> CfPop;
/// <summary> /// <inheritdoc/>
/// Gets the language of the client.
/// </summary>
public ClientLanguage ClientLanguage { get; } public ClientLanguage ClientLanguage { get; }
/// <summary> /// <inheritdoc/>
/// Gets the current Territory the player resides in.
/// </summary>
public ushort TerritoryType { get; private set; } public ushort TerritoryType { get; private set; }
/// <summary> /// <inheritdoc/>
/// Gets the local player character, if one is present.
/// </summary>
public PlayerCharacter? LocalPlayer => Service<ObjectTable>.GetNullable()?[0] as PlayerCharacter; public PlayerCharacter? LocalPlayer => Service<ObjectTable>.GetNullable()?[0] as PlayerCharacter;
/// <summary> /// <inheritdoc/>
/// Gets the content ID of the local character.
/// </summary>
public ulong LocalContentId => (ulong)Marshal.ReadInt64(this.address.LocalContentId); public ulong LocalContentId => (ulong)Marshal.ReadInt64(this.address.LocalContentId);
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether a character is logged in.
/// </summary>
public bool IsLoggedIn { get; private set; } public bool IsLoggedIn { get; private set; }
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether or not the user is playing PvP.
/// </summary>
public bool IsPvP { get; private set; } public bool IsPvP { get; private set; }
/// <summary> /// <inheritdoc/>
/// Gets a value indicating whether or not the user is playing PvP, excluding the Wolves' Den.
/// </summary>
public bool IsPvPExcludingDen { get; private set; } public bool IsPvPExcludingDen { get; private set; }
/// <summary> /// <summary>

View file

@ -462,252 +462,252 @@ public enum BitmapFontIcon : uint
/// <summary> /// <summary>
/// The Physical Damage icon. /// The Physical Damage icon.
/// </Summary> /// </summary>
DamagePhysical = 117, DamagePhysical = 117,
/// <summary> /// <summary>
/// The Magical Damage icon. /// The Magical Damage icon.
/// </Summary> /// </summary>
DamageMagical = 118, DamageMagical = 118,
/// <summary> /// <summary>
/// The Special Damage icon. /// The Special Damage icon.
/// </Summary> /// </summary>
DamageSpecial = 119, DamageSpecial = 119,
/// <summary> /// <summary>
/// A gold star icon with an orange exclamation mark. /// A gold star icon with an orange exclamation mark.
/// </Summary> /// </summary>
GoldStarProblem = 120, GoldStarProblem = 120,
/// <summary> /// <summary>
/// A blue star icon. /// A blue star icon.
/// </Summary> /// </summary>
BlueStar = 121, BlueStar = 121,
/// <summary> /// <summary>
/// A blue star icon with an orange exclamation mark. /// A blue star icon with an orange exclamation mark.
/// </Summary> /// </summary>
BlueStarProblem = 121, BlueStarProblem = 121,
/// <summary> /// <summary>
/// The Disconnecting icon. /// The Disconnecting icon.
/// </Summary> /// </summary>
Disconnecting = 124, Disconnecting = 124,
/// <summary> /// <summary>
/// The Do Not Disturb icon. /// The Do Not Disturb icon.
/// </Summary> /// </summary>
DoNotDisturb = 125, DoNotDisturb = 125,
/// <summary> /// <summary>
/// The Meteor icon. /// The Meteor icon.
/// </Summary> /// </summary>
Meteor = 126, Meteor = 126,
/// <summary> /// <summary>
/// The Role Playing icon. /// The Role Playing icon.
/// </Summary> /// </summary>
RolePlaying = 127, RolePlaying = 127,
/// <summary> /// <summary>
/// The Gladiator icon. /// The Gladiator icon.
/// </Summary> /// </summary>
Gladiator = 128, Gladiator = 128,
/// <summary> /// <summary>
/// The Pugilist icon. /// The Pugilist icon.
/// </Summary> /// </summary>
Pugilist = 129, Pugilist = 129,
/// <summary> /// <summary>
/// The Marauder icon. /// The Marauder icon.
/// </Summary> /// </summary>
Marauder = 130, Marauder = 130,
/// <summary> /// <summary>
/// The Lancer icon. /// The Lancer icon.
/// </Summary> /// </summary>
Lancer = 131, Lancer = 131,
/// <summary> /// <summary>
/// The Archer icon. /// The Archer icon.
/// </Summary> /// </summary>
Archer = 132, Archer = 132,
/// <summary> /// <summary>
/// The Conjurer icon. /// The Conjurer icon.
/// </Summary> /// </summary>
Conjurer = 133, Conjurer = 133,
/// <summary> /// <summary>
/// The Thaumaturge icon. /// The Thaumaturge icon.
/// </Summary> /// </summary>
Thaumaturge = 134, Thaumaturge = 134,
/// <summary> /// <summary>
/// The Carpenter icon. /// The Carpenter icon.
/// </Summary> /// </summary>
Carpenter = 135, Carpenter = 135,
/// <summary> /// <summary>
/// The Blacksmith icon. /// The Blacksmith icon.
/// </Summary> /// </summary>
Blacksmith = 136, Blacksmith = 136,
/// <summary> /// <summary>
/// The Armorer icon. /// The Armorer icon.
/// </Summary> /// </summary>
Armorer = 137, Armorer = 137,
/// <summary> /// <summary>
/// The Goldsmith icon. /// The Goldsmith icon.
/// </Summary> /// </summary>
Goldsmith = 138, Goldsmith = 138,
/// <summary> /// <summary>
/// The Leatherworker icon. /// The Leatherworker icon.
/// </Summary> /// </summary>
Leatherworker = 139, Leatherworker = 139,
/// <summary> /// <summary>
/// The Weaver icon. /// The Weaver icon.
/// </Summary> /// </summary>
Weaver = 140, Weaver = 140,
/// <summary> /// <summary>
/// The Alchemist icon. /// The Alchemist icon.
/// </Summary> /// </summary>
Alchemist = 131, Alchemist = 131,
/// <summary> /// <summary>
/// The Culinarian icon. /// The Culinarian icon.
/// </Summary> /// </summary>
Culinarian = 132, Culinarian = 132,
/// <summary> /// <summary>
/// The Miner icon. /// The Miner icon.
/// </Summary> /// </summary>
Miner = 143, Miner = 143,
/// <summary> /// <summary>
/// The Botanist icon. /// The Botanist icon.
/// </Summary> /// </summary>
Botanist = 144, Botanist = 144,
/// <summary> /// <summary>
/// The Fisher icon. /// The Fisher icon.
/// </Summary> /// </summary>
Fisher = 145, Fisher = 145,
/// <summary> /// <summary>
/// The Paladin icon. /// The Paladin icon.
/// </Summary> /// </summary>
Paladin = 146, Paladin = 146,
/// <summary> /// <summary>
/// The Monk icon. /// The Monk icon.
/// </Summary> /// </summary>
Monk = 147, Monk = 147,
/// <summary> /// <summary>
/// The Warrior icon. /// The Warrior icon.
/// </Summary> /// </summary>
Warrior = 148, Warrior = 148,
/// <summary> /// <summary>
/// The Dragoon icon. /// The Dragoon icon.
/// </Summary> /// </summary>
Dragoon = 149, Dragoon = 149,
/// <summary> /// <summary>
/// The Bard icon. /// The Bard icon.
/// </Summary> /// </summary>
Bard = 150, Bard = 150,
/// <summary> /// <summary>
/// The White Mage icon. /// The White Mage icon.
/// </Summary> /// </summary>
WhiteMage = 151, WhiteMage = 151,
/// <summary> /// <summary>
/// The Black Mage icon. /// The Black Mage icon.
/// </Summary> /// </summary>
BlackMage = 152, BlackMage = 152,
/// <summary> /// <summary>
/// The Arcanist icon. /// The Arcanist icon.
/// </Summary> /// </summary>
Arcanist = 153, Arcanist = 153,
/// <summary> /// <summary>
/// The Summoner icon. /// The Summoner icon.
/// </Summary> /// </summary>
Summoner = 154, Summoner = 154,
/// <summary> /// <summary>
/// The Scholar icon. /// The Scholar icon.
/// </Summary> /// </summary>
Scholar = 155, Scholar = 155,
/// <summary> /// <summary>
/// The Rogue icon. /// The Rogue icon.
/// </Summary> /// </summary>
Rogue = 156, Rogue = 156,
/// <summary> /// <summary>
/// The Ninja icon. /// The Ninja icon.
/// </Summary> /// </summary>
Ninja = 157, Ninja = 157,
/// <summary> /// <summary>
/// The Machinist icon. /// The Machinist icon.
/// </Summary> /// </summary>
Machinist = 158, Machinist = 158,
/// <summary> /// <summary>
/// The Dark Knight icon. /// The Dark Knight icon.
/// </Summary> /// </summary>
DarkKnight = 159, DarkKnight = 159,
/// <summary> /// <summary>
/// The Astrologian icon. /// The Astrologian icon.
/// </Summary> /// </summary>
Astrologian = 160, Astrologian = 160,
/// <summary> /// <summary>
/// The Samurai icon. /// The Samurai icon.
/// </Summary> /// </summary>
Samurai = 161, Samurai = 161,
/// <summary> /// <summary>
/// The Red Mage icon. /// The Red Mage icon.
/// </Summary> /// </summary>
RedMage = 162, RedMage = 162,
/// <summary> /// <summary>
/// The Blue Mage icon. /// The Blue Mage icon.
/// </Summary> /// </summary>
BlueMage = 163, BlueMage = 163,
/// <summary> /// <summary>
/// The Gunbreaker icon. /// The Gunbreaker icon.
/// </Summary> /// </summary>
Gunbreaker = 164, Gunbreaker = 164,
/// <summary> /// <summary>
/// The Dancer icon. /// The Dancer icon.
/// </Summary> /// </summary>
Dancer = 165, Dancer = 165,
/// <summary> /// <summary>
/// The Reaper icon. /// The Reaper icon.
/// </Summary> /// </summary>
Reaper = 166, Reaper = 166,
/// <summary> /// <summary>
/// The Sage icon. /// The Sage icon.
/// </Summary> /// </summary>
Sage = 167, Sage = 167,
/// <summary> /// <summary>

View file

@ -0,0 +1,76 @@
using System;
using Dalamud.Game.ClientState.Objects.SubKinds;
namespace Dalamud.Plugin.Services;
/// <summary>
/// This class represents the state of the game client at the time of access.
/// </summary>
public interface IClientState
{
/// <summary>
/// Event that gets fired when the current Territory changes.
/// </summary>
public event EventHandler<ushort> TerritoryChanged;
/// <summary>
/// Event that fires when a character is logging in, and the local character object is available.
/// </summary>
public event EventHandler Login;
/// <summary>
/// Event that fires when a character is logging out.
/// </summary>
public event EventHandler Logout;
/// <summary>
/// Event that fires when a character is entering PvP.
/// </summary>
public event Action EnterPvP;
/// <summary>
/// Event that fires when a character is leaving PvP.
/// </summary>
public event Action LeavePvP;
/// <summary>
/// Event that gets fired when a duty is ready.
/// </summary>
public event EventHandler<Lumina.Excel.GeneratedSheets.ContentFinderCondition> CfPop;
/// <summary>
/// Gets the language of the client.
/// </summary>
public ClientLanguage ClientLanguage { get; }
/// <summary>
/// Gets the current Territory the player resides in.
/// </summary>
public ushort TerritoryType { get; }
/// <summary>
/// Gets the local player character, if one is present.
/// </summary>
public PlayerCharacter? LocalPlayer { get; }
/// <summary>
/// Gets the content ID of the local character.
/// </summary>
public ulong LocalContentId { get; }
/// <summary>
/// Gets a value indicating whether a character is logged in.
/// </summary>
public bool IsLoggedIn { get; }
/// <summary>
/// Gets a value indicating whether or not the user is playing PvP.
/// </summary>
public bool IsPvP { get; }
/// <summary>
/// Gets a value indicating whether or not the user is playing PvP, excluding the Wolves' Den.
/// </summary>
public bool IsPvPExcludingDen { get; }
}