Files
tbd-station-14/Content.Server/NPC/HTN/Preconditions/Math/KeyBoolEqualsPrecondition.cs
Tornado Tech 31491775e5 Added new HTN operations and preconditions (#27486)
* Added new HTN operations & preconditions

* Ok I forgot about partial

* Namespace pierce the skies

* Some fixes, debug and new operators

* Bruh git eat my files
2024-05-08 12:18:03 +03:00

24 lines
670 B
C#

namespace Content.Server.NPC.HTN.Preconditions.Math;
/// <summary>
/// Checks for the presence of data in the blackboard and makes a comparison with the specified boolean
/// </summary>
public sealed partial class KeyBoolEqualsPrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
[DataField(required: true)]
public string Key = string.Empty;
[DataField(required: true)]
public bool Value;
public override bool IsMet(NPCBlackboard blackboard)
{
if (!blackboard.TryGetValue<bool>(Key, out var value, _entManager))
return false;
return Value == value;
}
}