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

Basic actor class. More...

Inheritance diagram for Dragengine.Scenery.BaseActor:
Dragengine.Scenery.BehaviorElement Dragengine.Scenery.Element Dragengine.Scenery.BaseVRActor

Public Member Functions

void addToGameWorld ()
 Add to game world. More...
 
ECBehaviorActorAnimated.Instance getActorAnimated ()
 Actor animated behavior instance. More...
 
ECBehaviorActorMover.Instance getActorMover ()
 Actor mover instance. More...
 
ECBehaviorActorAIAction.Instance getAIAction ()
 AI-Action instance. More...
 
ECBehaviorAlignActor.Instance getAlignActor ()
 Align actor instance. More...
 
ECBehaviorAvoidCollision.Instance getAvoidCollision ()
 Avoid collision instance. More...
 
ECBehaviorAvoidedByActor.Instance getAvoidedByActor ()
 Avoided by actor instance. More...
 
ECBehaviorCollider.Instance getCollider ()
 Collider behavior instance. More...
 
ECBehaviorColliderAI.Instance getColliderAI ()
 Collider AI behavior instance. More...
 
ECBehaviorComponent.Instance getComponent ()
 Component behavio instance. More...
 
ECBehaviorConversationActor.Instance getConversationActor ()
 Conversation actor instance. More...
 
ECBehaviorFootSteps.Instance getFootSteps ()
 Foot steps instance. More...
 
ECBehaviorLocomotion.Instance getLocomotion ()
 Locomotion behavior instance. More...
 
ECBehaviorNavigator.Instance getNavigator ()
 Navigator instance. More...
 
ECBehaviorParameterTable.Instance getParameterTable ()
 Parameter table instance. More...
 
ECBehaviorPlayerControllable.Instance getPlayerControllable ()
 Player controllable instance. More...
 
ECBehaviorPlayerInputCrouch.Instance getPlayerInputCrouch ()
 Player input crouching behavior instance. More...
 
ECBehaviorPlayerInputLook.Instance getPlayerInputLook ()
 Player input looking around behavior instance. More...
 
ECBehaviorPlayerInputMove.Instance getPlayerInputMove ()
 Player input moving behavior instance. More...
 
ECBehaviorPlayerInputTurn.Instance getPlayerInputTurn ()
 Player input turning behavior instance. More...
 
ECBehaviorProjectToGround.Instance getProjectToGround ()
 Project to ground behavior instance. More...
 
ECBehaviorRideOn.Instance getRideOn ()
 Ride on instance. More...
 
void init (StubElement stub)
 Initialize element from stub. More...
 
BaseActor new (BaseActorClass eclass)
 Create element. More...
 
void readFromFile (PersistencyEnvironment env, FileReader reader)
 Read element from file. More...
 
void teleportAdjustActor ()
 Adjust actor after teleporting. More...
 
void visit (ElementVisitor visitor)
 Visit element. More...
 
void writeToFile (PersistencyEnvironment env, FileWriter writer)
 
- Public Member Functions inherited from Dragengine.Scenery.BehaviorElement
Array collectInstances (Block ablock)
 Collect behavior instance with block into Array. More...
 
ECBehaviorInstance findInstance (Block ablock)
 Find behavior instance with block. More...
 
void forEachInstance (Block ablock)
 Visit behavior instances with block. More...
 
void forEachInstanceReverse (Block ablock)
 Visit behavior instances with block in reverse order. More...
 
ECBehaviorInstance getInstanceAt (int index)
 Behavior instance at index. More...
 
bool getRequiresAttachToParent ()
 Attach to parent has not been processed yet. More...
 
bool getRequiresEnterFrame ()
 Sub-class requires enterFrame() to be called. More...
 
bool getRequiresThink ()
 Sub-class requires think() to be called. More...
 
bool isChangingGameWorld ()
 Behavior element is in progress of beeing added to or removed from a GameWorld. More...
 
bool isReallyInGameWorld ()
 Element is in GameWorld and not in progress of beeing removed from it. More...
 
BehaviorElement new (BehaviorElementClass eclass)
 Create element. More...
 
void onSetPosition ()
 Position changed. More...
 
void requiresThinkChanged ()
 Requires thinking changed. More...
 
