From c9cd778133852af316db97da107214be33ec7a5d Mon Sep 17 00:00:00 2001
From: deltanedas <39013340+deltanedas@users.noreply.github.com>
Date: Fri, 1 Nov 2024 02:34:27 +0000
Subject: [PATCH] add IsMemberOfAny to faction system (#32975)
* add IsMemberOfAny to faction system
* pro
---------
Co-authored-by: deltanedas <@deltanedas:kde.org>
---
Content.Shared/NPC/Systems/NpcFactionSystem.cs | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/Content.Shared/NPC/Systems/NpcFactionSystem.cs b/Content.Shared/NPC/Systems/NpcFactionSystem.cs
index 98f14afe2a..0d684de80b 100644
--- a/Content.Shared/NPC/Systems/NpcFactionSystem.cs
+++ b/Content.Shared/NPC/Systems/NpcFactionSystem.cs
@@ -81,6 +81,24 @@ public sealed partial class NpcFactionSystem : EntitySystem
return ent.Comp.Factions.Contains(faction);
}
+ ///
+ /// Returns whether an entity is a member of any listed faction.
+ /// If the list is empty this returns false.
+ ///
+ public bool IsMemberOfAny(Entity ent, IEnumerable> factions)
+ {
+ if (!Resolve(ent, ref ent.Comp, false))
+ return false;
+
+ foreach (var faction in factions)
+ {
+ if (ent.Comp.Factions.Contains(faction))
+ return true;
+ }
+
+ return false;
+ }
+
///
/// Adds this entity to the particular faction.
///
--
2.51.2