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

Element class. More...

Inheritance diagram for Dragengine.Scenery.ElementClass:
Dragengine.ResourceListener Dragengine.Gui.MainMenus.Interactive.IMMCameraSpotClass Dragengine.Scenery.BehaviorElementClass Dragengine.Scenery.IgnoreElementClass Dragengine.Scenery.RailCornerClass Dragengine.Scenery.RandomElementClass Dragengine.Scenery.SpawnPointClass Dragengine.Gui.MainMenus.Interactive.IMMEnvironmentMapClass Dragengine.Gui.MainMenus.Interactive.IMMLightClass Dragengine.Gui.MainMenus.Interactive.IMMParticleEmitterClass Dragengine.Gui.MainMenus.Interactive.IMMPropClass Dragengine.Gui.MainMenus.Interactive.IMMSpeakerClass Dragengine.Scenery.AttachSlotClass Dragengine.Scenery.AttachableBaseBillboardClass Dragengine.Scenery.AttachableBaseForceFieldClass Dragengine.Scenery.AttachableBaseLightClass Dragengine.Scenery.AttachableBaseParticleEmitterClass Dragengine.Scenery.AttachableBaseSpeakerClass Dragengine.Scenery.BaseActorClass Dragengine.Scenery.BaseBillboardClass Dragengine.Scenery.BaseForceFieldClass Dragengine.Scenery.BaseLightClass Dragengine.Scenery.BaseParticleEmitterClass Dragengine.Scenery.BaseSkyClass Dragengine.Scenery.BaseSpeakerClass Dragengine.Scenery.EnvironmentMapClass Dragengine.Scenery.GhostElementClass Dragengine.Scenery.InfoConvoCoordSystemClass Dragengine.Scenery.PhysicsElementClass Dragengine.Scenery.SimpleElementClass Dragengine.Scenery.TriggerConversationClass Dragengine.Scenery.TriggerEvaluateClass Dragengine.Scenery.TriggerShoutClass Dragengine.Scenery.TriggerTimerClass Dragengine.Scenery.TriggerToggleClass Dragengine.Scenery.TriggerTouchClass Dragengine.TestSystem.TestCaseECBehavior.TestBehaviorElementClass Dragengine.TestSystem.TestCaseECBehaviorPersistency.TestBehaviorElementClass

Public Member Functions

void addProperty (ElementClassProperty property)
 Add property. More...
 
void copyPropertyValues (ElementClass eclass)
 Copy values of properties from another class to properties of this class. More...
 
void createAndAddElement (StubElement stub, GameWorld gameWorld)
 Create element from given stub and add it to game world. More...
 
Element createElement (StubElement stub)
 Create element instance from stub. More...
 
void dispose ()
 Dispose of element class. More...
 
ElementClass duplicateNamed (String classname)
 Create duplicate of class with new name. More...
 
bool equals (Object obj)
 Element class is equal to another object. More...
 
void failedLoading (String path, ResourceLoaderType resourceType)
 Resource failed loading. More...
 
void finishedLoading (String path, ResourceLoaderType resourceType, Object resource)
 Resource finished loading successfully. More...
 
void forEachProperty (Block ablock)
 Visit properties with block with parameter ElementClass. More...
 
String getBasePath ()
 Base path for relative loading of resource properties. More...
 
CodecPropertyString getCodecPropertyString ()
 Property codec helper. More...
 
bool getIsXmlElementClass ()
 Element class is an XML element class. More...
 
bool getPersistable ()
 Element class is persistable to file writers. More...
 
int getPropertyCount ()
 Number of properties. More...
 
ElementClassProperty getPropertyNamed (String name)
 Named property or null if absent. More...
 
Array getPropertyNames ()
 List of property names as array of strings. More...
 
TSTriggerExpressionParser getTriggerExpressionParser ()
 Trigger expression parser. More...
 
int hashCode ()
 Hash code. More...
 
bool hasPropertyNamed (String name)
 Named property is present. More...
 
Object injectProperty (Object injectValue, Block ablock)
 Process value visiting properties. More...
 
void loadAndAddElement (PersistencyEnvironment env, StubElement stub, FileReader reader, GameWorld gameWorld)
 Load element from file reader and add it to game world. More...
 
Element loadElement (PersistencyEnvironment env, StubElement stub, FileReader reader)
 Load element from file reader. More...
 
ElementClass new (String className)
 Create element class. More...
 
void removeAllProperties ()
 Remove all properties. More...
 
void removeProperty (ElementClassProperty property)
 Remove property. More...
 
void setBasePath (String path)
 Set base path for relative loading of resource properties. More...
 
void setIsXmlElementClass (bool isXmlElementClass)
 Set if element class is an XML element class. More...
 
void setPersistable (bool persistable)
 Set element class is persistable to file writers. More...
 
