PerformInterruption.cs 1.2 KB

12345678910111213141516171819202122232425262728
  1. namespace BehaviorDesigner.Runtime.Tasks
  2. {
  3. [TaskDescription("Perform the actual interruption. This will immediately stop the specified tasks from running and will return success or failure depending on the value of interrupt success.")]
  4. [TaskIcon("{SkinColor}PerformInterruptionIcon.png")]
  5. public class PerformInterruption : Action
  6. {
  7. [Tooltip("The list of tasks to interrupt. Can be any number of tasks")]
  8. public Interrupt[] interruptTasks;
  9. [Tooltip("When we interrupt the task should we return a task status of success?")]
  10. public SharedBool interruptSuccess;
  11. public override TaskStatus OnUpdate()
  12. {
  13. // Loop through all of the tasks and fire an interruption. Once complete return success.
  14. for (int i = 0; i < interruptTasks.Length; ++i) {
  15. interruptTasks[i].DoInterrupt(interruptSuccess.Value ? TaskStatus.Success : TaskStatus.Failure);
  16. }
  17. return TaskStatus.Success;
  18. }
  19. public override void OnReset()
  20. {
  21. // Reset the properties back to their original values.
  22. interruptTasks = null;
  23. interruptSuccess = false;
  24. }
  25. }
  26. }