Files
Delta-v/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/EnsureComponentOperator.cs
T
70874e4cae Medibot doAfter and some other improvements (#32932)
* Medibot doAfter and some other improvements

* Clean-up

* Review fixes

* the army of medibots chasing someone is really funny

* misc cleanup

---------

Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
2026-06-29 12:43:36 +02:00

30 lines
847 B
C#

using Robust.Shared.Prototypes;
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific;
public sealed partial class EnsureComponentOperator : HTNOperator
{
[Dependency] private readonly IEntityManager _entMan = default!;
/// <summary>
/// Target entity to inject.
/// </summary>
[DataField(required: true)]
public string TargetKey = string.Empty;
/// <summary>
/// Components to be added
/// </summary>
[DataField]
public ComponentRegistry Components = new();
public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime)
{
if (!blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entMan))
return HTNOperatorStatus.Failed;
_entMan.AddComponents(target, Components);
return HTNOperatorStatus.Finished;
}
}