Files
tbd-station-14/Content.Server/NPC/HTN/Preconditions/Math/KeyBoolEqualsPrecondition.cs
Tornado Tech a29b6a6894 Clean up new HTNs tasks (#28469)
* Clean up new HTNs tasks

* Added docs to math operations
2024-06-01 13:46:35 -04:00

25 lines
840 B
C#

namespace Content.Server.NPC.HTN.Preconditions.Math;
/// <summary>
/// Checks if there is a bool value for the specified <see cref="KeyBoolEqualsPrecondition.Key"/>
/// in the <see cref="NPCBlackboard"/> and the specified value is equal to the <see cref="KeyBoolEqualsPrecondition.Value"/>.
/// </summary>
public sealed partial class KeyBoolEqualsPrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
[DataField(required: true), ViewVariables]
public string Key = string.Empty;
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public bool Value;
public override bool IsMet(NPCBlackboard blackboard)
{
if (!blackboard.TryGetValue<bool>(Key, out var value, _entManager))
return false;
return Value == value;
}
}