Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
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.BaseWorld 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.
Array collectAttachableBehaviors (Block ablock)
 Collect attached behaviors with block into Array.
Array collectInstances (Block ablock)
 Collect behavior instance with block into Array.
ECAttachableBehavior findAttachableBehavior (Block ablock)
 Find attached behavior with block.
ECBehaviorInstance findInstance (Block ablock)
 Find behavior instance with block.
void forEachAttachableBehavior (Block ablock)
 Visit attached s with block.
void forEachAttachableBehaviorReverse (Block ablock)
 Visit attached behaviors with block in reverse order.
ECAttachableBehavior getAttachableBehaviorAt (int index)
 Attached behavior at index.
int getAttachableBehaviorCount ()
 Count of attachaed behaviors.
bool getRequiresAttachToParent ()
 Attach to parent has not been processed yet.
bool getRequiresEnterFrame ()
 Sub-class requires enterFrame() to be called.
bool getRequiresThink ()
 Sub-class requires think() to be called.
float getTimeScale ()
 Time scale applied to elapsed time.
bool isChangingGameWorld ()
 Behavior element is in progress of beeing added to or removed from a GameWorld.
bool isReallyInGameWorld ()
 Element is in GameWorld and not in progress of beeing removed from it.
BehaviorElement new (BehaviorElementClass eclass)
 Create element.
void onSetPosition ()
 Position changed.
void registerPostInit (BehaviorPostInit behavior)
 Register behavior instance for post init.
void removeAttachableBehavior (ECAttachableBehavior behavior)
 Remove attached behavior.
void requiresThinkChanged ()
 Requires thinking changed.
void setRequiresAttachToParent (bool requiresAttachToParent)
 Set if attach to parent has not been processed yet.
void setTimeScale (float scale)
 Set time scale applied to elapsed time.
Public Member Functions inherited from Dragengine.Scenery.Element
void addToGameWorld ()
Dictionary debugInformation ()
 Debug information as Dictionary.
void dispose ()
 Dispose of element.
void enterFrame ()
 Frame update started.
ElementClass getClass ()
DMatrix getElementMatrix ()
 Matrix to transform from element space into world space.
GameWorld getGameWorld ()
UniqueID getID ()
DMatrix getInverseElementMatrix ()
 Matrix to transform from world space into element space.
bool getIsScaled ()
 Is scaled.
Quaternion getOrientation ()
 Orientation.
Element getParent ()
DVector getPosition ()
 Position.
Vector getScaling ()
 Scaling.
StubElement getStub ()
 Element stub used to create the element.
bool getTouchable ()
bool getVisible ()
void init (StubElement stub)
 Initialize element from stub.
bool isChildOf (Element parent)
bool isDisposed ()
 Element has been disposed of.
bool isMyselfOrChildOf (Element parent)
bool isNotDisposed ()
 Element has not been disposed of.
void log (String message)
 Log using BaseGameApp Console if present.
Element new (ElementClass elementClass)
void onSetGameWorld ()
void onSetGeometry ()
 Position, orientation or scaling changed.
void onSetOrientation ()
 Orientation changed.
void onSetParent ()
void onSetScaling ()
 Scaling changed.
void onSetTouchable ()
void onSetVisible ()
void postThink (float elapsed)
void readFromFile (PersistencyEnvironment env, FileReader reader)
 Read element from file reader.
void removeFromGameWorld ()
void removeFromGameWorldIfPresent ()
 Remove element from game world if present.
void safeDispose ()
 Remove element from game world if present and dispose of element.
void setGameWorld (GameWorld gameWorld)
void setGeometry (DVector position, Quaternion orientation)
 Set position and orientation.
void setGeometry (DVector position, Quaternion orientation, Vector scaling)
 Set position, orientation and scaling of element.
void setID (UniqueID id)
void setOrientation (Quaternion orientation)
 Set orientation.
void setParent (Element parent)
void setPosition (DVector position)
 Set position.
void setScaling (Vector scaling)
 Set scaling.
void setStub (StubElement stub)
 Set element stub used to create the element.
void setTouchable (bool touchable)
void setVisible (bool visible)
void think (float elapsed)
String toString ()
void updateStubGeometryFromElement ()
 Update stub position, rotation and scaling from element.
void visit (ElementVisitor visitor)
void writeToFile (PersistencyEnvironment env, FileWriter writer)
 Write element to file writer.
void writeToFileWithStub (PersistencyEnvironment env, FileWriter writer)
 Write element to file writer with stub.

Public Attributes