void setRequiresAttachToParent (bool requiresAttachToParent)
 Set if attach to parent has not been processed yet. More...
 
- Public Member Functions inherited from Dragengine.Scenery.Element
Dictionary debugInformation ()
 Debug information as Dictionary. More...
 
void dispose ()
 Dispose of element. More...
 
void enterFrame ()
 Frame update started. More...
 
ElementClass getClass ()
 
DMatrix getElementMatrix ()
 Matrix to transform from element space into world space. More...
 
GameWorld getGameWorld ()
 
UniqueID getID ()
 
DMatrix getInverseElementMatrix ()
 Matrix to transform from world space into element space. More...
 
bool getIsScaled ()
 Is scaled. More...
 
Quaternion getOrientation ()
 Orientation. More...
 
Element getParent ()
 
DVector getPosition ()
 Position. More...
 
Vector getScaling ()
 Scaling. More...
 
StubElement getStub ()
 Element stub used to create the element. More...
 
bool getTouchable ()
 
bool getVisible ()
 
bool isChildOf (Element parent)
 
bool isDisposed ()
 Element has been disposed of. More...
 
bool isMyselfOrChildOf (Element parent)
 
bool isNotDisposed ()
 Element has not been disposed of. More...
 
void log (String message)
 Log using BaseGameApp Console if present. More...
 
Element new (ElementClass elementClass)
 
void onSetGameWorld ()
 
void onSetGeometry ()
 Position, orientation or scaling changed. More...
 
void onSetOrientation ()
 Orientation changed. More...
 
void onSetParent ()
 
void onSetScaling ()
 Scaling changed. More...
 
void onSetTouchable ()
 
void onSetVisible ()
 
void postThink (float elapsed)
 
void removeFromGameWorld ()
 
void removeFromGameWorldIfPresent ()
 Remove element from game world if present. More...
 
void safeDispose ()
 Remove element from game world if present and dispose of element. More...
 
void setGameWorld (GameWorld gameWorld)
 
void setGeometry (DVector position, Quaternion orientation)
 Set position and orientation. More...
 
void setGeometry (DVector position, Quaternion orientation, Vector scaling)
 Set position, orientation and scaling of element. More...
 
void setID (UniqueID id)
 
void setOrientation (Quaternion orientation)
 Set orientation. More...
 
void setParent (Element parent)
 
void setPosition (DVector position)
 Set position. More...
 
void setScaling (Vector scaling)
 Set scaling. More...
 
void setStub (StubElement stub)
 Set element stub used to create the element. More...
 
void setTouchable (bool touchable)
 
void setVisible (bool visible)
 
void think (float elapsed)
 
String toString ()
 
void writeToFileWithStub (PersistencyEnvironment env, FileWriter writer)
 Write element to file writer with stub. More...
 

Public Attributes

ECBehaviorActorAnimated.Instance pActorAnimated
 
ECBehaviorActorMover.Instance pActorMover
 
ECBehaviorActorAIAction.Instance pAIAction
 
ECBehaviorAlignActor.Instance pAlignActor
 
ECBehaviorAvoidCollision.Instance pAvoidCollision
 
ECBehaviorAvoidedByActor.Instance pAvoidedByActor
 
ECBehaviorCollider.Instance pCollider
 
ECBehaviorColliderAI.Instance pColliderAI
 
ECBehaviorComponent.Instance pComponent
 
ECBehaviorConversationActor.Instance pConversationActor
 
ECBehaviorFootSteps.Instance pFootSteps
 
ECBehaviorLocomotion.Instance pLocomotion
 
ECBehaviorNavigator.Instance pNavigator
 
ECBehaviorParameterTable.Instance pParameterTable
 
ECBehaviorPlayerControllable.Instance pPlayerControllable
 
ECBehaviorPlayerInputCrouch.Instance pPlayerInputCrouch
 
ECBehaviorPlayerInputLook.Instance pPlayerInputLook
 
ECBehaviorPlayerInputMove.Instance pPlayerInputMove
 
ECBehaviorPlayerInputTurn.Instance pPlayerInputTurn
 
ECBehaviorProjectToGround.Instance pProjectToGround
 
ECBehaviorRideOn.Instance pRideOn
 
- Public Attributes inherited from Dragengine.Scenery.BehaviorElement
Array pInstances
 
bool pIsChangingGameWorld
 
