ActiveHandEntityPrecondition.cs 589 B

123456789101112131415161718192021
  1. using Content.Shared.Hands.Components;
  2. namespace Content.Server.NPC.HTN.Preconditions;
  3. /// <summary>
  4. /// Returns true if an entity is held in the active hand.
  5. /// </summary>
  6. public sealed partial class ActiveHandEntityPrecondition : HTNPrecondition
  7. {
  8. [Dependency] private readonly IEntityManager _entManager = default!;
  9. public override bool IsMet(NPCBlackboard blackboard)
  10. {
  11. if (!blackboard.TryGetValue(NPCBlackboard.ActiveHand, out Hand? activeHand, _entManager))
  12. {
  13. return false;
  14. }
  15. return activeHand.HeldEntity != null;
  16. }
  17. }