Files
tbd-station-14/Content.Server/NPC/HTN/Preconditions/IsEmaggedPrecondition.cs
Centronias d3f85701f7 Adds HugBot (#37557)
* - hugbot
  - bdy with two arms because it needs two arms to hug
  - is constructable from:
    - box of hugs
    - proximity sensor
    - two borg arms
  - lots of voice lines
  - kinda like a medibot, it chases you down and then hugs you
    - except if it's emagged, then it punches you :)
    - it has a 2m cooldown per person by default

- MeleeAttackOperator
  - Read the doc, but it's an operator which makes the NPC hit a target exactly once assuming it's in range.
  - Used to make the hugbot attack
- RaiseEventForOwnerOperator
  - Read the doc, but it's an operator which raises an event on the owning NPC.
  - Used to make the hugbot hug extra code, specifically for the cooldown

- Changes to existing code:
  - `ComponentFilter : UtilityQueryFilter` gets `RetainWithComp` added which, as the name implies, retains entities with the specified comps rather than removing them. Basically, it lets you negate the filter.
  - `SpeakOperator : HTNOperator`'s `speech` field can use a `LocalizedDataSet` instead of just a locstring now
    - (I updated all of the existing usages for this)
  -

* two arms

* wait what if we just used mimebot arms so it doesn't look awful

* smort
2025-10-11 00:51:12 +00:00

32 lines
998 B
C#

using Content.Shared.Emag.Systems;
namespace Content.Server.NPC.HTN.Preconditions;
/// <summary>
/// A precondition which is met if the NPC is emagged with <see cref="EmagType"/>, as computed by
/// <see cref="EmagSystem.CheckFlag"/>. This is useful for changing NPC behavior in the case that the NPC is emagged,
/// eg. like a helper NPC bot turning evil.
/// </summary>
public sealed partial class IsEmaggedPrecondition : HTNPrecondition
{
private EmagSystem _emag;
/// <summary>
/// The type of emagging to check for.
/// </summary>
[DataField]
public EmagType EmagType = EmagType.Interaction;
public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
_emag = sysManager.GetEntitySystem<EmagSystem>();
}
public override bool IsMet(NPCBlackboard blackboard)
{
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
return _emag.CheckFlag(owner, EmagType);
}
}