void setPropertyValue (String name, Object value)
 Set value of named property. More...
 
Notification

Static Public Member Functions

static CodecPropertyString getSharedCodecPropertyString ()
 Shared property codec helper. More...
 
static TSTriggerExpressionParser getSharedTriggerExpressionParser ()
 Shared trigger expression parser. More...
 
static void setSharedCodecPropertyString (CodecPropertyString codec)
 Set shared property codec helper. More...
 
static void setSharedTriggerExpressionParser (TSTriggerExpressionParser parser)
 Set shared trigger expression parser. More...
 

Protected Member Functions

Element createElement ()
 Create element instance. More...
 

Detailed Description

Element class.

Describes class of elements. Instances of this element classes can be created from stubs and loaded from file readers. Supports class properties suitable for using XML subclassing.

Element classes can be set to not be persistable to file writers (for example save states). By default all element classes are persistable. Persistable element classes are not loaded if the world file is loaded only for the purpose to restore elements from file readers. Not persistable element classes are not written to file writers. Instead they are created if a world is loaded for the purpose to restore elements from file readers. Not persistable element classes are typically static geometry not changing or special elements not producing an element in the world but doing other things. See StaticGeometryClass in the example project for an example on how to use this feature.

Member Function Documentation

◆ addProperty()

void Dragengine.Scenery.ElementClass.addProperty ( ElementClassProperty  property)

Add property.

◆ copyPropertyValues()

void Dragengine.Scenery.ElementClass.copyPropertyValues ( ElementClass  eclass)

Copy values of properties from another class to properties of this class.

Version
1.17

Using this function call is required to support nested XML subclassing. Nested XML subclassing means the class duplicateNamed() is called on is not a script class but an XML subclass. In this situation the duplicateNamed() is called on the script class the base XML subclass has been created from and the values set to the properties using the XML file are lost.

◆ createAndAddElement()

void Dragengine.Scenery.ElementClass.createAndAddElement ( StubElement  stub,
GameWorld  gameWorld 
)

Create element from given stub and add it to game world.

Calls createElement(stub) to obtain a new element instance. If the returned element is null no further processing is done. If an element is returned it is added to gameWorld.

Most subclasses overwrite createElement() to create an instance of the subclass. Subclasses not representing actual elements or require special handling should overwrite this method and loadAndAddElement() to provide the specific handling.

Reimplemented in Dragengine.Scenery.SpawnPointClass, Dragengine.Scenery.RailCornerClass, Dragengine.Scenery.IgnoreElementClass, and Dragengine.Scenery.BehaviorElementClass.

◆ createElement() [1/2]

Element Dragengine.Scenery.ElementClass.createElement ( )
protected

Create element instance.

If this element class does not support creating elements, for example because the result is not an element, null has to be returned. The default implementation returns null. Subclasses not intending to create elements or requiring special creation handling should subclass createAndAddElement() and loadAndAddElement() bypassing this method.

Reimplemented in Dragengine.TestSystem.TestCaseECBehaviorPersistency.TestBehaviorElementClass, Dragengine.TestSystem.TestCaseECBehavior.TestBehaviorElementClass, Dragengine.Scenery.TwoStateAnimatedElementClass, Dragengine.Scenery.TriggerTouchClass, Dragengine.Scenery.TriggerToggleClass, Dragengine.Scenery.TriggerTimerClass, Dragengine.Scenery.TriggerShoutClass, Dragengine.Scenery.TriggerEvaluateClass, Dragengine.Scenery.TriggerConversationClass, Dragengine.Scenery.SimpleElementClass, Dragengine.Scenery.RandomElementClass, Dragengine.Scenery.SimpleElementOnRailClass, Dragengine.Scenery.PhysicsElementClass, Dragengine.Scenery.InfoConvoCoordSystemClass, Dragengine.Scenery.IgnoreElementClass, Dragengine.Scenery.HiddenElementClass, Dragengine.Scenery.GhostElementClass, Dragengine.Scenery.EnvironmentMapClass, Dragengine.Scenery.BehaviorElementClass, Dragengine.Scenery.BaseSpeakerClass, Dragengine.Scenery.BaseSkyClass, Dragengine.Scenery.BaseParticleEmitterClass, Dragengine.Scenery.BaseLightClass, Dragengine.Scenery.BaseForceFieldClass, Dragengine.Scenery.BaseBillboardClass, Dragengine.Scenery.AttachSlotClass, Dragengine.Scenery.AttachableBaseSpeakerClass, Dragengine.Scenery.AttachableBaseParticleEmitterClass, Dragengine.Scenery.AttachableBaseLightClass, Dragengine.Scenery.AttachableBaseForceFieldClass, Dragengine.Scenery.AttachableBaseBillboardClass, Dragengine.Scenery.AnimatedElementClass, Dragengine.Scenery.BaseVRActorClass, Dragengine.Scenery.BaseActorClass, Dragengine.Gui.MainMenus.Interactive.IMMSpeakerClass, Dragengine.Gui.MainMenus.Interactive.IMMPropClass, Dragengine.Gui.MainMenus.Interactive.IMMParticleEmitterClass, Dragengine.Gui.MainMenus.Interactive.IMMLightClass, Dragengine.Gui.MainMenus.Interactive.IMMHotSpotClass, Dragengine.Gui.MainMenus.Interactive.IMMEnvironmentMapClass, and Dragengine.Gui.MainMenus.Interactive.IMMCameraSpotClass.

