diff --git a/MiraAPI/Modifiers/ModifierComponent.cs b/MiraAPI/Modifiers/ModifierComponent.cs
index f8859e3..6335059 100644
--- a/MiraAPI/Modifiers/ModifierComponent.cs
+++ b/MiraAPI/Modifiers/ModifierComponent.cs
@@ -507,4 +507,61 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
{
return ActiveModifiers.Exists(x => x.UniqueId == id);
}
+
+ ///
+ /// Checks if a player has an active modifier by its type.
+ ///
+ /// Whether to check inactive modifiers (those pending to be added or removed).
+ /// The predicate to check the modifier.
+ /// The Type of the Modifier.
+ /// True if the Modifier is present, false otherwise.
+ [HideFromIl2Cpp]
+ public bool HasModifier(bool checkInactive, Func? predicate=null) where T : BaseModifier
+ {
+ return ActiveModifiers.Exists(MatchExpr) || (checkInactive && (_toAdd.Exists(MatchExpr) || _toRemove.Exists(MatchExpr)));
+ bool MatchExpr(BaseModifier bm) => bm is T modifier && (predicate == null || predicate(modifier));
+ }
+
+ ///
+ /// Checks if a player has an active modifier by its type.
+ ///
+ /// The modifier type.
+ /// Whether to check inactive modifiers (those pending to be added or removed).
+ /// The predicate to check the modifier.
+ /// True if the Modifier is present, false otherwise.
+ [HideFromIl2Cpp]
+ public bool HasModifier(Type type, bool checkInactive, Func? predicate=null)
+ {
+ return ActiveModifiers.Exists(MatchExpr) || (checkInactive && (_toAdd.Exists(MatchExpr) || _toRemove.Exists(MatchExpr)));
+ bool MatchExpr(BaseModifier bm) => bm.GetType() == type && (predicate == null || predicate(bm));
+ }
+
+ ///
+ /// Checks if a player has an active modifier by its type ID.
+ ///
+ /// The modifier's type ID.
+ /// Whether to check inactive modifiers (those pending to be added or removed).
+ /// The predicate to check the modifier.
+ /// True if the modifier is present, false otherwise.
+ [HideFromIl2Cpp]
+ public bool HasModifier(uint id, bool checkInactive, Func? predicate=null)
+ {
+ var type = ModifierManager.GetModifierType(id) ?? throw new InvalidOperationException(
+ $"Cannot get modifier with id {id} because it is not registered.");
+
+ return HasModifier(type, checkInactive, predicate);
+ }
+
+ ///
+ /// Checks if a player has an active modifier by its unique ID.
+ ///
+ /// The modifier's guid.
+ /// Whether to check inactive modifiers (those pending to be added or removed).
+ /// True if the modifier is present, false otherwise.
+ [HideFromIl2Cpp]
+ public bool HasModifier(Guid id, bool checkInactive)
+ {
+ return ActiveModifiers.Exists(MatchExpr) || (checkInactive && (_toAdd.Exists(MatchExpr) || _toRemove.Exists(MatchExpr)));
+ bool MatchExpr(BaseModifier bm) => bm.UniqueId == id;
+ }
}
diff --git a/MiraAPI/Modifiers/ModifierExtensions.cs b/MiraAPI/Modifiers/ModifierExtensions.cs
index ca49808..c028fa3 100644
--- a/MiraAPI/Modifiers/ModifierExtensions.cs
+++ b/MiraAPI/Modifiers/ModifierExtensions.cs
@@ -180,6 +180,17 @@ public static class ModifierExtensions
return player.GetModifierComponent().HasModifier(typeId, predicate);
}
+ ///
+ /// Checks if the player has a specific modifier by its GUID.
+ ///
+ /// The PlayerControl instance.
+ /// The unique ID of the modifier.
+ /// True if the player has the modifier, false otherwise.
+ public static bool HasModifier(this PlayerControl player, Guid uniqueId)
+ {
+ return player.GetModifierComponent().HasModifier(uniqueId);
+ }
+
///
/// Clears all modifiers from a player.
///
@@ -204,17 +215,6 @@ public static class ModifierExtensions
}
}
- ///
- /// Checks if the player has a specific modifier by its GUID.
- ///
- /// The PlayerControl instance.
- /// The unique ID of the modifier.
- /// True if the player has the modifier, false otherwise.
- public static bool HasModifier(this PlayerControl player, Guid uniqueId)
- {
- return player.GetModifierComponent().HasModifier(uniqueId);
- }
-
///
/// Tries to get a modifier by its type.
///
diff --git a/MiraAPI/Modifiers/ModifierManager.cs b/MiraAPI/Modifiers/ModifierManager.cs
index 8b67b4f..9f61239 100644
--- a/MiraAPI/Modifiers/ModifierManager.cs
+++ b/MiraAPI/Modifiers/ModifierManager.cs
@@ -105,6 +105,7 @@ public static class ModifierManager
// Filter and sort modifiers by descending priority.
var modifiers = IdToTypeModifierMap
+ .Where(x=>x.Value.IsAssignableTo(typeof(GameModifier)))
.Select(x => Activator.CreateInstance(x.Value) as GameModifier)
.OfType()
.Where(x => x.GetAmountPerGame() > 0 && x.GetAssignmentChance() > 0)