mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 21:03:43 +01:00
feat: New Condition APIs (#1842)
* feat: New Condition APIs - New methods for `ICondition`: - `AnyExcept` ensures the listed conditions are *not* present. - `OnlyAny` ensures that *only* the listed conditions are met. - `EqualTo` ensures that the condition state matches the listed set. - New `IsGameIdle` method in `IClientState` can be used to check if the player is not in any "active" game state.
This commit is contained in:
parent
8f36641f36
commit
1c03242aa9
4 changed files with 88 additions and 29 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
|
||||
namespace Dalamud.Plugin.Services;
|
||||
|
|
@ -81,4 +82,19 @@ public interface IClientState
|
|||
/// Gets a value indicating whether the client is currently in Group Pose (GPose) mode.
|
||||
/// </summary>
|
||||
public bool IsGPosing { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the client is currently "idle". This means a player is not logged in, or is notctively in combat
|
||||
/// or doing anything that we may not want to disrupt.
|
||||
/// </summary>
|
||||
/// <param name="blockingFlag">An outvar containing the first observed condition blocking the "idle" state. 0 if idle.</param>
|
||||
/// <returns>Returns true if the client is idle, false otherwise.</returns>
|
||||
public bool IsClientIdle(out ConditionFlag blockingFlag);
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the client is currently "idle". This means a player is not logged in, or is notctively in combat
|
||||
/// or doing anything that we may not want to disrupt.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if the client is idle, false otherwise.</returns>
|
||||
public bool IsClientIdle() => this.IsClientIdle(out _);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ public interface ICondition
|
|||
|
||||
/// <inheritdoc cref="this[int]"/>
|
||||
public bool this[ConditionFlag flag] => this[(int)flag];
|
||||
|
||||
/// <summary>
|
||||
/// Convert the conditions array to a set of all set condition flags.
|
||||
/// </summary>
|
||||
/// <returns>Returns a set.</returns>
|
||||
public IReadOnlySet<ConditionFlag> AsReadOnlySet();
|
||||
|
||||
/// <summary>
|
||||
/// Check if any condition flags are set.
|
||||
|
|
@ -55,8 +61,14 @@ public interface ICondition
|
|||
public bool Any(params ConditionFlag[] flags);
|
||||
|
||||
/// <summary>
|
||||
/// Check that *only* any of the condition flags specified are set. Useful to test if the client is in one of any
|
||||
/// of a few specific condiiton states.
|
||||
/// Check that the specified condition flags are *not* present in the current conditions.
|
||||
/// </summary>
|
||||
/// <param name="except">The array of flags to check.</param>
|
||||
/// <returns>Returns false if any of the listed conditions are present, true otherwise.</returns>
|
||||
public bool AnyExcept(params ConditionFlag[] except);
|
||||
|
||||
/// <summary>
|
||||
/// Check that *only* any of the condition flags specified are set.
|
||||
/// </summary>
|
||||
/// <param name="other">The array of flags to check.</param>
|
||||
/// <returns>Returns a bool.</returns>
|
||||
|
|
@ -68,11 +80,5 @@ public interface ICondition
|
|||
/// </summary>
|
||||
/// <param name="other">The array of flags to check.</param>
|
||||
/// <returns>Returns a bool.</returns>
|
||||
public bool OnlyAll(params ConditionFlag[] other);
|
||||
|
||||
/// <summary>
|
||||
/// Convert the conditions array to a set of all set condition flags.
|
||||
/// </summary>
|
||||
/// <returns>Returns a set.</returns>
|
||||
public IReadOnlySet<ConditionFlag> AsReadOnlySet();
|
||||
public bool EqualTo(params ConditionFlag[] other);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue