2025-06-25 09:13:03 -04:00
|
|
|
using Content.Server.Hands.Systems;
|
2023-08-02 10:48:56 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.NPC.HTN.Preconditions;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns true if an entity is held in the active hand.
|
|
|
|
|
/// </summary>
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class ActiveHandEntityPrecondition : HTNPrecondition
|
2023-08-02 10:48:56 +10:00
|
|
|
{
|
|
|
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
|
|
|
|
|
|
|
|
public override bool IsMet(NPCBlackboard blackboard)
|
|
|
|
|
{
|
2025-06-25 09:13:03 -04:00
|
|
|
if (!blackboard.TryGetValue(NPCBlackboard.Owner, out EntityUid owner, _entManager) ||
|
|
|
|
|
!blackboard.TryGetValue(NPCBlackboard.ActiveHand, out string? activeHand, _entManager))
|
2023-08-02 10:48:56 +10:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 09:13:03 -04:00
|
|
|
return !_entManager.System<HandsSystem>().HandIsEmpty(owner, activeHand);
|
2023-08-02 10:48:56 +10:00
|
|
|
}
|
|
|
|
|
}
|