bool pIsThinker
 
bool pRequiresAttachToParent
 
bool pRequiresEnterFrame
 
bool pRequiresThink
 
Array pThinkingInstances
 

Protected Member Functions

void initAvoidCollisionShape (StubElement stub)
 Initialize avoid collision collider shape. More...
 
void initColliderShape (StubElement stub)
 Initialize collider AI shape. More...
 
void initNavigator (StubElement stub)
 Initialize navigator. More...
 
void initProjectToGroundShapes (StubElement stub)
 Initialize project to ground shapes. More...
 
void spawnAdjustActor ()
 Adjust actor after spawning. More...
 
- Protected Member Functions inherited from Dragengine.Scenery.BehaviorElement
void setRequiresEnterFrame (bool requiresEnterFrame)
 Set if sub-class requires enterFrame() to be called. More...
 
void setRequiresThink (bool requiresThink)
 Set if sub-class requires think() to be called. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Dragengine.Scenery.Element
static Element readElementFromFileWithStub (PersistencyEnvironment env, FileReader reader, ElementClassList ElementClassList)
 Load element from file reader with stub supporting null element. More...
 
static void writeElementToFileWithStub (PersistencyEnvironment env, FileWriter writer, Element element)
 Write element to file writer with stub supporting null element. More...
 

Detailed Description

Basic actor class.

Basic implementation of an actor in a game. Actors exhibit complex behavior beyond simple interactions as provided by props. Typically this behavior can be split into two different groups: actions and AI.

BaseActor extends SimpleElement since actor handling requires a visible component as well as a collider to properly move inside the game world. BaseActor registers itself as thinker.

Actions
Actions provide an action an actor is currently performing. By using individual classes for individual groups of actions allows to easily adding and modifying behavior. It is also possible to represent all actions of an actor through a single class instance for example if the developer wishes to use more descriptive or visual tools to design behavior. The important Element actions are forwarded to the active action for each actor. To change the action an actor performs call setAction().
AI
AI defines the large scale behavior of an actor. While actions provide handling of a group of actions in a flexible and extendible way the AI defines when to perform what action. This allows to reuse behavior between player and non-player actors. To take control of an actor use BasePlayerActor (or an element with ECBehaviorPlayerControllable support) and set the AI either to null or a subclass of BaseActorAI knowing how to restore a proper actor AI after the player releases control. If you use null as AI you need to use BasePlayerActor.playerReleasesControl() to restore the AI instead.
Player input tracker
If actor is controller by player the bindings send player input to the instance of PlayerInputLook assigned to the actor. This helps to track different kinds of player input to properly trigger actions. AI does not require this to be present.
Locomotion
Locomotion is provided using an instance of ECBehaviorLocomotion. This class provides all the basic behavior to do locomotion for different type of actors. Supports organic locomotion of 2-legged and 4-legged characters with natural and FPS type movement patterns as well as mechanical locomotion like vehicles.
Navigation
Navigation handling is provided using an instance of Navigator. The default configuration supports mesh type navigation but can be changed to support grid or volumetric. To properly use navigation with the AI set up the required parameters like navigation space type, layer and cost parameters.
Camera director
You can attach the game camera and microphone directly to the actor collider AI. An easier solution is using PlayerControlledActorCameraDirector class. This uses the actor currently controlled by the player to update the game camera and microphone without manual management. Use it like this:
windowGameWorld.setCameraDirector(PlayerControlledActorCameraDirector.new())
This camera director tracks what actor the player is currently controlling. It is not required to handle this yourself. If you need different directing parameters for individual actors you store the camera directory and change its parameters by subclassing the playerTakesControl() method.

Member Function Documentation

◆ addToGameWorld()

void Dragengine.Scenery.BaseActor.addToGameWorld ( )

Add to game world.

Reimplemented from Dragengine.Scenery.Element.

◆ getActorAnimated()

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

Actor animated behavior instance.

◆ getActorMover()

ECBehaviorActorMover.Instance Dragengine.Scenery.BaseActor.getActorMover ( )

Actor mover instance.

◆ getAIAction()

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

AI-Action instance.

◆ getAlignActor()

ECBehaviorAlignActor.Instance Dragengine.Scenery.BaseActor.getAlignActor ( )

Align actor instance.

