Drag[en]gine Script Module DragonScript  1.21
Dragengine.Scenery.BaseActorAction Class Reference

Base actor action. More...

Inheritance diagram for Dragengine.Scenery.BaseActorAction:
Dragengine.LoadSave.Persistable Dragengine.Scenery.BAAAlignActor Dragengine.Scenery.BAACutscene Dragengine.Scenery.BAAFirstPerson Dragengine.Scenery.BAAVehicle Dragengine.Scenery.BAAFirstPersonVR

Classes

class  Factory
 Factory for loading actor actions. More...
 

Public Member Functions

void activate (BehaviorElement actor)
 Action has been set as active action in an actor. More...
 
void activateWhileLoading (BehaviorElement actor)
 Action has been set as active action in an actor while loading. More...
 
void aiFailed ()
 Notify actor AI this action failed. More...
 
void aiFinished ()
 Notify actor AI this action failed. More...
 
void cancel ()
 Cancel action the next time possible. More...
 
bool canHitCollider (Collider owner, Collider collider)
 Two colliders can hit each other. More...
 
void colliderChanged (Collider owner)
 Collider changed. More...
 
void collisionResponse (Collider owner, CollisionInfo info)
 Collision detected. More...
 
bool conversationWait ()
 Check if conversation actions have to wait for actor to finish this action. More...
 
void deactivate ()
 Action has been unset as active action in an actor. More...
 
void dispose ()
 Dispose of actor action. 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 the action is assigned to or null. More...
 
ECBehaviorActorAnimated.Instance getActorAnimated ()
 Actor animated behavior if present. More...
 
ECBehaviorActorAIAction.Instance getAIAction ()
 Behavior actor ai-action or null. More...
 
ECBehaviorConversationActor.Instance getConversationActor ()
 Conversation actor behavior if present. More...
 
ECBehaviorLocomotion.Instance getLocomotion ()
 Locomotion behavior. More...
 
ECBehaviorPlayerControllable.Instance getPlayerControllable ()
 Behavior player controllable or null. More...
 
bool isActive ()
 Action is active actor action. More...
 
bool isControlledByPlayer ()
 Actor is controlled by player. More...
 
bool isNotActive ()
 Action is not active actor action. 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...
 
BaseActorAction new ()
 Create actor action. More...
 
BaseActorAction new (PersistencyEnvironment env, FileReader reader)
 Create actor action from persisted state. More...
 
String persistencyFactoryName ()
 Name of PersistencyFactory required to load object from file. More...
 
void playerPostThink (float elapsed)
 Post physics for player controlled actor only. More...
 
void playerReleasesControl ()
 Player released control of actor. More...
 
void playerTakesControl ()
 Player takes control of actor. More...
 
void playerThink (float elapsed)
 Thinking for player controlled actor only. More...
 
void postThink (float elapsed)
 Post physics. More...
 
void think (float elapsed)
 Thinking. More...
 
void writeObjectToFile (PersistencyEnvironment env, FileWriter writer)
 Write object to file writer. More...
 

Protected Member Functions

void applyAnimations ()
 Apply animations. More...
 
void initAnimator ()
 Initialize animator. More...
 
void initBehaviors ()
 Init behaviors. More...
 
void updateAICollider (float elapsed)
 Update AI collider. More...
 
void updateAnimator (float elapsed)
 Update animator controllers. More...
 
void updateLocomotion (float elapsed)
 Update locomotion. More...
 

Protected Attributes

BehaviorElement actor
 Actor the action is assigned to or null. More...
 
ECBehaviorActorAnimated.Instance actorAnimated
 Actor animated behavior if present. More...
 
ECBehaviorActorAIAction.Instance aiAction
 Behavior actor ai-action or null. More...
 
ECBehaviorConversationActor.Instance conversationActor
 Conversation actor behavior if present. More...
 
ECBehaviorLocomotion.Instance locomotion
 Locomotion behavior. More...
 
ECBehaviorPlayerControllable.Instance playerControllable
 Behavior player controllable or null. More...
 

Detailed Description

Base actor action.

Action supports the Persistable interface an can be read from and writen to file writers.

Member Function Documentation

◆ activate()

void Dragengine.Scenery.BaseActorAction.activate ( BehaviorElement  actor)

Action has been set as active action in an actor.

Stores the actor and calls initAnimator() and ECBehaviorActorAnimated.applyAnimations().

Calls these hook methods:

