blob: 4bcd2c5d862806938f8f8ee4014a53f6bfff5cfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
namespace BehaviorDesigner.Runtime.Tasks
{
[TaskDescription("The until failure task will keep executing its child task until the child task returns failure.")]
[HelpURL("http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=41")]
[TaskIcon("{SkinColor}UntilFailureIcon.png")]
public class UntilFailure : Decorator
{
// The status of the child after it has finished running.
private TaskStatus executionStatus = TaskStatus.Inactive;
public override bool CanExecute()
{
// Keep running until the child task returns failure.
return executionStatus == TaskStatus.Success || executionStatus == TaskStatus.Inactive;
}
public override void OnChildExecuted(TaskStatus childStatus)
{
// Update the execution status after a child has finished running.
executionStatus = childStatus;
}
public override void OnEnd()
{
// Reset the execution status back to its starting values.
executionStatus = TaskStatus.Inactive;
}
}
}
|