◆ createElement() [2/2]

Element Dragengine.Scenery.ElementClass.createElement ( StubElement  stub)

Create element instance from stub.

Calls createElement() to create the element. If the returned element is null no further processing is done. If an element is returned init() is called on the element using stub.

This method is used by createAndAddElement() and loadAndAddElement(). It can be used to create fully initialized elements without adding them to the game world.

Reimplemented in Dragengine.Scenery.RandomElementClass, and Dragengine.Scenery.IgnoreElementClass.

◆ dispose()

◆ duplicateNamed()

ElementClass Dragengine.Scenery.ElementClass.duplicateNamed ( String  classname)

Create duplicate of class with new name.

This is used for creating element classes using XML element class loading. If this class does not support XML subclassing return null.

The default implementation returns null.

Reimplemented in Dragengine.Scenery.EnvironmentMapClass, Dragengine.Gui.MainMenus.Interactive.IMMSpeakerClass, Dragengine.Gui.MainMenus.Interactive.IMMPropClass, Dragengine.Gui.MainMenus.Interactive.IMMParticleEmitterClass, Dragengine.Gui.MainMenus.Interactive.IMMLightClass, Dragengine.Gui.MainMenus.Interactive.IMMHotSpotClass, Dragengine.Gui.MainMenus.Interactive.IMMEnvironmentMapClass, Dragengine.Gui.MainMenus.Interactive.IMMCameraSpotClass, Dragengine.Scenery.TwoStateAnimatedElementClass, Dragengine.Scenery.TriggerTouchClass, Dragengine.Scenery.TriggerToggleClass, Dragengine.Scenery.TriggerTimerClass, Dragengine.Scenery.TriggerShoutClass, Dragengine.Scenery.TriggerEvaluateClass, Dragengine.Scenery.TriggerConversationClass, Dragengine.Scenery.SimpleElementClass, Dragengine.Scenery.RandomElementClass, Dragengine.Scenery.SimpleElementOnRailClass, Dragengine.Scenery.PhysicsElementClass, Dragengine.Scenery.InfoConvoCoordSystemClass, Dragengine.Scenery.IgnoreElementClass, Dragengine.Scenery.HiddenElementClass, Dragengine.Scenery.GhostElementClass, Dragengine.Scenery.BaseSpeakerClass, Dragengine.Scenery.BaseSkyClass, Dragengine.Scenery.BaseParticleEmitterClass, Dragengine.Scenery.BaseLightClass, Dragengine.Scenery.BaseForceFieldClass, Dragengine.Scenery.BaseBillboardClass, Dragengine.Scenery.AttachSlotClass, Dragengine.Scenery.AttachableBaseSpeakerClass, Dragengine.Scenery.AttachableBaseParticleEmitterClass, Dragengine.Scenery.AttachableBaseLightClass, Dragengine.Scenery.AttachableBaseForceFieldClass, Dragengine.Scenery.AttachableBaseBillboardClass, and Dragengine.Scenery.AnimatedElementClass.

◆ equals()

bool Dragengine.Scenery.ElementClass.equals ( Object  obj)

Element class is equal to another object.

Two element classes are equal if they have the same class name.

◆ failedLoading()

void Dragengine.Scenery.ElementClass.failedLoading ( String  path,
ResourceLoaderType  resourceType 
)

Resource failed loading.

Implements Dragengine.ResourceListener.

◆ finishedLoading()

void Dragengine.Scenery.ElementClass.finishedLoading ( String  path,
ResourceLoaderType  resourceType,
Object  resource 
)

Resource finished loading successfully.

Implements Dragengine.ResourceListener.

◆ forEachProperty()

void Dragengine.Scenery.ElementClass.forEachProperty ( Block  ablock)

Visit properties with block with parameter ElementClass.

◆ getBasePath()

String Dragengine.Scenery.ElementClass.getBasePath ( )

Base path for relative loading of resource properties.

◆ getCodecPropertyString()

CodecPropertyString Dragengine.Scenery.ElementClass.getCodecPropertyString ( )

Property codec helper.

Default implementation uses shared coded property string. Subclass to use a specific codec for this class only.

◆ getIsXmlElementClass()

