KeyNotExistsPrecondition.cs 521 B

12345678910111213141516
  1. namespace Content.Server.NPC.HTN.Preconditions;
  2. /// <summary>
  3. /// Checks if there is no value at the specified <see cref="KeyNotExistsPrecondition.Key"/> in the <see cref="NPCBlackboard"/>.
  4. /// Returns true if there is no value.
  5. /// </summary>
  6. public sealed partial class KeyNotExistsPrecondition : HTNPrecondition
  7. {
  8. [DataField(required: true), ViewVariables]
  9. public string Key = string.Empty;
  10. public override bool IsMet(NPCBlackboard blackboard)
  11. {
  12. return !blackboard.ContainsKey(Key);
  13. }
  14. }