◆ getAvoidCollision()

ECBehaviorAvoidCollision.Instance Dragengine.Scenery.BaseActor.getAvoidCollision ( )

Avoid collision instance.

◆ getAvoidedByActor()

ECBehaviorAvoidedByActor.Instance Dragengine.Scenery.BaseActor.getAvoidedByActor ( )

Avoided by actor instance.

◆ getCollider()

ECBehaviorCollider.Instance Dragengine.Scenery.BaseActor.getCollider ( )

Collider behavior instance.

◆ getColliderAI()

ECBehaviorColliderAI.Instance Dragengine.Scenery.BaseActor.getColliderAI ( )

Collider AI behavior instance.

◆ getComponent()

ECBehaviorComponent.Instance Dragengine.Scenery.BaseActor.getComponent ( )

Component behavio instance.

◆ getConversationActor()

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

Conversation actor instance.

◆ getFootSteps()

ECBehaviorFootSteps.Instance Dragengine.Scenery.BaseActor.getFootSteps ( )

Foot steps instance.

◆ getLocomotion()

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

Locomotion behavior instance.

◆ getNavigator()

ECBehaviorNavigator.Instance Dragengine.Scenery.BaseActor.getNavigator ( )

Navigator instance.

◆ getParameterTable()

ECBehaviorParameterTable.Instance Dragengine.Scenery.BaseActor.getParameterTable ( )

Parameter table instance.

◆ getPlayerControllable()

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

Player controllable instance.

◆ getPlayerInputCrouch()

ECBehaviorPlayerInputCrouch.Instance Dragengine.Scenery.BaseActor.getPlayerInputCrouch ( )

Player input crouching behavior instance.

◆ getPlayerInputLook()

ECBehaviorPlayerInputLook.Instance Dragengine.Scenery.BaseActor.getPlayerInputLook ( )

Player input looking around behavior instance.

◆ getPlayerInputMove()

ECBehaviorPlayerInputMove.Instance Dragengine.Scenery.BaseActor.getPlayerInputMove ( )

Player input moving behavior instance.

◆ getPlayerInputTurn()

ECBehaviorPlayerInputTurn.Instance Dragengine.Scenery.BaseActor.getPlayerInputTurn ( )

Player input turning behavior instance.

◆ getProjectToGround()

ECBehaviorProjectToGround.Instance Dragengine.Scenery.BaseActor.getProjectToGround ( )

Project to ground behavior instance.

◆ getRideOn()

ECBehaviorRideOn.Instance Dragengine.Scenery.BaseActor.getRideOn ( )

Ride on instance.

◆ init()

void Dragengine.Scenery.BaseActor.init ( StubElement  stub)

Initialize element from stub.

Calls these hook methods to do initialization work.

Reimplemented from Dragengine.Scenery.Element.

◆ initAvoidCollisionShape()

void Dragengine.Scenery.BaseActor.initAvoidCollisionShape ( StubElement  stub)
protected

Initialize avoid collision collider shape.

Sets sphere shape with the same size as used for the collider AI shape.

◆ initColliderShape()

void Dragengine.Scenery.BaseActor.initColliderShape ( StubElement  stub)
protected

Initialize collider AI shape.

Assigns a capsule shape to the collider AI. The capsule has a total height of 1.8m and is 0.6m wide. This is a reasonable collider AI shape for a humanoid actor.

◆ initNavigator()

void Dragengine.Scenery.BaseActor.initNavigator ( StubElement  stub)
protected

Initialize navigator.

See ECBehaviorNavigator.init() . Sets layer to 0 and space type to NavigationSpaceType.mesh . Sets default fix cost to 0 and default cost-per-meter to 1. These apply if no cost types are added by the actor or other behaviors. The blocking cost is set to 10000.

Subclass should add type specific costs if required.

◆ initProjectToGroundShapes()

void Dragengine.Scenery.BaseActor.initProjectToGroundShapes ( StubElement  stub)
protected

Initialize project to ground shapes.

Assigns a box shape to the project to ground touch sensor. The shape is located at the actor position and has a radius of slightly more than the radius used for the collider AI (0.31m) and a height of the same value. This is a reasonable collider AI shape for a humanoid actor.

