CatStation/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/EnsureComponentOperator.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

29 lines
838 B
C#

using Robust.Shared.Prototypes;
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific;
public sealed partial class EnsureComponentOperator : HTNOperator
{
[Dependency] private 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;
}
}