mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
24 lines
828 B
C#
24 lines
828 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 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;
|
|
}
|
|
}
|