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
dotnet_code_quality_unused_parameters = non_public
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.private_constants_rule.severity = warning
dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style

View file

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

View file

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

View file

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