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

Element class. More...

Inheritance diagram for ElementClass:
ResourceNotifier BaseLightClass IGDEVirtualElementClass RandomElementClass SimpleElementClass SpawnPointClass TriggerShoutClass LightPointClass LightSpotClass

Public Member Functions

void addDependencies (PreloadManager preloadManager)
 
void addProperty (ElementClassProperty property)
 Add property. 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, int resourceType)
 Resource failed loading. More...
 
void finishedLoading (String path, int resourceType, Object resource)
 Resource finished loading successfully. More...
 
void forEachProperty (Block ablock)
 Visit properties with block with parameter ElementClass. More...
 
String getClassname ()
 Cclass name. More...
 
CodecPropertyString getCodecPropertyString ()
 Property codec helper. 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...
 
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 preloadResources ()
 Preload resources. More...
 
void setPersistable (bool persistable)
 Set element class is persistable to file writers. 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

◆ addDependencies()

void addDependencies ( PreloadManager  preloadManager)

Adds element classes this class depends on. Dependent classes usually are elements created alongside elements of this class or elements which can be produced during the lifetime of an element of this class.

◆ addProperty()

void addProperty ( ElementClassProperty  property)

Add property.

◆ createAndAddElement()

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

◆ createElement() [1/2]

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

◆ createElement() [2/2]

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

◆ dispose()

void dispose ( )

Dispose of element class.

◆ duplicateNamed()

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.

◆ equals()

bool equals ( Object  obj)

Element class is equal to another object.

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

◆ failedLoading()

void failedLoading ( String  path,
int  resourceType 
)

Resource failed loading.

Implements ResourceNotifier.

◆ finishedLoading()

void finishedLoading ( String  path,
int  resourceType,
Object  resource 
)

Resource finished loading successfully.

Implements ResourceNotifier.

◆ forEachProperty()

void forEachProperty ( Block  ablock)

Visit properties with block with parameter ElementClass.

◆ getClassname()

String getClassname ( )

Cclass name.

◆ getCodecPropertyString()

CodecPropertyString getCodecPropertyString ( )

Property codec helper.

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

◆ getPersistable()

bool getPersistable ( )

Element class is persistable to file writers.

◆ getPropertyCount()

int getPropertyCount ( )

Number of properties.

◆ getPropertyNamed()

ElementClassProperty getPropertyNamed ( String  name)

Named property or null if absent.

◆ getPropertyNames()

Array getPropertyNames ( )

List of property names as array of strings.

◆ getSharedCodecPropertyString()

static CodecPropertyString getSharedCodecPropertyString ( )
static

Shared property codec helper.

◆ getSharedTriggerExpressionParser()

static TSTriggerExpressionParser getSharedTriggerExpressionParser ( )
static

Shared trigger expression parser.

◆ getTriggerExpressionParser()

TSTriggerExpressionParser getTriggerExpressionParser ( )

Trigger expression parser.

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

◆ hashCode()

int hashCode ( )

Hash code.

◆ hasPropertyNamed()

bool hasPropertyNamed ( String  name)

Named property is present.

◆ loadAndAddElement()

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

◆ loadElement()

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

◆ new()

ElementClass new ( String  className)

Create element class.

◆ preloadResources()

void preloadResources ( )

Preload resources.

◆ setPersistable()

void setPersistable ( bool  persistable)

Set element class is persistable to file writers.

◆ setSharedCodecPropertyString()

static void setSharedCodecPropertyString ( CodecPropertyString  codec)
static

Set shared property codec helper.

◆ setSharedTriggerExpressionParser()

static void setSharedTriggerExpressionParser ( TSTriggerExpressionParser  parser)
static

Set shared trigger expression parser.


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