HandcuffedPrecondition.cs 757 B

1234567891011121314151617181920212223242526
  1. using Content.Server.Cuffs;
  2. using Content.Shared.Cuffs.Components;
  3. namespace Content.Server.NPC.HTN.Preconditions;
  4. public sealed partial class HandcuffedPrecondition : HTNPrecondition
  5. {
  6. [Dependency] private readonly IEntityManager _entManager = default!;
  7. [DataField]
  8. public bool ReactOnlyWhenFullyCuffed = true;
  9. public override bool IsMet(NPCBlackboard blackboard)
  10. {
  11. var cuffable = _entManager.System<CuffableSystem>();
  12. var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
  13. if (!_entManager.TryGetComponent<CuffableComponent>(owner, out var cuffComp))
  14. return false;
  15. var target = (owner, cuffComp);
  16. return cuffable.IsCuffed(target, ReactOnlyWhenFullyCuffed);
  17. }
  18. }