Reimplemented in Dragengine.Scenery.BAAVehicle, Dragengine.Scenery.BAAFirstPerson, Dragengine.Scenery.BAACutscene, and Dragengine.Scenery.BAAAlignActor.

◆ activateWhileLoading()

void Dragengine.Scenery.BaseActorAction.activateWhileLoading ( BehaviorElement  actor)

Action has been set as active action in an actor while loading.

Similar to activate(BehaviorElement) but only stores the actor and calls initBehaviors(). This is required since while loading behaviors load their state and actions load their states. If activate(BehaviorElement) is called these states would be reset to initial values.

◆ aiFailed()

void Dragengine.Scenery.BaseActorAction.aiFailed ( )

Notify actor AI this action failed.

Calls actionFailed() on actor AI if all of these conditions apply:

  • Actor is not player controlled
  • Actor AI is not null

◆ aiFinished()

void Dragengine.Scenery.BaseActorAction.aiFinished ( )

Notify actor AI this action failed.

Calls actionFinished() on actor AI if all of these conditions apply:

  • Actor is not player controlled
  • Actor AI is not null

◆ applyAnimations()

void Dragengine.Scenery.BaseActorAction.applyAnimations ( )
protected

Apply animations.

Default implementation calls these method if the behvaiors are present:

  • ECBehaviorActorAnimated.applyAnimations()

◆ cancel()

void Dragengine.Scenery.BaseActorAction.cancel ( )

Cancel action the next time possible.

Calls aiFailed().

Reimplemented in Dragengine.Scenery.BAAAlignActor.

◆ canHitCollider()

bool Dragengine.Scenery.BaseActorAction.canHitCollider ( Collider  owner,
Collider  collider 
)

◆ colliderChanged()

void Dragengine.Scenery.BaseActorAction.colliderChanged ( Collider  owner)

◆ collisionResponse()

void Dragengine.Scenery.BaseActorAction.collisionResponse ( Collider  owner,
CollisionInfo  info 
)

◆ conversationWait()

bool Dragengine.Scenery.BaseActorAction.conversationWait ( )

Check if conversation actions have to wait for actor to finish this action.

BaseActor adds a listener to ECBehaviorConversationActor using conversationWait() to answer waiting queries by conversation scripts.

The default implementation returns false which equals no waiting required.

◆ deactivate()

void Dragengine.Scenery.BaseActorAction.deactivate ( )

Action has been unset as active action in an actor.

The stored actor is not cleared to allow aiFinished() and aiFailed() calls to function.

Reimplemented in Dragengine.Scenery.BAAAlignActor.

◆ dispose()

void Dragengine.Scenery.BaseActorAction.dispose ( )

Dispose of actor action.

◆ enteredGameWorld()

void Dragengine.Scenery.BaseActorAction.enteredGameWorld ( )

Actor entered game world.

◆ enterFrame()

void Dragengine.Scenery.BaseActorAction.enterFrame ( )

Actor has been added to game world and enterFrame() is called once.

Reimplemented in Dragengine.Scenery.BAAAlignActor.

◆ getActor()

BehaviorElement Dragengine.Scenery.BaseActorAction.getActor ( )

Actor the action is assigned to or null.

◆ getActorAnimated()

ECBehaviorActorAnimated.Instance Dragengine.Scenery.BaseActorAction.getActorAnimated ( )

Actor animated behavior if present.

◆ getAIAction()

ECBehaviorActorAIAction.Instance Dragengine.Scenery.BaseActorAction.getAIAction ( )

Behavior actor ai-action or null.

◆ getConversationActor()

ECBehaviorConversationActor.Instance Dragengine.Scenery.BaseActorAction.getConversationActor ( )

Conversation actor behavior if present.

◆ getLocomotion()

ECBehaviorLocomotion.Instance Dragengine.Scenery.BaseActorAction.getLocomotion ( )

Locomotion behavior.

◆ getPlayerControllable()

ECBehaviorPlayerControllable.Instance Dragengine.Scenery.BaseActorAction.getPlayerControllable ( )

Behavior player controllable or null.

◆ initAnimator()

void Dragengine.Scenery.BaseActorAction.initAnimator ( )
protected

Initialize animator.

Overwrite to change animator to use for this actor.

Default implementation does nothing.

Using ECBehaviorActorAnimated