Assigns a sphere shape to the project to ground instance. This is usually the same shape as used for the collider AI but can be optimized. For example if the shape is a capcule the project to ground shape can be opzimized to a sphere of the matching radius. The default implementation does apply this optimization and uses a sphere with the same radius as used for the collider AI capsule.

◆ new()

BaseActor Dragengine.Scenery.BaseActor.new ( BaseActorClass  eclass)

Create element.

◆ readFromFile()

void Dragengine.Scenery.BaseActor.readFromFile ( PersistencyEnvironment  env,
FileReader  reader 
)

Read element from file.

Reimplemented from Dragengine.Scenery.Element.

◆ spawnAdjustActor()

void Dragengine.Scenery.BaseActor.spawnAdjustActor ( )
protected

Adjust actor after spawning.

Updates the actor turning to match the orientation. Also resets some parameters to make the actor appear without erratic motions. Called during addToGameWorld.

◆ teleportAdjustActor()

void Dragengine.Scenery.BaseActor.teleportAdjustActor ( )

Adjust actor after teleporting.

Calls spawnAdjustActor().

◆ visit()

void Dragengine.Scenery.BaseActor.visit ( ElementVisitor  visitor)

Visit element.

Reimplemented from Dragengine.Scenery.Element.

Reimplemented in Dragengine.Scenery.BaseVRActor.

◆ writeToFile()

void Dragengine.Scenery.BaseActor.writeToFile ( PersistencyEnvironment  env,
FileWriter  writer 
)

Writes the element to a file.

Reimplemented from Dragengine.Scenery.Element.

Member Data Documentation

◆ pActorAnimated

ECBehaviorActorAnimated.Instance Dragengine.Scenery.BaseActor.pActorAnimated

◆ pActorMover

ECBehaviorActorMover.Instance Dragengine.Scenery.BaseActor.pActorMover

◆ pAIAction

ECBehaviorActorAIAction.Instance Dragengine.Scenery.BaseActor.pAIAction

◆ pAlignActor

ECBehaviorAlignActor.Instance Dragengine.Scenery.BaseActor.pAlignActor

◆ pAvoidCollision

ECBehaviorAvoidCollision.Instance Dragengine.Scenery.BaseActor.pAvoidCollision

◆ pAvoidedByActor

ECBehaviorAvoidedByActor.Instance Dragengine.Scenery.BaseActor.pAvoidedByActor

◆ pCollider

ECBehaviorCollider.Instance Dragengine.Scenery.BaseActor.pCollider

◆ pColliderAI

ECBehaviorColliderAI.Instance Dragengine.Scenery.BaseActor.pColliderAI

◆ pComponent

ECBehaviorComponent.Instance Dragengine.Scenery.BaseActor.pComponent

◆ pConversationActor

ECBehaviorConversationActor.Instance Dragengine.Scenery.BaseActor.pConversationActor

◆ pFootSteps

ECBehaviorFootSteps.Instance Dragengine.Scenery.BaseActor.pFootSteps

◆ pLocomotion

ECBehaviorLocomotion.Instance Dragengine.Scenery.BaseActor.pLocomotion

◆ pNavigator

ECBehaviorNavigator.Instance Dragengine.Scenery.BaseActor.pNavigator

◆ pParameterTable

ECBehaviorParameterTable.Instance Dragengine.Scenery.BaseActor.pParameterTable

◆ pPlayerControllable

ECBehaviorPlayerControllable.Instance Dragengine.Scenery.BaseActor.pPlayerControllable

◆ pPlayerInputCrouch

ECBehaviorPlayerInputCrouch.Instance Dragengine.Scenery.BaseActor.pPlayerInputCrouch

◆ pPlayerInputLook

ECBehaviorPlayerInputLook.Instance Dragengine.Scenery.BaseActor.pPlayerInputLook

◆ pPlayerInputMove

ECBehaviorPlayerInputMove.Instance Dragengine.Scenery.BaseActor.pPlayerInputMove

◆ pPlayerInputTurn

ECBehaviorPlayerInputTurn.Instance Dragengine.Scenery.BaseActor.pPlayerInputTurn

◆ pProjectToGround

ECBehaviorProjectToGround.Instance Dragengine.Scenery.BaseActor.pProjectToGround

◆ pRideOn

ECBehaviorRideOn.Instance Dragengine.Scenery.BaseActor.pRideOn

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