add IsMemberOfAny to faction system (#32975)

* add IsMemberOfAny to faction system

* pro

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2024-11-01 02:34:27 +00:00
committed by GitHub
parent c8259c6c0f
commit c9cd778133

View File

@@ -81,6 +81,24 @@ public sealed partial class NpcFactionSystem : EntitySystem
return ent.Comp.Factions.Contains(faction);
}
/// <summary>
/// Returns whether an entity is a member of any listed faction.
/// If the list is empty this returns false.
/// </summary>
public bool IsMemberOfAny(Entity<NpcFactionMemberComponent?> ent, IEnumerable<ProtoId<NpcFactionPrototype>> 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;
}
/// <summary>
/// Adds this entity to the particular faction.
/// </summary>