blob: 77e0f77b75d08f77159cbe3b29295ef3dbc1bd08 (
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 success task will keep executing its child task until the child task returns success.")]
[HelpURL("http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=42")]
[TaskIcon("{SkinColor}UntilSuccessIcon.png")]
public class UntilSuccess : 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 success.
return executionStatus == TaskStatus.Failure || 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;
}
}
}
|