mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* 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
29 lines
838 B
C#
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;
|
|
}
|
|
}
|