From: deltanedas <39013340+deltanedas@users.noreply.github.com>
Date: Fri, 1 Nov 2024 02:34:27 +0000 (+0000)
Subject: add IsMemberOfAny to faction system (#32975)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=c9cd778133852af316db97da107214be33ec7a5d;p=space-station-14.git
add IsMemberOfAny to faction system (#32975)
* add IsMemberOfAny to faction system
* pro
---------
Co-authored-by: deltanedas <@deltanedas:kde.org>
---
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.
///