mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-01 16:47:26 +00:00
* 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>
30 lines
847 B
C#
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;
|
|
}
|
|
}
|