Drag[en]gine Script Module DragonScript  1.23
Dragengine.Scenery.BehaviorElement Class Reference

Behavior element. More...

Inheritance diagram for Dragengine.Scenery.BehaviorElement:
Dragengine.Scenery.Element Dragengine.Gui.MainMenus.Interactive.IMMEnvironmentMap Dragengine.Gui.MainMenus.Interactive.IMMLight Dragengine.Gui.MainMenus.Interactive.IMMParticleEmitter Dragengine.Gui.MainMenus.Interactive.IMMProp Dragengine.Gui.MainMenus.Interactive.IMMSpeaker Dragengine.Scenery.AttachSlot Dragengine.Scenery.AttachableBaseBillboard Dragengine.Scenery.AttachableBaseForceField Dragengine.Scenery.AttachableBaseLight Dragengine.Scenery.AttachableBaseParticleEmitter Dragengine.Scenery.AttachableBaseSpeaker Dragengine.Scenery.BaseActor Dragengine.Scenery.BaseBillboard Dragengine.Scenery.BaseForceField Dragengine.Scenery.BaseLight Dragengine.Scenery.BaseParticleEmitter Dragengine.Scenery.BaseSky Dragengine.Scenery.BaseSpeaker Dragengine.Scenery.EnvironmentMap Dragengine.Scenery.GhostElement Dragengine.Scenery.InfoConvoCoordSystem Dragengine.Scenery.PhysicsElement Dragengine.Scenery.SimpleElement Dragengine.Scenery.TriggerConversation Dragengine.Scenery.TriggerEvaluate Dragengine.Scenery.TriggerShout Dragengine.Scenery.TriggerTimer Dragengine.Scenery.TriggerToggle Dragengine.Scenery.TriggerTouch

Public Member Functions

void addAttachableBehavior (ECAttachableBehavior behavior)
 Add attached behavior. More...
 
Array collectAttachableBehaviors (Block ablock)
 Collect attached behaviors with block into Array. More...
 
Array collectInstances (Block ablock)
 Collect behavior instance with block into Array. More...
 
ECAttachableBehavior findAttachableBehavior (Block ablock)
 Find attached behavior with block. More...
 
ECBehaviorInstance findInstance (Block ablock)
 Find behavior instance with block. More...
 
void forEachAttachableBehavior (Block ablock)
 Visit attached s with block. More...
 
void forEachAttachableBehaviorReverse (Block ablock)
 Visit attached behaviors with block in reverse order. More...
 
void forEachInstance (Block ablock)
 Visit behavior instances with block. More...
 
void forEachInstanceReverse (Block ablock)
 Visit behavior instances with block in reverse order. More...
 
ECAttachableBehavior getAttachableBehaviorAt (int index)
 Attached behavior at index. More...
 
int getAttachableBehaviorCount ()
 Count of attachaed behaviors. 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 removeAttachableBehavior (ECAttachableBehavior behavior)
 Remove attached behavior. 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
void addToGameWorld ()
 
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 ()
 
void init (StubElement stub)
 Initialize element from stub. More...
 
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 readFromFile (PersistencyEnvironment env, FileReader reader)
 Read element from file reader. More...
 
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 updateStubGeometryFromElement ()
 Update stub position, rotation and scaling from element. More...
 
void visit (ElementVisitor visitor)
 
void writeToFile (PersistencyEnvironment env, FileWriter writer)
 Write element to file writer. More...
 
void writeToFileWithStub (PersistencyEnvironment env, FileWriter writer)
 Write element to file writer with stub. More...
 

Public Attributes

Array pAttachableBehaviors
 
Array pInstances
 
bool pIsChangingGameWorld
 
bool pIsThinker
 
bool pRequiresAttachToParent
 
bool pRequiresEnterFrame
 
bool pRequiresThink
 
- Public Attributes inherited from Dragengine.Scenery.Element
ElementClass pClass
 
GameWorld pGameWorld
 
UniqueID pID
 
bool pIsScaled
 
DMatrix pMatrix
 
DMatrix pMatrixInverse
 
Quaternion pOrientation
 
Element pParent
 
DVector pPosition
 
Vector pScaling
 
StubElement pStub
 
bool pTouchable
 
bool pVisible
 

Protected Member Functions

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

Behavior element.

