Drag[en]gine Script Module DragonScript
1.23
|
Actor AI using BehaviorTree. More...
Classes | |
class | BTActionAI |
Behavior tree action with link to BAAIBehaviorTree. More... | |
class | BTContextAI |
Behavior tree context with link to BAAIBehaviorTree. More... | |
class | Factory |
Factory for loading actor ai. More... | |
Public Member Functions | |
void | dispose () |
Dispose of actor ai. More... | |
ECBehaviorBehaviorTree.Instance | getBehaviorBehaviorTree () |
Behavior behavior tree to send notifications to. More... | |
BTContextAI | getContext () |
Behavior tree context or null if not set. More... | |
bool | getPauseInConversation () |
Pause behavior tree while actor is in a conversation. More... | |
bool | getRunning () |
Behavior tree is running. More... | |
BAAIBehaviorTree | new () |
Create actor ai. More... | |
BAAIBehaviorTree | new (PersistencyEnvironment env, FileReader reader) |
Create actor ai restoring from file reader. More... | |
void | onBehaviorTreeFailed (Exception e) |
Running the behavior tree failed. More... | |
String | persistencyFactoryName () |
Name of PersistencyFactory required to load object from file. More... | |
void | resetContext () |
Reset context to run it again. More... | |
void | setBehaviorBehaviorTree (ECBehaviorBehaviorTree.Instance behavior) |
Set behavior behavior tree to send notifications to. More... | |
void | setContext (BTContextAI context) |
Set behavior tree context or null if not set. More... | |
void | setPauseInConversation (bool pauseInConversation) |
Set to pause behavior tree while actor is in a conversation. More... | |
void | setRunning (bool running) |
Set if behavior tree is running. More... | |
void | think (float elapsed) |
Thinking. More... | |
void | writeObjectToFile (PersistencyEnvironment env, FileWriter writer) |
Write object to file writer. More... | |
Public Member Functions inherited from Dragengine.Scenery.BaseActorAI | |
void | actionFailed () |
Action failed. More... | |
void | actionFinished () |
Action finished successfully. More... | |
void | activate (BehaviorElement actor) |
AI has been set as active AI in an actor. More... | |
void | activateWhileLoading (BehaviorElement actor) |
AI has been set as active AI in an actor while loading. More... | |
void | collision (Collider owner, CollisionInfo info) |
Collision detected. More... | |
void | deactivate () |
Action has been unset as active action in an actor. More... | |
void | enterConversation () |
Actor has been added to a conversation playback. More... | |
void | enteredGameWorld () |
Actor entered game world. More... | |
void | enterFrame () |
Actor has been added to game world and enterFrame() is called once. More... | |
BehaviorElement | getActor () |
Actor owning the action. More... | |
ECBehaviorActorAIAction.Instance | getAIAction () |
Behavior actor ai-action or null. More... | |
ECBehaviorPlayerControllable.Instance | getPlayerControllable () |
Behavior player controllable or null. More... | |
bool | isActive () |
AI is active actor AI. More... | |
bool | isControlledByPlayer () |
Actor is controlled by player. More... | |
bool | isNotActive () |
AI is not active actor AI. More... | |
void | leaveConversation () |
Actor has been removed from a conversation playback. More... | |
void | leftGameWorld () |
Actor left game world. More... | |
void | log (Console console, Element element, String text) |
Log text about element to console prefixed with actor information. More... | |
void | log (Console console, Exception exception) |
Log exception to console prefixed with actor information. More... | |
void | log (Console console, String text) |
Log text to console prefixed with actor information. More... | |
void | log (Element element, String text) |
Log text about element to BaseGameApp console prefixed with actor information. More... | |
void | log (Exception exception) |
Log exception to BaseGameApp console prefixed with actor information. More... | |
void | log (String text) |
Log text to BaseGameApp console prefixed with actor information. More... | |
String | loggingPrefix () |
Logging prefix. More... | |
void | playerReleasesControl () |
Player released control of actor. More... | |
void | playerTakesControl () |
Player takes control of actor. More... | |
Public Attributes | |
ECBehaviorBehaviorTree.Instance | pBehaviorBehaviorTree |
BTContextAI | pContext |
bool | pPauseInConversation |
bool | pRunning |
Protected Member Functions | |
void | initBehaviors () |
Init behaviors. More... | |
Protected Attributes | |
ECBehaviorConversationActor.Instance | conversationActor |
Protected Attributes inherited from Dragengine.Scenery.BaseActorAI | |
BehaviorElement | actor |
Actor the action is assigned to or null. More... | |
ECBehaviorActorAIAction.Instance | aiAction |
Behavior actor ai-action or null. More... | |
ECBehaviorPlayerControllable.Instance | playerControllable |
Behavior player controllable or null. More... | |
Actor AI using BehaviorTree.
Uses BehaviorTree using BTContext to do AI. For each call to think() the behavior tree is stepped. In case of an exception in the behavior tree the exception is logged and the running of the behavior tree cancelled.
To use this AI set the BTContext subclass set up with the required actions and state initialized to run the behavior tree. Do this after the AI instance is created which can be also due to Persistable interface loading from file reader.
To support behaviors receiving notifications about the state of the context set also the ECBehaviorBehaviorTree used to initialize the context.
void Dragengine.Scenery.BAAIBehaviorTree.dispose | ( | ) |
Dispose of actor ai.
Reimplemented from Dragengine.Scenery.BaseActorAI.
ECBehaviorBehaviorTree.Instance Dragengine.Scenery.BAAIBehaviorTree.getBehaviorBehaviorTree | ( | ) |
Behavior behavior tree to send notifications to.
BTContextAI Dragengine.Scenery.BAAIBehaviorTree.getContext | ( | ) |
Behavior tree context or null if not set.
bool Dragengine.Scenery.BAAIBehaviorTree.getPauseInConversation | ( | ) |
Pause behavior tree while actor is in a conversation.
bool Dragengine.Scenery.BAAIBehaviorTree.getRunning | ( | ) |
Behavior tree is running.
|
protected |
Init behaviors.
Retrieve and store required and optional behavior instances from the actor element.
Reimplemented from Dragengine.Scenery.BaseActorAI.
BAAIBehaviorTree Dragengine.Scenery.BAAIBehaviorTree.new | ( | ) |
Create actor ai.
Reimplemented from Dragengine.Scenery.BaseActorAI.
BAAIBehaviorTree Dragengine.Scenery.BAAIBehaviorTree.new | ( | PersistencyEnvironment | env, |
FileReader | reader | ||
) |
Create actor ai restoring from file reader.
void Dragengine.Scenery.BAAIBehaviorTree.onBehaviorTreeFailed | ( | Exception | e | ) |
Running the behavior tree failed.
Default implementation logs exception using log(Exception).
exception | Exception if thrown or null otherwise. |
String Dragengine.Scenery.BAAIBehaviorTree.persistencyFactoryName | ( | ) |
Name of PersistencyFactory required to load object from file.
Name of PersistencyFactory is first written to the file as string with 8-bit length. Then writeToFile() is called to write the object itself. Empty name is not allowed as is names longer than 255 characters. Name has to match a PersistencyFactory present in the Persistency instance used for loading objects. Object is read using PersistencyFactory.readObjectFromFile() of the matching PersistencyFactory.
Reimplemented from Dragengine.Scenery.BaseActorAI.
void Dragengine.Scenery.BAAIBehaviorTree.resetContext | ( | ) |
Reset context to run it again.
void Dragengine.Scenery.BAAIBehaviorTree.setBehaviorBehaviorTree | ( | ECBehaviorBehaviorTree.Instance | behavior | ) |
Set behavior behavior tree to send notifications to.
void Dragengine.Scenery.BAAIBehaviorTree.setContext | ( | BTContextAI | context | ) |
Set behavior tree context or null if not set.
If context is not null resetContext() is also called.
void Dragengine.Scenery.BAAIBehaviorTree.setPauseInConversation | ( | bool | pauseInConversation | ) |
Set to pause behavior tree while actor is in a conversation.
void Dragengine.Scenery.BAAIBehaviorTree.setRunning | ( | bool | running | ) |
Set if behavior tree is running.
void Dragengine.Scenery.BAAIBehaviorTree.think | ( | float | elapsed | ) |
Thinking.
Behavior tree is process if:
If running the behavior tree throws an exception or returns false running is set to false and onBehaviorTreeFailed() is called. To run the context again call resetContext().
Reimplemented from Dragengine.Scenery.BaseActorAI.
void Dragengine.Scenery.BAAIBehaviorTree.writeObjectToFile | ( | PersistencyEnvironment | env, |
FileWriter | writer | ||
) |
Write object to file writer.
Reimplemented from Dragengine.Scenery.BaseActorAI.
|
protected |
ECBehaviorBehaviorTree.Instance Dragengine.Scenery.BAAIBehaviorTree.pBehaviorBehaviorTree |
BTContextAI Dragengine.Scenery.BAAIBehaviorTree.pContext |
bool Dragengine.Scenery.BAAIBehaviorTree.pPauseInConversation |
bool Dragengine.Scenery.BAAIBehaviorTree.pRunning |