Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
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.BaseWorldClass Dragengine.Scenery.EnvironmentMapClass Dragengine.Scenery.GenericBehaviorElementClass 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.
void copyPropertyValues (ElementClass eclass)
 Copy values of properties from another class to properties of this class.
void createAndAddElement (StubElement stub, GameWorld gameWorld)
 Create element from given stub and add it to game world.
Element createElement (StubElement stub)
 Create element instance from stub.
void dispose ()
 Dispose of element class.
ElementClass duplicateNamed (String classname)
 Create duplicate of class with new name.
bool equals (Object obj)
 Element class is equal to another object.
void failedLoading (String path, ResourceLoaderType resourceType)
 Resource failed loading.
void finishedLoading (String path, ResourceLoaderType resourceType, Object resource)
 Resource finished loading successfully.
void forEachProperty (Block ablock)
 Visit properties with block with parameter ElementClass.
String getBasePath ()
 Base path for relative loading of resource properties.
CodecPropertyString getCodecPropertyString ()
 Property codec helper.
bool getIsXmlElementClass ()
 Element class is an XML element class.
bool getPersistable ()
 Element class is persistable to file writers.
int getPropertyCount ()
 Number of properties.
ElementClassProperty getPropertyNamed (String name)
 Named property or null if absent.
Array getPropertyNames ()
 List of property names as array of strings.
TSTriggerExpressionParser getTriggerExpressionParser ()
 Trigger expression parser.
int hashCode ()
 Hash code.
bool hasPropertyNamed (String name)
 Named property is present.
Object injectProperty (Object injectValue, Block ablock)
 Process value visiting properties.
void loadAndAddElement (PersistencyEnvironment env, StubElement stub, FileReader reader, GameWorld gameWorld)
 Load element from file reader and add it to game world.
Element loadElement (PersistencyEnvironment env, StubElement stub, FileReader reader)
 Load element from file reader.
ElementClass new (String className)
 Create element class.
void removeAllProperties ()
 Remove all properties.
void removeProperty (ElementClassProperty property)
 Remove property.
void setBasePath (String path)
 Set base path for relative loading of resource properties.
void setIsXmlElementClass (bool isXmlElementClass)
 Set if element class is an XML element class.
void setPersistable (bool persistable)
 Set element class is persistable to file writers.
void setPropertyValue (String name, Object value)
 Set value of named property.
Public Member Functions inherited from Dragengine.ResourceListener

Static Public Member Functions

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

Protected Member Functions

Element createElement ()
 Create element instance.

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

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

References forEachProperty(), removeAllProperties(), and removeProperty().

Referenced by finishedLoading().

◆ 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.BehaviorElementClass, Dragengine.Scenery.IgnoreElementClass, Dragengine.Scenery.RailCornerClass, and Dragengine.Scenery.SpawnPointClass.

References getPersistable(), and setPropertyValue().

Referenced by failedLoading().

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

References injectProperty().

Referenced by failedLoading().

◆ 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.IgnoreElementClass, and Dragengine.Scenery.RandomElementClass.

◆ 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.Gui.MainMenus.Interactive.IMMCameraSpotClass, Dragengine.Gui.MainMenus.Interactive.IMMEnvironmentMapClass, Dragengine.Gui.MainMenus.Interactive.IMMHotSpotClass, Dragengine.Gui.MainMenus.Interactive.IMMLightClass, Dragengine.Gui.MainMenus.Interactive.IMMParticleEmitterClass, Dragengine.Gui.MainMenus.Interactive.IMMPropClass, Dragengine.Gui.MainMenus.Interactive.IMMSpeakerClass, Dragengine.Scenery.AnimatedElementClass, Dragengine.Scenery.AttachableBaseBillboardClass, Dragengine.Scenery.AttachableBaseForceFieldClass, Dragengine.Scenery.AttachableBaseLightClass, Dragengine.Scenery.AttachableBaseParticleEmitterClass, Dragengine.Scenery.AttachableBaseSpeakerClass, Dragengine.Scenery.AttachSlotClass, Dragengine.Scenery.BaseActorClass, Dragengine.Scenery.BaseBillboardClass, Dragengine.Scenery.BaseForceFieldClass, Dragengine.Scenery.BaseLightClass, Dragengine.Scenery.BaseParticleEmitterClass, Dragengine.Scenery.BaseSkyClass, Dragengine.Scenery.BaseSpeakerClass, Dragengine.Scenery.BaseWorldClass, Dragengine.Scenery.EnvironmentMapClass, Dragengine.Scenery.GenericBehaviorElementClass, Dragengine.Scenery.GhostElementClass, Dragengine.Scenery.HiddenElementClass, Dragengine.Scenery.IgnoreElementClass, Dragengine.Scenery.InfoConvoCoordSystemClass, Dragengine.Scenery.PhysicsElementClass, Dragengine.Scenery.RandomElementClass, Dragengine.Scenery.SimpleElementClass, Dragengine.Scenery.SimpleElementOnRailClass, Dragengine.Scenery.TriggerConversationClass, Dragengine.Scenery.TriggerEvaluateClass, Dragengine.Scenery.TriggerShoutClass, Dragengine.Scenery.TriggerTimerClass, Dragengine.Scenery.TriggerToggleClass, Dragengine.Scenery.TriggerTouchClass, and Dragengine.Scenery.TwoStateAnimatedElementClass.