Behavior elements are jack of all trade elements. They allow building complex element behaviors by using behavior building blocks. Theye behavior building blocks are provided by ECBehavior classes attached to the element class.

Behavior elements are suited for prototyping or rapid development since they require little written code. Building element classes the conventional way though is usually preferred.

To create an element based on BehaviorElement create a new subclass of BehaviorElementClass and add all the desired ECBehavior instance. There is no need to subclas BehaviorElement. When creating a new instance the BehaviorElement is filled with ECBehavior created ECBehaviorInstance instances. These provide the actual behavior to the element.

Version 1.23

Added support for attachable behaviors. These behaviords can be added and removed at runtime to individual elements. This can be used for debugging purpose or adding temporary behaviors to an element. Attachable behaviors work similar to behaviors and will be also persisted.

Member Function Documentation

◆ addAttachableBehavior()

void Dragengine.Scenery.BehaviorElement.addAttachableBehavior ( ECAttachableBehavior  behavior)

Add attached behavior.

Version
1.23

◆ collectAttachableBehaviors()

Array Dragengine.Scenery.BehaviorElement.collectAttachableBehaviors ( Block  ablock)

Collect attached behaviors with block into Array.

Version
1.5

Block is required to have one parameter ECAttachableBehavior or subclass thereof and returning true for instances to collect. Block is called only for instances castable to block parameter type.

◆ collectInstances()

Array Dragengine.Scenery.BehaviorElement.collectInstances ( Block  ablock)

Collect behavior instance with block into Array.

Version
1.5

Block is required to have one parameter ECBehaviorInstance or subclass thereof and returning true for instances to collect. Block is called only for instances castable to block parameter type.

◆ findAttachableBehavior()

ECAttachableBehavior Dragengine.Scenery.BehaviorElement.findAttachableBehavior ( Block  ablock)

Find attached behavior with block.

Block is required to have one parameter ECAttachableBehavior or subclass thereof and returning true if the right instance is found otherwise false. Block is called only for instances castable to block parameter type.

◆ findInstance()

ECBehaviorInstance Dragengine.Scenery.BehaviorElement.findInstance ( Block  ablock)

Find behavior instance with block.

Block is required to have one parameter ECBehaviorInstance or subclass thereof and returning true if the right instance is found otherwise false. Block is called only for instances castable to block parameter type.

◆ forEachAttachableBehavior()

void Dragengine.Scenery.BehaviorElement.forEachAttachableBehavior ( Block  ablock)

Visit attached s with block.

Block is required to have one parameter of type ECAttachableBehavior or subclass thereof. Block is called only for instances castable to block parameter type.

◆ forEachAttachableBehaviorReverse()

void Dragengine.Scenery.BehaviorElement.forEachAttachableBehaviorReverse ( Block  ablock)

Visit attached behaviors with block in reverse order.

Block is required to have one parameter ECAttachableBehavior or subclass thereof. Block is called only for instances castable to block parameter type.

◆ forEachInstance()

void Dragengine.Scenery.BehaviorElement.forEachInstance ( Block  ablock)

Visit behavior instances with block.

Block is required to have one parameter of type ECBehaviorInstance or subclass thereof. Block is called only for instances castable to block parameter type.

◆ forEachInstanceReverse()

void Dragengine.Scenery.BehaviorElement.forEachInstanceReverse ( Block  ablock)

Visit behavior instances with block in reverse order.

Block is required to have one parameter ECBehaviorInstance or subclass thereof. Block is called only for instances castable to block parameter type.

◆ getAttachableBehaviorAt()

ECAttachableBehavior Dragengine.Scenery.BehaviorElement.getAttachableBehaviorAt ( int  index)

Attached behavior at index.

Version
1.23

◆ getAttachableBehaviorCount()

int Dragengine.Scenery.BehaviorElement.getAttachableBehaviorCount ( )

Count of attachaed behaviors.

Version
1.23

◆ getRequiresAttachToParent()

bool Dragengine.Scenery.BehaviorElement.getRequiresAttachToParent ( )

Attach to parent has not been processed yet.

◆ getRequiresEnterFrame()

bool Dragengine.Scenery.BehaviorElement.getRequiresEnterFrame ( )

Sub-class requires enterFrame() to be called.

◆ getRequiresThink()

bool Dragengine.Scenery.BehaviorElement.getRequiresThink ( )

Sub-class requires think() to be called.

