Drag[en]gine Script Module DragonScript Script API  1.0
Element Class Reference
Inheritance diagram for Element:
IMMCameraSpot IMMEnvironmentMap IMMLight IMMParticleEmitter IMMSpeaker BaseLight SimpleElement SpawnPoint Trigger TestingElement

Public Member Functions

void addToGameWorld ()
 
void dispose ()
 
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...
 
Quaternion getOrientation ()
 
Element getParent ()
 
DVector getPosition ()
 
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 isMyselfOrChildOf (Element parent)
 
Element new (ElementClass elementClass)
 
void onSetGameWorld ()
 
void onSetGeometry ()
 
void onSetOrientation ()
 
void onSetParent ()
 
void onSetPosition ()
 
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 setGameWorld (GameWorld gameWorld)
 
void setGeometry (DVector position, Quaternion orientation)
 
void setID (UniqueID id)
 
void setOrientation (Quaternion orientation)
 
void setParent (Element parent)
 
void setPosition (DVector position)
 
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 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...
 

Static Public Member Functions

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

Element of a game.

Author
Roland Pl├╝ss
Version
1.0

Member Function Documentation

◆ addToGameWorld()

void addToGameWorld ( )

Adds the element content to the game world if required.

◆ dispose()

void dispose ( )

Disposes of this Element. Use this function to unset all cross-references that would cause this Element to litter the memory.

◆ enterFrame()

void enterFrame ( )

Frame update started.

To receive this event call GameWorld.addEnterFrameOnce() from inside addToGameWorld(). This event is called at the beginning of the next frame update before think() of any element is called.

Use this method as a one-time call to carry out tasks required to be done once before any elements start thinking. Typically this is done after adding a new element to a game world to finish connections to other elements in the game world which can not be established before all required elements are added too.

Warning
Do not call GameWorld.addEnterFrameOnce() or GameWorld.removeEnterFrameOnce() from inside enterFrame(). Do this from addToGameWorld(), removeFromGameWorld(), think() or postThink().

◆ getClass()

ElementClass getClass ( )

Retrieves the element class.

◆ getElementMatrix()

DMatrix getElementMatrix ( )

Matrix to transform from element space into world space.

◆ getGameWorld()

GameWorld getGameWorld ( )

Retrieves the game world or null if not attached.

◆ getID()

UniqueID getID ( )

Retrieves the unique id or null if not set.

◆ getInverseElementMatrix()

DMatrix getInverseElementMatrix ( )

Matrix to transform from world space into element space.

◆ getOrientation()

Quaternion getOrientation ( )

Retrieves orientation of element.

◆ getParent()

Element getParent ( )

Retrieves the parent or null if not attached.

◆ getPosition()

DVector getPosition ( )

Returns position of element.

◆ getStub()

StubElement getStub ( )

Element stub used to create the element.

◆ getTouchable()

bool getTouchable ( )

Determines if the element is touchable.

◆ getVisible()

bool getVisible ( )

Determines if the element is visible.

◆ init()

void init ( StubElement  stub)

Initialize element from stub.

The stub is stored in the element for saving. Do not change the stub after using it for the init() call.

◆ isChildOf()

bool isChildOf ( Element  parent)

Determines if a this element is parented directly or indirectly to the given element. If the element is the same as the given element false is returned.

◆ isMyselfOrChildOf()

bool isMyselfOrChildOf ( Element  parent)

Determines if a this element is parented directly or indirectly to the given element. If the element is the same as the given element true is returned.

◆ new()

Element new ( ElementClass  elementClass)

Creates a new element object.

◆ onSetGameWorld()

void onSetGameWorld ( )

Game world changed.

◆ onSetGeometry()

void onSetGeometry ( )

Position and orientation changed.

◆ onSetOrientation()

void onSetOrientation ( )

Orientation changed.

◆ onSetParent()

void onSetParent ( )

Parent changed.

◆ onSetPosition()

void onSetPosition ( )

Position changed.

◆ onSetTouchable()

void onSetTouchable ( )

Touchable state changed.

◆ onSetVisible()

void onSetVisible ( )

Visible state changed.

◆ postThink()

void postThink ( float  elapsed)

Called after the physics system has carried out collision detection and physics simulations. The element has to update its states like position or rotation from its registered physics objects like Colliders or Components. Complex animated elements also update here the skeletal animations.

Parameters
elapsedTime elapsed since last frame update in seconds

◆ readElementFromFileWithStub()

static Element readElementFromFileWithStub ( PersistencyEnvironment  env,
FileReader  reader,
ElementClassList  ElementClassList 
)
static

Load element from file reader with stub supporting null element.

Reads element class name from reader. If element class name is empty null element is returned. Otherwise stub and element is read from file reader. Uses ElementClass.loadElement() if supported.

◆ readFromFile()

void readFromFile ( PersistencyEnvironment  env,
FileReader  reader 
)

Read element from file reader.

Default implementation does nothing.

◆ removeFromGameWorld()

void removeFromGameWorld ( )

Removes the element content from the game world if placed there before.

◆ removeFromGameWorldIfPresent()

void removeFromGameWorldIfPresent ( )

Remove element from game world if present.

◆ setGameWorld()

void setGameWorld ( GameWorld  gameWorld)

Sets the game world or null if not attached.

◆ setGeometry()

void setGeometry ( DVector  position,
Quaternion  orientation 
)

Sets the position and orientation of element.

◆ setID()

void setID ( UniqueID  id)

Sets the unique id or null to unset it.

◆ setOrientation()

void setOrientation ( Quaternion  orientation)

Set orientation of element.

◆ setParent()

void setParent ( Element  parent)

Sets the parent or null if not attached.

◆ setPosition()

void setPosition ( DVector  position)

Sets the position of element.

◆ setStub()

void setStub ( StubElement  stub)

Set element stub used to create the element.

◆ setTouchable()

void setTouchable ( bool  touchable)

Sets if the element is touchable.

◆ setVisible()

void setVisible ( bool  visible)

Sets if the element is visible.

◆ think()

void think ( float  elapsed)

Thinks about what the element is going to do in this frame. This is the place to use AI functions to determine the next motions beeing it displacement, rotation or other shape changes. The game world will use this information to carry out changes to the elements. An element does not change its state by itself rather waits for the game world to apply the required changes. Execute here als updates to dynamic skins that are independant, hence not requiring the game world to be uptodate for rendering.

Parameters
elapsedTime elapsed since last frame update in seconds

◆ toString()

String toString ( )

Return string representation of this Element.

◆ visit()

void visit ( ElementVisitor  visitor)

Visit this element.

◆ writeElementToFileWithStub()

static void writeElementToFileWithStub ( PersistencyEnvironment  env,
FileWriter  writer,
Element  element 
)
static

Write element to file writer with stub supporting null element.

Writes element class name, then the stub parameters and then the element parameters. If no stub exists an empty one is used for writing stub parameters. If element is null empty element class name is written. Empty element class name is used during loading to indicate a null element.

◆ writeToFile()

void writeToFile ( PersistencyEnvironment  env,
FileWriter  writer 
)

Write element to file writer.

Default implementation does nothing.

Note
Updating save file format can be done by adding to the StubElement a property with the save file version used, for example "@saveVersion" or similar. Since the stub element is read and stored during init while loading this information is present when readFromFile() is called.

◆ writeToFileWithStub()

void writeToFileWithStub ( PersistencyEnvironment  env,
FileWriter  writer 
)

Write element to file writer with stub.

Writes element class name, then the stub parameters and then the element parameters. If no stub exists an empty one is used for writing stub parameters.


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