Files
tbd-station-14/Content.Server/NPC/HTN/Preconditions/ThirstyPrecondition.cs
778b 439d6ff44e Fixed mice behavior of eating everything (#23322)
* Added precondition for EatTask

* Added Thirsty precondition for htn drink task

* Added start state for hungry and thirsty components

* Update nutrition.yml

* Fixed pascalcase's
2024-01-02 13:49:20 -05:00

27 lines
867 B
C#

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