Files
wwdpublic/Content.Server/NPC/HTN/Preconditions/HandcuffedPrecondition.cs
IProduceWidgets 188bf9ff09 Allow ai to understand if its handcuffed. (#30402)
* allow ai to understand if its handcuffed.

* rerun tests they worky on local

* Contained here in, a string of expletives about flaky tests.

* on retrospect, default true is probably smorter.

* do reviews

* I forgor xml

* more xml

(cherry picked from commit 6bcdd23e84418be6ca86f39c632ce42e4ae81e31)
2025-01-15 18:11:42 +03:00

27 lines
757 B
C#

using Content.Server.Cuffs;
using Content.Shared.Cuffs.Components;
namespace Content.Server.NPC.HTN.Preconditions;
public sealed partial class HandcuffedPrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
[DataField]
public bool ReactOnlyWhenFullyCuffed = true;
public override bool IsMet(NPCBlackboard blackboard)
{
var cuffable = _entManager.System<CuffableSystem>();
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
if (!_entManager.TryGetComponent<CuffableComponent>(owner, out var cuffComp))
return false;
var target = (owner, cuffComp);
return cuffable.IsCuffed(target, ReactOnlyWhenFullyCuffed);
}
}