◆ isChangingGameWorld()

bool Dragengine.Scenery.BehaviorElement.isChangingGameWorld ( )

Behavior element is in progress of beeing added to or removed from a GameWorld.

Version
1.5

Returns true while inside addToGameWorld() or removeFromGameWorld(). This knowledge is required by certain behaviors to produce correct result.

For example ECBehaviorTwoStateAnimated requires In this situation the behavior element layout can look like this:

The ECBehaviorTriggered has been added by ECBehaviorTwoStateAnimated.

The rule of ECBehaviorTwoStateAnimated is that if the trigger changes while the element is in a GameWorld then activate() or deactivate() is called to start the transition process. If the element is not in a GameWorld then setActivated() or setDeactivated() has to be called instead. This is required to ensure the element starts out in the activated state when added to a game world in which the trigger expression happens to eavluate to true.

When the element is added to the game world the following call-chain happens:

ECBehaviorTriggered.addToGameWorld() evaluates the trigger expression using the GameWorld the element is beeing added to. Since the trigger expression evaluates to true all listeners are notified about the ECBehaviorTriggered state having changed to true. This causes ECBehaviorTwoStateAnimated.SwitchStateListener to be fired. At this point in time the BehaviorElement already returns the GameWorld instance instead of null and the ECBehaviorTwoStateAnimated thinks it needs to do an activate() instead of a setActivated().

By using isChangingGameWorld() the ECBehaviorTwoStateAnimated can figure out that it should not call activate() but setActivated().

◆ isReallyInGameWorld()

bool Dragengine.Scenery.BehaviorElement.isReallyInGameWorld ( )

Element is in GameWorld and not in progress of beeing removed from it.

Version
1.5

Convenience method returning true if getGameWorld() returns not null and isChangingGameWorld() returns false.

◆ new()

BehaviorElement Dragengine.Scenery.BehaviorElement.new ( BehaviorElementClass  eclass)

Create element.

◆ onSetPosition()

void Dragengine.Scenery.BehaviorElement.onSetPosition ( )

Position changed.

Reimplemented from Dragengine.Scenery.Element.

◆ removeAttachableBehavior()

void Dragengine.Scenery.BehaviorElement.removeAttachableBehavior ( ECAttachableBehavior  behavior)

Remove attached behavior.

Version
1.23

ECAttachableBehavior::dispose() is not called on the behavior.

◆ requiresThinkChanged()

void Dragengine.Scenery.BehaviorElement.requiresThinkChanged ( )

Requires thinking changed.

Called by ECBehaviorInstance if their requirement for thinking changed. This means the requiresThink() implementation returns a different value than the last time it has been checked.

This call will cause the behavior element to check again all behavior instances for their thinking requirement and will addThinker()/removeThinker() accordingly.

Using this method helps to reduce the script processing load by not making the element think() method called if no behavior requires it.

◆ setRequiresAttachToParent()

void Dragengine.Scenery.BehaviorElement.setRequiresAttachToParent ( bool  requiresAttachToParent)

Set if attach to parent has not been processed yet.

Version
1.15

Use this method if you need to reattach the element to the parent defined in the StubElement the next time it enters a game world.

◆ setRequiresEnterFrame()

void Dragengine.Scenery.BehaviorElement.setRequiresEnterFrame ( bool  requiresEnterFrame)
protected

Set if sub-class requires enterFrame() to be called.

◆ setRequiresThink()

void Dragengine.Scenery.BehaviorElement.setRequiresThink ( bool  requiresThink)
protected

Set if sub-class requires think() to be called.

Member Data Documentation

◆ pAttachableBehaviors

Array Dragengine.Scenery.BehaviorElement.pAttachableBehaviors

◆ pInstances

Array Dragengine.Scenery.BehaviorElement.pInstances

◆ pIsChangingGameWorld

bool Dragengine.Scenery.BehaviorElement.pIsChangingGameWorld

◆ pIsThinker

bool Dragengine.Scenery.BehaviorElement.pIsThinker

◆ pRequiresAttachToParent

bool Dragengine.Scenery.BehaviorElement.pRequiresAttachToParent

◆ pRequiresEnterFrame

bool Dragengine.Scenery.BehaviorElement.pRequiresEnterFrame

◆ pRequiresThink

bool Dragengine.Scenery.BehaviorElement.pRequiresThink

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