bool Dragengine.Scenery.ElementClass.getIsXmlElementClass ( )

Element class is an XML element class.

Version
1.17

◆ getPersistable()

bool Dragengine.Scenery.ElementClass.getPersistable ( )

Element class is persistable to file writers.

◆ getPropertyCount()

int Dragengine.Scenery.ElementClass.getPropertyCount ( )

Number of properties.

◆ getPropertyNamed()

ElementClassProperty Dragengine.Scenery.ElementClass.getPropertyNamed ( String  name)

Named property or null if absent.

◆ getPropertyNames()

Array Dragengine.Scenery.ElementClass.getPropertyNames ( )

List of property names as array of strings.

◆ getSharedCodecPropertyString()

static CodecPropertyString Dragengine.Scenery.ElementClass.getSharedCodecPropertyString ( )
static

Shared property codec helper.

◆ getSharedTriggerExpressionParser()

static TSTriggerExpressionParser Dragengine.Scenery.ElementClass.getSharedTriggerExpressionParser ( )
static

Shared trigger expression parser.

◆ getTriggerExpressionParser()

TSTriggerExpressionParser Dragengine.Scenery.ElementClass.getTriggerExpressionParser ( )

Trigger expression parser.

Default implementation uses shared trigger expression parser. Subclass to use a specific parser for this class only.

◆ hashCode()

int Dragengine.Scenery.ElementClass.hashCode ( )

Hash code.

◆ hasPropertyNamed()

bool Dragengine.Scenery.ElementClass.hasPropertyNamed ( String  name)

Named property is present.

◆ injectProperty()

Object Dragengine.Scenery.ElementClass.injectProperty ( Object  injectValue,
Block  ablock 
)

Process value visiting properties.

Works like Array.inject() . Block receives Object processed value as first argument and ElementClassProperty as second argument. Block return value becomes processed value for the next visited property. First property received initialValue to process.

◆ loadAndAddElement()

void Dragengine.Scenery.ElementClass.loadAndAddElement ( PersistencyEnvironment  env,
StubElement  stub,
FileReader  reader,
GameWorld  gameWorld 
)

Load element from file reader and add it to game world.

Calls loadElement(stub) to obtain a new element instance. If the returned element is null no further processing is done. If an element is returned it is added to the gameWorld.

Most subclasses overwrite createElement() to create an instance of the subclass. Subclasses not representing actual elements or require special handling should overwrite this method and createAndAddElement() to provide the specific handling.

Reimplemented in Dragengine.Scenery.RandomElementClass, and Dragengine.Scenery.IgnoreElementClass.

◆ loadElement()

Element Dragengine.Scenery.ElementClass.loadElement ( PersistencyEnvironment  env,
StubElement  stub,
FileReader  reader 
)

Load element from file reader.

Calls createElement(stub) to obtain a new element instance. If the returned element is null no further processing is done. If an element is returned readFromFile(reader) is called on the element. Then the element is added to gameWorld.

This method is used by loadAndAddElement(). It can be used to create fully loaded elements without adding them to the game world.

Reimplemented in Dragengine.Scenery.RandomElementClass, and Dragengine.Scenery.IgnoreElementClass.

◆ new()

◆ removeAllProperties()

void Dragengine.Scenery.ElementClass.removeAllProperties ( )

Remove all properties.

◆ removeProperty()

void Dragengine.Scenery.ElementClass.removeProperty ( ElementClassProperty  property)

Remove property.

◆ setBasePath()

void Dragengine.Scenery.ElementClass.setBasePath ( String  path)

Set base path for relative loading of resource properties.

◆ setIsXmlElementClass()

void Dragengine.Scenery.ElementClass.setIsXmlElementClass ( bool  isXmlElementClass)

Set if element class is an XML element class.

Version
1.17

◆ setPersistable()

void Dragengine.Scenery.ElementClass.setPersistable ( bool  persistable)

Set element class is persistable to file writers.

◆ setPropertyValue()

void Dragengine.Scenery.ElementClass.setPropertyValue ( String  name,
Object  value 
)

Set value of named property.

Used by LoadElementClass to set the property value. This is not necessarily the same as the value retrieved from the property for use by Element instances. For example with resources this sets the path to the resource to load while the Element instances get the loaded resource itself.

Parameters
nameName of property to set value for.
valueValue to set.
basePathBase path for relative resource loading.
Exceptions
EInvalidParamProperty is absent.
ExceptionValue is not understood by property.

◆ setSharedCodecPropertyString()

static void Dragengine.Scenery.ElementClass.setSharedCodecPropertyString ( CodecPropertyString  codec)
static

Set shared property codec helper.

◆ setSharedTriggerExpressionParser()

static void Dragengine.Scenery.ElementClass.setSharedTriggerExpressionParser ( TSTriggerExpressionParser  parser)
static

Set shared trigger expression parser.


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