Drag[en]gine Script Module DragonScript  1.23
Dragengine.Scenery.RandomElementClass Class Reference

Use random element class from a list of element classes. More...

Inheritance diagram for Dragengine.Scenery.RandomElementClass:
Dragengine.Scenery.ElementClass Dragengine.ResourceListener

Public Member Functions

Element createElement (StubElement stub)
 Create element instance from stub. More...
 
void dispose ()
 Dispose of element class. More...
 
ElementClass duplicateNamed (String classname)
 Create named element class based on this class. More...
 
ECPElementClassList getElementClasses ()
 Element class list to choose from. More...
 
ECPFloat getGenerateChance ()
 Chance for element to be generated at all. More...
 
ECPVector getMaxRandomRotation ()
 Maximum random rotation. More...
 
ECPFloat getMaxRandomScale ()
 Maximum random scaling. More...
 
ECPVector getMinRandomRotation ()
 Minimum random rotation. More...
 
ECPFloat getMinRandomScale ()
 Minimum random scaling. More...
 
ECPBoolean getRandomRotScale ()
 Randomize rotation and scaling. 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...
 
RandomElementClass new (ElementClassList eclassList)
 Create element class. More...
 
RandomElementClass new (String className, ElementClassList eclassList)
 Create element class. More...
 
- Public Member Functions inherited from Dragengine.Scenery.ElementClass
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...
 
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...
 
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

Protected Member Functions

Element createElement ()
 Create element instance. More...
 
void modifyStub (StubElement stub)
 Modify stub for creating element. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Dragengine.Scenery.ElementClass
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...
 

Detailed Description

Use random element class from a list of element classes.

Add element classes to choose from to "elementClasses" element class property. The first time the world is created this element picks randomly one element class from this list and create it in place of this element class.

This class supports only persistable element classes. If you try to use a non-persistable element class an exception will be thrown. This is requied since the random state can only be saved if the created element is persisted. If not persisted the element would simply vanish during loading.

This class supports these sub properties (all removed before creating chosen element):

  • elementClasses: List of element classes replacing the list stored in the element class itself. Of the form "className1 className2 ... classNameN"
  • generateChance: Chance to generate the element at all. Floating point value in the range from 0 to 1. A value of 1 equals 100% chance to generate the element.

Member Function Documentation

◆ createElement() [1/2]

Element Dragengine.Scenery.RandomElementClass.createElement ( )
protected

Create element instance.

This method should never be called.

Reimplemented from Dragengine.Scenery.ElementClass.

◆ createElement() [2/2]

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

Create element instance from stub.

Picks at random a class from the list of element classes and uses it to create the element as if this class had been originally used instead.

Alters the stub element class to match the element class chosen by createElement().

Generate chance is used (either through class property or stub property) to randomly skip generating an element at all.

Reimplemented from Dragengine.Scenery.ElementClass.

◆ dispose()

void Dragengine.Scenery.RandomElementClass.dispose ( )

Dispose of element class.

Reimplemented from Dragengine.Scenery.ElementClass.

◆ duplicateNamed()

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

Create named element class based on this class.

Reimplemented from Dragengine.Scenery.ElementClass.

◆ getElementClasses()

ECPElementClassList Dragengine.Scenery.RandomElementClass.getElementClasses ( )

Element class list to choose from.

◆ getGenerateChance()

ECPFloat Dragengine.Scenery.RandomElementClass.getGenerateChance ( )

Chance for element to be generated at all.

◆ getMaxRandomRotation()

ECPVector Dragengine.Scenery.RandomElementClass.getMaxRandomRotation ( )

Maximum random rotation.

◆ getMaxRandomScale()

ECPFloat Dragengine.Scenery.RandomElementClass.getMaxRandomScale ( )

Maximum random scaling.

◆ getMinRandomRotation()

ECPVector Dragengine.Scenery.RandomElementClass.getMinRandomRotation ( )

Minimum random rotation.

◆ getMinRandomScale()

ECPFloat Dragengine.Scenery.RandomElementClass.getMinRandomScale ( )

Minimum random scaling.

◆ getRandomRotScale()

ECPBoolean Dragengine.Scenery.RandomElementClass.getRandomRotScale ( )

Randomize rotation and scaling.

◆ loadAndAddElement()

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

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

This method should never be called or something went wrong. Throws EInvalidParam.

Reimplemented from Dragengine.Scenery.ElementClass.

◆ loadElement()

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

Load element from file reader.

This method should never be called or something went wrong. Throws EInvalidParam.

Reimplemented from Dragengine.Scenery.ElementClass.

◆ modifyStub()

void Dragengine.Scenery.RandomElementClass.modifyStub ( StubElement  stub)
protected

Modify stub for creating element.

Called if element class is found and element is about to be created. Default implementation applies random rotation and scaling if enabled. Subclass can add further random modifications if desired.

◆ new() [1/2]

RandomElementClass Dragengine.Scenery.RandomElementClass.new ( ElementClassList  eclassList)

Create element class.

◆ new() [2/2]

RandomElementClass Dragengine.Scenery.RandomElementClass.new ( String  className,
ElementClassList  eclassList 
)

Create element class.


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