SetBoolOperator.cs 853 B

1234567891011121314151617181920212223242526272829
  1. using System.Threading;
  2. using System.Threading.Tasks;
  3. namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Math;
  4. /// <summary>
  5. /// Set <see cref="SetBoolOperator.Value"/> to bool value for the
  6. /// specified <see cref="SetFloatOperator.TargetKey"/> in the <see cref="NPCBlackboard"/>.
  7. /// </summary>
  8. public sealed partial class SetBoolOperator : HTNOperator
  9. {
  10. [DataField(required: true), ViewVariables]
  11. public string TargetKey = string.Empty;
  12. [DataField, ViewVariables(VVAccess.ReadWrite)]
  13. public bool Value;
  14. public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard,
  15. CancellationToken cancelToken)
  16. {
  17. return (
  18. true,
  19. new Dictionary<string, object>
  20. {
  21. { TargetKey, Value }
  22. }
  23. );
  24. }
  25. }