Add mob retaliation (#19901)

This commit is contained in:
Nemanja
2023-10-06 20:56:18 -04:00
committed by GitHub
parent 45234b25b6
commit 02df8cd263
10 changed files with 339 additions and 47 deletions

View File

@@ -6,12 +6,18 @@ namespace Content.Server.NPC.Components;
/// Prevents an NPC from attacking ignored entities from enemy factions.
/// Can be added to if pettable, see PettableFriendComponent.
/// </summary>
[RegisterComponent, Access(typeof(FactionExceptionSystem))]
[RegisterComponent, Access(typeof(NpcFactionSystem))]
public sealed partial class FactionExceptionComponent : Component
{
/// <summary>
/// List of entities that this NPC will refuse to attack
/// Collection of entities that this NPC will refuse to attack
/// </summary>
[DataField("ignored")]
public HashSet<EntityUid> Ignored = new();
/// <summary>
/// Collection of entities that this NPC will attack, regardless of faction.
/// </summary>
[DataField("hostiles")]
public HashSet<EntityUid> Hostiles = new();
}

View File

@@ -0,0 +1,16 @@
using Content.Server.NPC.Systems;
namespace Content.Server.NPC.Components;
/// <summary>
/// This is used for tracking entities stored in <see cref="FactionExceptionComponent"/>
/// </summary>
[RegisterComponent, Access(typeof(NpcFactionSystem))]
public sealed partial class FactionExceptionTrackerComponent : Component
{
/// <summary>
/// entities with <see cref="FactionExceptionComponent"/> that are tracking this entity.
/// </summary>
[DataField("entities")]
public HashSet<EntityUid> Entities = new();
}

View File

@@ -0,0 +1,24 @@
using Content.Server.NPC.Systems;
namespace Content.Server.NPC.Components;
/// <summary>
/// Entities with this component will retaliate against those who physically attack them.
/// It has an optional "memory" specification wherein it will only attack those entities for a specified length of time.
/// </summary>
[RegisterComponent, Access(typeof(NPCRetaliationSystem))]
public sealed partial class NPCRetaliationComponent : Component
{
/// <summary>
/// How long after being attacked will an NPC continue to be aggressive to the attacker for.
/// </summary>
[DataField("attackMemoryLength"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan? AttackMemoryLength;
/// <summary>
/// A dictionary that stores an entity and the time at which they will no longer be considered hostile.
/// </summary>
/// todo: this needs to support timeoffsetserializer at some point
[DataField("attackMemories")]
public Dictionary<EntityUid, TimeSpan> AttackMemories = new();
}