using Content.Shared.Hands.Components; using Content.Shared.Nutrition.Components; using Robust.Shared.Prototypes; namespace Content.Server.NPC.HTN.Preconditions; /// /// Returns true if the active hand entity has the specified components. /// public sealed partial class HungryPrecondition : HTNPrecondition { [Dependency] private readonly IEntityManager _entManager = default!; [DataField(required: true)] public HungerThreshold MinHungerState = HungerThreshold.Starving; public override bool IsMet(NPCBlackboard blackboard) { if (!blackboard.TryGetValue(NPCBlackboard.Owner, out var owner, _entManager)) { return false; } return _entManager.TryGetComponent(owner, out var hunger) ? hunger.CurrentThreshold <= MinHungerState : false; } }