Array pAttachableBehaviors
Array pInstances
bool pIsChangingGameWorld
bool pRequiresEnterFrame
float pTimeScale
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.
void setRequiresThink (bool requiresThink)
 Set if sub-class requires think() to be called.

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.
static void writeElementToFileWithStub (PersistencyEnvironment env, FileWriter writer, Element element)
 Write element to file writer with stub supporting null element.

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

References Dragengine.Scenery.Element.init(), and pInstances.

Referenced by setTimeScale().

◆ 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.

References pInstances.

Referenced by onSetPosition().

◆ 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.

References pInstances.

Referenced by getRequiresAttachToParent().

◆ 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.

References pInstances.

Referenced by isChangingGameWorld().

◆ 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.

References Dragengine.Scenery.Element.dispose(), and pAttachableBehaviors.

Referenced by getRequiresThink().

◆ 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.

Referenced by removeAttachableBehavior(), and requiresThinkChanged().

◆ 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.

References pInstances.

Referenced by requiresThinkChanged().

◆ getAttachableBehaviorAt()

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

Attached behavior at index.

Version
1.23

References Dragengine.Scenery.Element.init().

Referenced by setTimeScale().

◆ getAttachableBehaviorCount()

int Dragengine.Scenery.BehaviorElement.getAttachableBehaviorCount ( )

Count of attachaed behaviors.

Version
1.23

References Dragengine.Scenery.Element.dispose().

Referenced by getTimeScale().

◆ getRequiresAttachToParent()

bool Dragengine.Scenery.BehaviorElement.getRequiresAttachToParent ( )

Attach to parent has not been processed yet.

References collectInstances(), and pInstances.

Referenced by onSetPosition().

◆ getRequiresEnterFrame()

bool Dragengine.Scenery.BehaviorElement.getRequiresEnterFrame ( )

Sub-class requires enterFrame() to be called.

Referenced by onSetPosition().

◆ getRequiresThink()

bool Dragengine.Scenery.BehaviorElement.getRequiresThink ( )

Sub-class requires think() to be called.

References findInstance(), and pInstances.

Referenced by onSetPosition().

◆ getTimeScale()

float Dragengine.Scenery.BehaviorElement.getTimeScale ( )

Time scale applied to elapsed time.

Version
1.35

References getAttachableBehaviorCount(), and pAttachableBehaviors.

Referenced by onSetPosition().

◆ 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().

References findAttachableBehavior(), and pAttachableBehaviors.

Referenced by onSetPosition().

◆ 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.

Referenced by onSetPosition().

◆ new()

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

Create element.

References new(), pAttachableBehaviors, pInstances, and pTimeScale.

Referenced by new(), onSetPosition(), and setTimeScale().

◆ onSetPosition()

◆ registerPostInit()

void Dragengine.Scenery.BehaviorElement.registerPostInit ( BehaviorPostInit behavior)

Register behavior instance for post init.

Version
1.26

Call this during ECBehaviorInstance.init() to register for a post-init.

References pInstances.

Referenced by onSetPosition().

◆ removeAttachableBehavior()

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

Remove attached behavior.

Version
1.23

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

References forEachAttachableBehavior(), and Dragengine.Scenery.Element.getClass().

Referenced by requiresThinkChanged().

◆ 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.

References forEachAttachableBehavior(), forEachAttachableBehaviorReverse(), pAttachableBehaviors, and removeAttachableBehavior().

Referenced by onSetPosition().

◆ 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.

Referenced by onSetPosition().

◆ setRequiresEnterFrame()

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

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

Referenced by Dragengine.Gui.MainMenus.Interactive.IMMLight.new(), and onSetPosition().

◆ setRequiresThink()

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

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

Referenced by onSetPosition().

◆ setTimeScale()

void Dragengine.Scenery.BehaviorElement.setTimeScale ( float scale)

Set time scale applied to elapsed time.

Version
1.35

References addAttachableBehavior(), getAttachableBehaviorAt(), new(), and pAttachableBehaviors.

Referenced by onSetPosition().

Member Data Documentation

◆ pAttachableBehaviors

Array Dragengine.Scenery.BehaviorElement.pAttachableBehaviors

◆ pInstances

◆ pIsChangingGameWorld

bool Dragengine.Scenery.BehaviorElement.pIsChangingGameWorld

Referenced by onSetPosition().

◆ pRequiresEnterFrame

bool Dragengine.Scenery.BehaviorElement.pRequiresEnterFrame

Referenced by onSetPosition().

◆ pTimeScale

float Dragengine.Scenery.BehaviorElement.pTimeScale

Referenced by new(), and onSetPosition().


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