E
- type of the blackboard object that tasks use to read or modify game state@TaskConstraint(minChildren=1, maxChildren=1) public abstract class Decorator<E> extends Task<E>
Decorator
is a wrapper that provides custom behavior for its child.
The child can be of any kind (branch task, leaf task, or another decorator).Task.Status
Modifier and Type | Field and Description |
---|---|
protected Task<E> |
child
The child task wrapped by this decorator
|
Constructor and Description |
---|
Decorator()
Creates a decorator with no child task.
|
Decorator(Task<E> child)
Creates a decorator that wraps the given task.
|
Modifier and Type | Method and Description |
---|---|
protected int |
addChildToTask(Task<E> child)
This method will add a child to the list of this task's children
|
void |
childFail(Task<E> runningTask)
This method will be called when one of the children of this task fails.
|
void |
childRunning(Task<E> runningTask,
Task<E> reporter)
This method will be called when one of the ancestors of this task needs to run again.
|
void |
childSuccess(Task<E> runningTask)
This method will be called when one of the children of this task succeeds.
|
protected Task<E> |
copyTo(Task<E> task)
Copies this task to the given task.
|
Task<E> |
getChild(int i) |
int |
getChildCount() |
void |
run()
This method contains the update logic of this task.
|
protected int addChildToTask(Task<E> child)
Task
addChildToTask
in class Task<E>
child
- the child task which will be addedpublic int getChildCount()
getChildCount
in class Task<E>
public void run()
Task
Task.running()
,
Task.success()
or Task.fail()
exactly once.public void childRunning(Task<E> runningTask, Task<E> reporter)
Task
childRunning
in class Task<E>
runningTask
- the task that needs to run againreporter
- the task that reports, usually one of this task's childrenpublic void childFail(Task<E> runningTask)
Task
public void childSuccess(Task<E> runningTask)
Task
childSuccess
in class Task<E>
runningTask
- the task that succeededCopyright © 2018. All rights reserved.