References addProperty(), hasPropertyNamed(), and new().

Referenced by loadAndAddElement().

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

Referenced by failedLoading().

◆ failedLoading()

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

◆ finishedLoading()

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

Resource finished loading successfully.

Implements Dragengine.ResourceListener.

References copyPropertyValues().

Referenced by failedLoading().

◆ forEachProperty()

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

Visit properties with block with parameter ElementClass.

References getCodecPropertyString(), and getSharedTriggerExpressionParser().

Referenced by copyPropertyValues().

◆ getBasePath()

String Dragengine.Scenery.ElementClass.getBasePath ( )

Base path for relative loading of resource properties.

References new().

Referenced by setSharedCodecPropertyString().

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

Referenced by forEachProperty(), and Dragengine.Scenery.RandomElementClass.loadAndAddElement().

◆ getIsXmlElementClass()

bool Dragengine.Scenery.ElementClass.getIsXmlElementClass ( )

Element class is an XML element class.

Version
1.17

Referenced by setSharedTriggerExpressionParser().

◆ getPersistable()

bool Dragengine.Scenery.ElementClass.getPersistable ( )

Element class is persistable to file writers.

References getPropertyCount().

Referenced by createAndAddElement(), and Dragengine.Scenery.RandomElementClass.loadAndAddElement().

◆ getPropertyCount()

int Dragengine.Scenery.ElementClass.getPropertyCount ( )

Number of properties.

Referenced by getPersistable().

◆ getPropertyNamed()

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

Named property or null if absent.

Referenced by setPersistable().

◆ getPropertyNames()

Array Dragengine.Scenery.ElementClass.getPropertyNames ( )

List of property names as array of strings.

References getSharedCodecPropertyString().

Referenced by setPersistable().

◆ getSharedCodecPropertyString()

CodecPropertyString Dragengine.Scenery.ElementClass.getSharedCodecPropertyString ( )
static

Shared property codec helper.

Referenced by getPropertyNames().

◆ getSharedTriggerExpressionParser()

TSTriggerExpressionParser Dragengine.Scenery.ElementClass.getSharedTriggerExpressionParser ( )
static

Shared trigger expression parser.

Referenced by forEachProperty().

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

References setIsXmlElementClass().

Referenced by injectProperty().

◆ hashCode()

int Dragengine.Scenery.ElementClass.hashCode ( )

Hash code.

Referenced by failedLoading().

◆ hasPropertyNamed()

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

Named property is present.

References new(), and setSharedCodecPropertyString().

Referenced by duplicateNamed().

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

References getTriggerExpressionParser(), new(), and setSharedTriggerExpressionParser().

Referenced by createElement().

◆ 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.IgnoreElementClass, and Dragengine.Scenery.RandomElementClass.

References duplicateNamed().

Referenced by Dragengine.Scenery.BehaviorElementClass.createAndAddElement(), and failedLoading().

◆ 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.IgnoreElementClass, and Dragengine.Scenery.RandomElementClass.

References setPersistable().

Referenced by failedLoading().

◆ new()

◆ removeAllProperties()

void Dragengine.Scenery.ElementClass.removeAllProperties ( )

Remove all properties.

Referenced by copyPropertyValues().

◆ removeProperty()

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

Remove property.

Referenced by copyPropertyValues().

◆ setBasePath()

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

Set base path for relative loading of resource properties.

References dispose().

Referenced by setSharedCodecPropertyString().

◆ setIsXmlElementClass()

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

Set if element class is an XML element class.

Version
1.17

Referenced by getTriggerExpressionParser().

◆ setPersistable()

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

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

Referenced by createAndAddElement().

◆ setSharedCodecPropertyString()

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

Set shared property codec helper.

References getBasePath(), new(), and setBasePath().

Referenced by hasPropertyNamed().

◆ setSharedTriggerExpressionParser()

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

Set shared trigger expression parser.

References getIsXmlElementClass().

Referenced by injectProperty().


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