Add mob retaliation (#19901)
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
using Content.Server.NPC.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.NPC.Systems;
|
||||
|
||||
/// <summary>
|
||||
/// Outlines faction relationships with each other.
|
||||
/// </summary>
|
||||
public sealed class NpcFactionSystem : EntitySystem
|
||||
public sealed partial class NpcFactionSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly FactionExceptionSystem _factionException = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
|
||||
@@ -26,6 +26,8 @@ public sealed class NpcFactionSystem : EntitySystem
|
||||
_sawmill = Logger.GetSawmill("faction");
|
||||
SubscribeLocalEvent<NpcFactionMemberComponent, ComponentStartup>(OnFactionStartup);
|
||||
_protoManager.PrototypesReloaded += OnProtoReload;
|
||||
|
||||
InitializeException();
|
||||
RefreshFactions();
|
||||
}
|
||||
|
||||
@@ -134,12 +136,15 @@ public sealed class NpcFactionSystem : EntitySystem
|
||||
if (TryComp<FactionExceptionComponent>(entity, out var factionException))
|
||||
{
|
||||
// ignore anything from enemy faction that we are explicitly friendly towards
|
||||
return hostiles.Where(target => !_factionException.IsIgnored(factionException, target));
|
||||
return hostiles
|
||||
.Union(GetHostiles(entity, factionException))
|
||||
.Where(target => !IsIgnored(entity, target, factionException));
|
||||
}
|
||||
|
||||
return hostiles;
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public IEnumerable<EntityUid> GetNearbyFriendlies(EntityUid entity, float range, NpcFactionMemberComponent? component = null)
|
||||
{
|
||||
if (!Resolve(entity, ref component, false))
|
||||
|
||||
Reference in New Issue
Block a user