Drag[en]gine Script Module DragonScript Script API  1.0
SimpleElement Class Reference

Simple element. More...

Inheritance diagram for SimpleElement:
Element IMMProp IMMHotSpot

Public Member Functions

void addToGameWorld ()
 Add element to game world. More...
 
void dispose ()
 Dispose of element. More...
 
Collider getCollider ()
 Collider or null if not set. More...
 
Component getComponent ()
 Component or null if not set. More...
 
Dictionary getRigShapeDataMap ()
 Rig shape data dictionary using rig shape property as key. More...
 
void init (StubElement stub)
 Initialize element from stub. More...
 
SimpleElement new (SimpleElementClass eclass)
 Create element. More...
 
void onSetGeometry ()
 Position and orientation changed. More...
 
void onSetOrientation ()
 Orientation changed. More...
 
void onSetPosition ()
 Position changed. More...
 
void onSetTouchable ()
 Touchable state changed. More...
 
void onSetVisible ()
 Visible state changed. More...
 
void removeFromGameWorld ()
 Remove element from game world if set. More...
 
void visit (ElementVisitor visitor)
 Visit element. More...
 
- Public Member Functions inherited from Element
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...
 

Protected Member Functions

void attachComponent (StubElement stub)
 Attach component to collider. More...
 
Collider createCollider (StubElement stub)
 Create collider for the element. More...
 
ShapeList createColliderShapeExtends (StubElement stub)
 Create box shape for collider volume matching component extends. More...
 
ColliderVolume createColliderVolumeExtends (StubElement stub)
 Create collider volume matching component extends. More...
 
CollisionFilter createCollisionFilter (StubElement stub)
 Create collision filter for a collider. More...
 
Component createComponent (StubElement stub)
 Create component for the element. More...
 
ColliderVolume createGhostCollider ()
 Create ghost collider. More...
 
void setCollider (Collider collider)
 Set collider or null if not set. More...
 
void setComponent (Component comp)
 Set component or null if not set. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from 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

Simple element.

Simple elements contain a component and a collider both of which can be null. If a component is present a component collider is created. If component is null no collider is created. If a collider is created the component is attached to it. The subclass has to only move the collider.

This class handles colliders with static response type. If the collider changes position the element is not updated correctly. If you need kinematic or dynamic response type you have to implement ColliderListener and call setColliderListener.

A rig shape data map is provided to allow identifying collision materials if a component collider is used.

Changing the visible state changes the visible state of the component if present. Changing the touchable state changes the enabled state of the collider if present.

Simple elements are considered static in nature by default. They do not save any dynamic properties to file writers. If the subclass is of dynamic nature it has to save the appropriate element properties.

Various hook methods are present for subclasses to modify the behavior:

To support loading and saving of dynamic subclasses overwrite these methods:

Member Function Documentation

◆ addToGameWorld()

void addToGameWorld ( )

Add element to game world.

◆ attachComponent()

void attachComponent ( StubElement  stub)
protected

Attach component to collider.

The default implementation attaches the component statically if the component and collider exists. For this to work the component has to be in the right position relative to the collider.

◆ createCollider()

Collider createCollider ( StubElement  stub)
protected

Create collider for the element.

It is not required to create a collider but without a collider no resources can be attached and have to be handled manually. To support attaching but without a collider affecting the world use createGhostCollider(). The default implementation creates a component collider if the element component is not null and has a rig which is not null. Otherwise no collider is created. If you want to use an automatic collision box collider volume the shape can be created using createColliderShapeExtends().

If a collider is created it is initilized with parameters stored in the element class modified by the stub. Uses createCollisionFilter() to create the collision filter. Collider components attach their component automatically so no explicit attaching is required.

Overwrite to modify collider creation process using parameters stored in the stub if required.

◆ createColliderShapeExtends()

ShapeList createColliderShapeExtends ( StubElement  stub)
protected

Create box shape for collider volume matching component extends.

◆ createColliderVolumeExtends()

ColliderVolume createColliderVolumeExtends ( StubElement  stub)
protected

Create collider volume matching component extends.

◆ createCollisionFilter()

CollisionFilter createCollisionFilter ( StubElement  stub)
protected

Create collision filter for a collider.

The default implementation creates an empty collision filter.

◆ createComponent()

Component createComponent ( StubElement  stub)
protected

Create component for the element.

It is not required to create a component. Return null to use no component. The default implementation creates a component using the component parameters stored in the element class. If not all required resources can be found no component is created. Overwrite to modify component creation process using parameters stored in the sub if required.

◆ createGhostCollider()

ColliderVolume createGhostCollider ( )
protected

Create ghost collider.

A ghost collider can be used to attach resources but does not affect the world. It is disabled and has an empty collision filter. The position and orientation is taken from the stub.

◆ dispose()

void dispose ( )

Dispose of element.

◆ getCollider()

Collider getCollider ( )

Collider or null if not set.

◆ getComponent()

Component getComponent ( )

Component or null if not set.

◆ getRigShapeDataMap()

Dictionary getRigShapeDataMap ( )

Rig shape data dictionary using rig shape property as key.

◆ init()

void init ( StubElement  stub)

Initialize element from stub.

◆ new()

Create element.

◆ onSetGeometry()

void onSetGeometry ( )

Position and orientation changed.

◆ onSetOrientation()

void onSetOrientation ( )

Orientation changed.

◆ onSetPosition()

void onSetPosition ( )

Position changed.

◆ onSetTouchable()

void onSetTouchable ( )

Touchable state changed.

◆ onSetVisible()

void onSetVisible ( )

Visible state changed.

◆ removeFromGameWorld()

void removeFromGameWorld ( )

Remove element from game world if set.

Does not dispose of the element.

◆ setCollider()

void setCollider ( Collider  collider)
protected

Set collider or null if not set.

◆ setComponent()

void setComponent ( Component  comp)
protected

Set component or null if not set.

◆ visit()

void visit ( ElementVisitor  visitor)

Visit element.


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