Call setActiveAnimatorID() with the identifier of the desired animator as set up in the "actorAnimated.animators" element class property. If you set up controller mappings using actorAnimated.setDefaultControllerMappings() or manually you can stop here since controller mappings are automatically updated. By default BaseActorClass does calls setDefaultControllerMappings().

A typical implementation can look like this:

actorAnimated.setActiveAnimatorID("default")
ECBehaviorActorAnimated.Instance actorAnimated
Actor animated behavior if present.
Definition: BaseActorAction.ds:60
Manually handling AnimatorInstance and Animator

If you change the animator you should usually also change the locomotion controller mappings to automatically animate them unless you plan to do it manually.

A typical implementation can look like this:

var Animator animator = ... // animator you would like to set
var AnimatorInstance ainst = ... // animator instance created and handled by yourself
ainst.setAnimator(animator)
var Locomotion locomotion = getActor().getLocomotion()
locomotion.removeAllControllerMappings()
locomotion.addControllerMapping(ainst.getControllerAt(0), Locomotion.ATTR_ELAPSED_TIME)
locomotion.addControllerMapping(ainst.getControllerAt(1), Locomotion.ATTR_DISPLACEMENT)
locomotion.addControllerMapping(ainst.getControllerAt(2), Locomotion.ATTR_LOOK_HORIZONTAL)
locomotion.addControllerMapping(ainst.getControllerAt(3), Locomotion.ATTR_LOOK_VERTICAL)
ECBehaviorLocomotion.Instance locomotion
Locomotion behavior.
Definition: BaseActorAction.ds:54
BehaviorElement getActor()
Actor the action is assigned to or null.

This example code sets an animator which is known to have 4 controllers. The mappings are set to automatically update the controllers with values matching their use. In this case the first controller is playback while actor is not moving. The second controller is playback while actor is walking. Using ATTR_DISPLACEMENT uses the distance moved by the actor as controller value. Using distance avoids feet shuffling and works well with variable movement speeds. The other two controllers affect the direction the actor is looking.

◆ initBehaviors()

void Dragengine.Scenery.BaseActorAction.initBehaviors ( )
protected

Init behaviors.

Retrieve and store required and optional behavior instances from the actor element.

Reimplemented in Dragengine.Scenery.BAAVehicle, Dragengine.Scenery.BAAFirstPersonVR, Dragengine.Scenery.BAAFirstPerson, Dragengine.Scenery.BAACutscene, and Dragengine.Scenery.BAAAlignActor.

◆ isActive()

bool Dragengine.Scenery.BaseActorAction.isActive ( )

Action is active actor action.

Version
1.4

◆ isControlledByPlayer()

bool Dragengine.Scenery.BaseActorAction.isControlledByPlayer ( )

Actor is controlled by player.

◆ isNotActive()

bool Dragengine.Scenery.BaseActorAction.isNotActive ( )

Action is not active actor action.

Version
1.4

◆ leftGameWorld()

void Dragengine.Scenery.BaseActorAction.leftGameWorld ( )

Actor left game world.

◆ log() [1/6]

void Dragengine.Scenery.BaseActorAction.log ( Console  console,
Element  element,
String  text 
)

Log text about element to console prefixed with actor information.

◆ log() [2/6]

void Dragengine.Scenery.BaseActorAction.log ( Console  console,
Exception  exception 
)

Log exception to console prefixed with actor information.

◆ log() [3/6]

void Dragengine.Scenery.BaseActorAction.log ( Console  console,
String  text 
)

Log text to console prefixed with actor information.

◆ log() [4/6]

void Dragengine.Scenery.BaseActorAction.log ( Element  element,
String  text 
)

Log text about element to BaseGameApp console prefixed with actor information.

◆ log() [5/6]

void Dragengine.Scenery.BaseActorAction.log ( Exception  exception)

Log exception to BaseGameApp console prefixed with actor information.

◆ log() [6/6]

void Dragengine.Scenery.BaseActorAction.log ( String  text)

Log text to BaseGameApp console prefixed with actor information.

◆ loggingPrefix()

String Dragengine.Scenery.BaseActorAction.loggingPrefix ( )

Logging prefix.

Returns string in the form "<actor-class>/<action-class>".

◆ new() [1/2]

BaseActorAction Dragengine.Scenery.BaseActorAction.new ( )

◆ new() [2/2]

BaseActorAction Dragengine.Scenery.BaseActorAction.new ( PersistencyEnvironment  env,
FileReader  reader 
)

Create actor action from persisted state.

