Drag[en]gine Script Module DragonScript
1.21
|
Behavior tree context. More...
Public Member Functions | |
void | forEachAction (Block ablock) |
Visit actions using block with parameters String (name and BTAction (action). More... | |
void | forEachCondition (Block ablock) |
Visit conditions using block with parameters String (name and BTCondition (condition). More... | |
BTAction | getAction (String name) |
Action for name or null if absent. More... | |
int | getActionCount () |
Number of actions. More... | |
bool | getActionFirstRun () |
Action runs for the first time after the current rule changed. More... | |
BehaviorTree | getBehaviorTree () |
Behavior tree. More... | |
BTCondition | getCondition (String name) |
Condition for name or null if absent. More... | |
int | getConditionCount () |
Number of conditions. More... | |
Console | getConsole () |
Console or null if not wishing to log anything. More... | |
BTRule | getCurrentRule () |
Current rule. More... | |
BTResult | getLastResult () |
Last result. More... | |
String | getLoggingName () |
Logging name to tell apart logs. More... | |
bool | getLogRuleChanges () |
Log behavior tree rule changes. More... | |
bool | getLogSteps () |
Log behavior tree steps. More... | |
int | getRunAwayLimit () |
Run away limit. More... | |
bool | hasAction (String name) |
Action is present. More... | |
bool | hasCondition (String name) |
Condition is present. More... | |
BTContext | new (BehaviorTree behaviorTree) |
Create behavior tree context. More... | |
BTContext | new (BTContext context) |
Create copy of behavior tree context. More... | |
BTContext | new (BTContext context, BehaviorTree behaviorTree) |
Create copy of behavior tree context but using a different behavior tree. More... | |
void | readFromFile (PersistencyEnvironment env, FileReader reader) |
Read state from file. More... | |
void | removeAction (String name) |
Remove action. More... | |
void | removeAllActions () |
Remove all actions. More... | |
void | removeAllConditions () |
Remove all conditions. More... | |
void | removeCondition (String name) |
Remove condition. More... | |
void | reset () |
Reset to initial state. More... | |
void | setAction (String name, Block action) |
Set action for name using block. More... | |
void | setAction (String name, BTAction action) |
Set action for name. More... | |
void | setActionFirstRun (bool firstRun) |
Set action runs for the first time after the current rule changed. More... | |
void | setBehaviorTree (BehaviorTree behaviorTree) |
Set behavior tree and reset state. More... | |
void | setCondition (String name, Block condition) |
Set condition for name using block. More... | |
void | setCondition (String name, BTCondition condition) |
Set condition for name. More... | |
void | setConsole (Console console) |
Set console or null if not wishing to log anything. More... | |
void | setCurrentRule (BTRule rule) |
Set current rule. More... | |
void | setCurrentRuleByID (String id) |
Set current rule by identifier. More... | |
void | setLoggingName (String name) |
Set logging name to tell apart logs. More... | |
void | setLogRuleChanges (bool logRuleChanges) |
Set log behavior tree rule changes. More... | |
void | setLogSteps (bool logSteps) |
Set log behavior tree steps. More... | |
void | setRunAwayLimit (int limit) |
Set run away limit. More... | |
bool | stepBehaviorTree () |
Step behavior tree. More... | |
void | writeToFile (PersistencyEnvironment env, FileWriter writer) |
Write state to file. More... | |
Public Attributes | |
bool | pActionFirstRun |
Dictionary | pActions |
BehaviorTree | pBehaviorTree |
Dictionary | pConditions |
Console | pConsole |
BTRule | pCurrentRule |
BTResult | pLastResult |
String | pLoggingName |
bool | pLogRuleChanges |
bool | pLogSteps |
Array | pRunAwayList |
Protected Member Functions | |
void | onCurrentRuleChanged () |
Hook method called if setCurrentRule() is called. More... | |
Behavior tree context.
Used to run a behavior tree instance. The behavior tree itself is shared across contexts while the individual state is stored in the context. Context has to provide the BTAction instances for the behavior tree rules to call. Subclass the context to provide the required data for your BTAction subclasses to work properly.
The context can be written to and restored from file readers. This class saves only the current rule identifier. Subclass has to save its own states by overwriting readFromFile() and writeToFile().
Since version 1.19 the behavior tree can be changed after creating the context. If you change the behavior tree during runtime you have to make sure it is also set before readFromFile() is called otherwise an exception can be thrown.
void Dragengine.BehaviorTreeSystem.BTContext.forEachAction | ( | Block | ablock | ) |
Visit actions using block with parameters String (name and BTAction (action).
void Dragengine.BehaviorTreeSystem.BTContext.forEachCondition | ( | Block | ablock | ) |
Visit conditions using block with parameters String (name and BTCondition (condition).
BTAction Dragengine.BehaviorTreeSystem.BTContext.getAction | ( | String | name | ) |
Action for name or null if absent.
int Dragengine.BehaviorTreeSystem.BTContext.getActionCount | ( | ) |
Number of actions.
bool Dragengine.BehaviorTreeSystem.BTContext.getActionFirstRun | ( | ) |
Action runs for the first time after the current rule changed.
After calling setCurrentRule() this flag is set to true. Whenever an action is run this flag is set to false. This allows actions to know if they are run for the first time after the current rule changed. This allows actions to do some setting up tasks the first time they run and check back on this state as long as they run.
BehaviorTree Dragengine.BehaviorTreeSystem.BTContext.getBehaviorTree | ( | ) |
Behavior tree.
BTCondition Dragengine.BehaviorTreeSystem.BTContext.getCondition | ( | String | name | ) |
Condition for name or null if absent.
int Dragengine.BehaviorTreeSystem.BTContext.getConditionCount | ( | ) |
Number of conditions.
Console Dragengine.BehaviorTreeSystem.BTContext.getConsole | ( | ) |
Console or null if not wishing to log anything.
BTRule Dragengine.BehaviorTreeSystem.BTContext.getCurrentRule | ( | ) |
Current rule.
BTResult Dragengine.BehaviorTreeSystem.BTContext.getLastResult | ( | ) |
Last result.
String Dragengine.BehaviorTreeSystem.BTContext.getLoggingName | ( | ) |
Logging name to tell apart logs.
bool Dragengine.BehaviorTreeSystem.BTContext.getLogRuleChanges | ( | ) |
Log behavior tree rule changes.
bool Dragengine.BehaviorTreeSystem.BTContext.getLogSteps | ( | ) |
Log behavior tree steps.
int Dragengine.BehaviorTreeSystem.BTContext.getRunAwayLimit | ( | ) |
Run away limit.
bool Dragengine.BehaviorTreeSystem.BTContext.hasAction | ( | String | name | ) |
Action is present.
bool Dragengine.BehaviorTreeSystem.BTContext.hasCondition | ( | String | name | ) |
Condition is present.
BTContext Dragengine.BehaviorTreeSystem.BTContext.new | ( | BehaviorTree | behaviorTree | ) |
Create behavior tree context.
Create copy of behavior tree context.
Actions are copied as shallow copy. If you need a deep set all actions anew. The state of the context is the same as without creating a copy.
BTContext Dragengine.BehaviorTreeSystem.BTContext.new | ( | BTContext | context, |
BehaviorTree | behaviorTree | ||
) |
Create copy of behavior tree context but using a different behavior tree.
Actions are copied as shallow copy. If you need a deep set all actions anew. The state of the context is the same as without creating a copy.
This method is useful to use an initialized base context with a fallback behavior tree. Whenever a new context is required the base context is copied. This avoids the need to assign actions and conditions since they are copied from the base context.
|
protected |
Hook method called if setCurrentRule() is called.
Allows subclasses to react to current rule changes. This might be required for certain BTAction to reset states if rules change.
void Dragengine.BehaviorTreeSystem.BTContext.readFromFile | ( | PersistencyEnvironment | env, |
FileReader | reader | ||
) |
Read state from file.
void Dragengine.BehaviorTreeSystem.BTContext.removeAction | ( | String | name | ) |
Remove action.
void Dragengine.BehaviorTreeSystem.BTContext.removeAllActions | ( | ) |
Remove all actions.
void Dragengine.BehaviorTreeSystem.BTContext.removeAllConditions | ( | ) |
Remove all conditions.
void Dragengine.BehaviorTreeSystem.BTContext.removeCondition | ( | String | name | ) |
Remove condition.
void Dragengine.BehaviorTreeSystem.BTContext.reset | ( | ) |
Reset to initial state.
Sets the behavior tree root rule as current rule.
void Dragengine.BehaviorTreeSystem.BTContext.setAction | ( | String | name, |
Block | action | ||
) |
Set action for name using block.
void Dragengine.BehaviorTreeSystem.BTContext.setAction | ( | String | name, |
BTAction | action | ||
) |
Set action for name.
void Dragengine.BehaviorTreeSystem.BTContext.setActionFirstRun | ( | bool | firstRun | ) |
Set action runs for the first time after the current rule changed.
To be called only by BTRuleAction.run().
void Dragengine.BehaviorTreeSystem.BTContext.setBehaviorTree | ( | BehaviorTree | behaviorTree | ) |
Set behavior tree and reset state.
Sets the behavior tree then calls reset(). If you change the behavior tree during runtime you have to make sure it is also set before readFromFile() is called otherwise an exception can be thrown.
void Dragengine.BehaviorTreeSystem.BTContext.setCondition | ( | String | name, |
Block | condition | ||
) |
Set condition for name using block.
void Dragengine.BehaviorTreeSystem.BTContext.setCondition | ( | String | name, |
BTCondition | condition | ||
) |
Set condition for name.
void Dragengine.BehaviorTreeSystem.BTContext.setConsole | ( | Console | console | ) |
Set console or null if not wishing to log anything.
void Dragengine.BehaviorTreeSystem.BTContext.setCurrentRule | ( | BTRule | rule | ) |
Set current rule.
Sets action first run to true and calls onCurrentRuleChanged().
void Dragengine.BehaviorTreeSystem.BTContext.setCurrentRuleByID | ( | String | id | ) |
Set current rule by identifier.
Sets action first run to true and calls onCurrentRuleChanged().
EInvalidParam | Rule with identifier not found. |
void Dragengine.BehaviorTreeSystem.BTContext.setLoggingName | ( | String | name | ) |
Set logging name to tell apart logs.
void Dragengine.BehaviorTreeSystem.BTContext.setLogRuleChanges | ( | bool | logRuleChanges | ) |
Set log behavior tree rule changes.
void Dragengine.BehaviorTreeSystem.BTContext.setLogSteps | ( | bool | logSteps | ) |
Set log behavior tree steps.
void Dragengine.BehaviorTreeSystem.BTContext.setRunAwayLimit | ( | int | limit | ) |
Set run away limit.
bool Dragengine.BehaviorTreeSystem.BTContext.stepBehaviorTree | ( | ) |
Step behavior tree.
Multiple actions can run before this method returns.
BTRunAwayException | Run-away condition detected. |
void Dragengine.BehaviorTreeSystem.BTContext.writeToFile | ( | PersistencyEnvironment | env, |
FileWriter | writer | ||
) |
Write state to file.
bool Dragengine.BehaviorTreeSystem.BTContext.pActionFirstRun |
Dictionary Dragengine.BehaviorTreeSystem.BTContext.pActions |
BehaviorTree Dragengine.BehaviorTreeSystem.BTContext.pBehaviorTree |
Dictionary Dragengine.BehaviorTreeSystem.BTContext.pConditions |
Console Dragengine.BehaviorTreeSystem.BTContext.pConsole |
BTRule Dragengine.BehaviorTreeSystem.BTContext.pCurrentRule |
BTResult Dragengine.BehaviorTreeSystem.BTContext.pLastResult |
String Dragengine.BehaviorTreeSystem.BTContext.pLoggingName |
bool Dragengine.BehaviorTreeSystem.BTContext.pLogRuleChanges |
bool Dragengine.BehaviorTreeSystem.BTContext.pLogSteps |
Array Dragengine.BehaviorTreeSystem.BTContext.pRunAwayList |