2024-05-08 19:18:03 +10:00
|
|
|
|
namespace Content.Server.NPC.HTN.Preconditions.Math;
|
|
|
|
|
|
|
2024-06-02 03:46:35 +10:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Checks if there is a float value for the specified <see cref="KeyFloatGreaterPrecondition.Key"/>
|
|
|
|
|
|
/// in the <see cref="NPCBlackboard"/> and the specified value is less then <see cref="KeyFloatGreaterPrecondition.Value"/>.
|
|
|
|
|
|
/// </summary>
|
2024-05-08 19:18:03 +10:00
|
|
|
|
public sealed partial class KeyFloatLessPrecondition : HTNPrecondition
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
|
|
|
|
|
2024-06-02 03:46:35 +10:00
|
|
|
|
[DataField(required: true), ViewVariables]
|
2024-05-08 19:18:03 +10:00
|
|
|
|
public string Key = string.Empty;
|
|
|
|
|
|
|
2024-06-02 03:46:35 +10:00
|
|
|
|
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
|
2024-05-08 19:18:03 +10:00
|
|
|
|
public float Value;
|
|
|
|
|
|
|
|
|
|
|
|
public override bool IsMet(NPCBlackboard blackboard)
|
|
|
|
|
|
{
|
|
|
|
|
|
return blackboard.TryGetValue<float>(Key, out var value, _entManager) && value < Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|