Reimplemented in Dragengine.Scenery.BAACutscene, and Dragengine.Scenery.BAAAlignActor.

◆ persistencyFactoryName()

String Dragengine.Scenery.BaseActorAction.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.

Implements Dragengine.LoadSave.Persistable.

Reimplemented in Dragengine.Scenery.BAAVehicle, Dragengine.Scenery.BAAFirstPersonVR, Dragengine.Scenery.BAAFirstPerson, Dragengine.Scenery.BAACutscene, and Dragengine.Scenery.BAAAlignActor.

◆ playerPostThink()

void Dragengine.Scenery.BaseActorAction.playerPostThink ( float  elapsed)

Post physics for player controlled actor only.

Default implementation does nothing.

◆ playerReleasesControl()

void Dragengine.Scenery.BaseActorAction.playerReleasesControl ( )

Player released control of actor.

Reimplemented in Dragengine.Scenery.BAAVehicle, and Dragengine.Scenery.BAAFirstPerson.

◆ playerTakesControl()

void Dragengine.Scenery.BaseActorAction.playerTakesControl ( )

Player takes control of actor.

Reimplemented in Dragengine.Scenery.BAAVehicle, and Dragengine.Scenery.BAAFirstPerson.

◆ playerThink()

void Dragengine.Scenery.BaseActorAction.playerThink ( float  elapsed)

Thinking for player controlled actor only.

Default implementation does nothing.

Reimplemented in Dragengine.Scenery.BAAVehicle, and Dragengine.Scenery.BAAFirstPerson.

◆ postThink()

void Dragengine.Scenery.BaseActorAction.postThink ( float  elapsed)

◆ think()

void Dragengine.Scenery.BaseActorAction.think ( float  elapsed)

Thinking.

Default implementation does these actions in this order:

playerThink() is called by ECBehaviorActorAIAction if player controls this actor.

Reimplemented in Dragengine.Scenery.BAAVehicle, Dragengine.Scenery.BAAFirstPerson, Dragengine.Scenery.BAACutscene, and Dragengine.Scenery.BAAAlignActor.

◆ updateAICollider()

void Dragengine.Scenery.BaseActorAction.updateAICollider ( float  elapsed)
protected

Update AI collider.

Default implementation does nothing.

Reimplemented in Dragengine.Scenery.BAAVehicle, Dragengine.Scenery.BAAFirstPerson, and Dragengine.Scenery.BAACutscene.

◆ updateAnimator()

void Dragengine.Scenery.BaseActorAction.updateAnimator ( float  elapsed)
protected

Update animator controllers.

Default implementation calls these method if the behvaiors are present:

  • ECBehaviorLocomotion.updateAnimator()
  • ECBehaviorActorAnimated.notifyControllersChanged()

◆ updateLocomotion()

void Dragengine.Scenery.BaseActorAction.updateLocomotion ( float  elapsed)
protected

Update locomotion.

Default implementation does nothing.

Reimplemented in Dragengine.Scenery.BAAVehicle, Dragengine.Scenery.BAAFirstPerson, and Dragengine.Scenery.BAACutscene.

◆ writeObjectToFile()

void Dragengine.Scenery.BaseActorAction.writeObjectToFile ( PersistencyEnvironment  env,
FileWriter  writer 
)

Write object to file writer.

Implements Dragengine.LoadSave.Persistable.

Reimplemented in Dragengine.Scenery.BAACutscene, and Dragengine.Scenery.BAAAlignActor.

Member Data Documentation

◆ actor

BehaviorElement Dragengine.Scenery.BaseActorAction.actor
protected

Actor the action is assigned to or null.

◆ actorAnimated

ECBehaviorActorAnimated.Instance Dragengine.Scenery.BaseActorAction.actorAnimated
protected

Actor animated behavior if present.

◆ aiAction

ECBehaviorActorAIAction.Instance Dragengine.Scenery.BaseActorAction.aiAction
protected

Behavior actor ai-action or null.

◆ conversationActor

ECBehaviorConversationActor.Instance Dragengine.Scenery.BaseActorAction.conversationActor
protected

Conversation actor behavior if present.

◆ locomotion

ECBehaviorLocomotion.Instance Dragengine.Scenery.BaseActorAction.locomotion
protected

Locomotion behavior.

◆ playerControllable

ECBehaviorPlayerControllable.Instance Dragengine.Scenery.BaseActorAction.playerControllable
protected

Behavior player controllable or null.


The documentation for this class was generated from the following file: