diff --git a/Dalamud/Game/ClientState/Conditions/Condition.cs b/Dalamud/Game/ClientState/Conditions/Condition.cs index d281d7aec..23778288e 100644 --- a/Dalamud/Game/ClientState/Conditions/Condition.cs +++ b/Dalamud/Game/ClientState/Conditions/Condition.cs @@ -1,3 +1,5 @@ +using System.Linq; + using Dalamud.IoC; using Dalamud.IoC.Internal; using Dalamud.Plugin.Services; @@ -98,6 +100,20 @@ internal sealed class Condition : IInternalDisposableService, ICondition return false; } + /// + public bool Only(params ConditionFlag[] flags) + { + for (var i = 0; i < MaxConditionEntries; i++) + { + if (this[i] && flags.All(f => (int)f != i)) + { + return false; + } + } + + return true; + } + private void Dispose(bool disposing) { if (this.isDisposed) @@ -181,6 +197,9 @@ internal class ConditionPluginScoped : IInternalDisposableService, ICondition /// public bool Any(params ConditionFlag[] flags) => this.conditionService.Any(flags); + + /// + public bool Only(params ConditionFlag[] flags) => this.conditionService.Only(flags); private void ConditionChangedForward(ConditionFlag flag, bool value) => this.ConditionChange?.Invoke(flag, value); } diff --git a/Dalamud/Plugin/Services/ICondition.cs b/Dalamud/Plugin/Services/ICondition.cs index 9700cef5a..3b74c333c 100644 --- a/Dalamud/Plugin/Services/ICondition.cs +++ b/Dalamud/Plugin/Services/ICondition.cs @@ -51,4 +51,12 @@ public interface ICondition /// Whether any single provided flag is set. /// The condition flags to check. public bool Any(params ConditionFlag[] flags); + + /// + /// Check if none but the provided condition flags are set. + /// This is not an exclusive check, it will return true if the provided flags are the only ones set. + /// + /// The condition flags to check for. + /// Whether only flags passed in are set. + public bool Only(params ConditionFlag[] flags); }