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

Game world. More...

Inheritance diagram for GameWorld:

Public Member Functions

void addElement (Element element)
 Add Element. More...
 
void addEnterFrameOnce (Element element)
 Call Element.enterFrame() on element once at start of next frame update. More...
 
void addOneShotSpeaker (Speaker speaker)
 Add one shot speaker. More...
 
void debugPrintStats (Utils.Console console, String identifyInLogs)
 
void dispose ()
 Dispose of game world. More...
 
void enterFrame ()
 Call Element.enterFrame() on registered elements then unregister all elements. More...
 
void forEachElement (Block ablock)
 Visit elements with block with parameter Element. More...
 
CachedVegetation getCachedVegetation ()
 Cached vegetation. More...
 
UniqueID getNextObjectID ()
 Next object ID from world file required for saving and remapping ID ranges. More...
 
TemporaryDecalManager getTemporaryDecalManager ()
 Temporary decal manager. More...
 
UniqueIDRemapper getUniqueIDRemapper ()
 Unique ID remapper. More...
 
World getWorld ()
 Engine world resource. More...
 
bool hasElement (Element element)
 Element is present. More...
 
GameWorld new ()
 Create game world. More...
 
void playSoundOnce (Sound sound, Element element, float volume, float range)
 Play sound once. More...
 
void playSoundOnce (Sound sound, DVector position, float volume, float range)
 Play sound once. More...
 
void playSoundOnce (Sound sound, DVector position, Quaternion orientation, float volume, float range)
 Play sound once. More...
 
void playSynthesizerOnce (SynthesizerInstance synthesizer, Element element, float volume, float range)
 Play synthesizer instance once. More...
 
void playSynthesizerOnce (SynthesizerInstance synthesizer, DVector position, float volume, float range)
 Play synthesizer instance once. More...
 
void playSynthesizerOnce (SynthesizerInstance synthesizer, DVector position, Quaternion orientation, float volume, float range)
 Play synthesizer instance once. More...
 
void postThink (float elapsed)
 Make elements think after physics simulation. More...
 
void processElements (ElementProcessor processor)
 Process elements. More...
 
void readFromFile (PersistencyEnvironment env, FileReader reader)
 Read from file. More...
 
void removeAllElements ()
 Remove all elements disposing of them. More...
 
void removeElement (Element element)
 Remove Element without disposing it. More...
 
void removeEnterFrameOnce (Element element)
 Stop call Element.enterFrame() on element once at start of next frame update. More...
 
void removeThinker (Element element)
 Remove element requiring thinking on frame updates. More...
 
void setCachedVegetation (CachedVegetation cachedVegetation)
 Set cached vegetation. More...
 
void setNextObjectID (UniqueID nextObjectID)
 Set next object ID from world file required for saving and remapping ID ranges. More...
 
void setTemporaryDecalManager (TemporaryDecalManager manager)
 Set temporary decal manager. More...
 
void setUniqueIDRemapper (UniqueIDRemapper remapper)
 Set Unique ID remapper. More...
 
void think (float elapsed)
 Make elements think. More...
 
void update (float elapsed)
 Update game world. More...
 
void visitElements (ElementVisitor visitor)
 Visit elements. More...
 
void writeDynamicElementDataToFile (PersistencyEnvironment env, FileWriter writer)
 Write dynamic element data to file. More...
 
void writeElementStubsToFile (PersistencyEnvironment env, FileWriter writer)
 Write elemen stubs to file. More...
 
void writeToFile (PersistencyEnvironment env, FileWriter writer)
 Write to file. More...
 

Detailed Description

Game world.

A single simulation unit in the game. Simple games require usually only one game world containing all elements of the currently loaded map or level. More complex games can use multiple game worlds for example to simulate development of the game world outside the currently visible section. Every game world wraps an engine world resource. Elements removed from the game world using removeElement are not disposed of. This allows to move elements between game worlds. Elements removed using removeAllElements though get disposed.

Member Function Documentation

◆ addElement()

void addElement ( Element  element)

Add Element.

◆ addEnterFrameOnce()

void addEnterFrameOnce ( Element  element)

Call Element.enterFrame() on element once at start of next frame update.

◆ addOneShotSpeaker()

void addOneShotSpeaker ( Speaker  speaker)

Add one shot speaker.

Plays a short sound once and will be deleted once finished playing.

◆ debugPrintStats()

void debugPrintStats ( Utils.Console  console,
String  identifyInLogs 
)

TEMPORARY

◆ dispose()

void dispose ( )

Dispose of game world.

Used to clear reference loops.

◆ enterFrame()

void enterFrame ( )

Call Element.enterFrame() on registered elements then unregister all elements.

Warning
Do not call addEnterFrameOnce or removeEnterFrameOnce from inside enterFrame().

◆ forEachElement()

void forEachElement ( Block  ablock)

Visit elements with block with parameter Element.

◆ getCachedVegetation()

CachedVegetation getCachedVegetation ( )

Cached vegetation.

◆ getNextObjectID()

UniqueID getNextObjectID ( )

Next object ID from world file required for saving and remapping ID ranges.

◆ getTemporaryDecalManager()

TemporaryDecalManager getTemporaryDecalManager ( )

Temporary decal manager.

◆ getUniqueIDRemapper()

UniqueIDRemapper getUniqueIDRemapper ( )

Unique ID remapper.

◆ getWorld()

World getWorld ( )

Engine world resource.

◆ hasElement()

bool hasElement ( Element  element)

Element is present.

◆ new()

GameWorld new ( )

Create game world.

◆ playSoundOnce() [1/3]

void playSoundOnce ( Sound  sound,
Element  element,
float  volume,
float  range 
)

Play sound once.

Creates a speaker with the sound and parameters playing it once. If sound it null nothing is done.

◆ playSoundOnce() [2/3]

void playSoundOnce ( Sound  sound,
DVector  position,
float  volume,
float  range 
)

Play sound once.

Creates a speaker with the sound and parameters playing it once. If sound it null nothing is done.

◆ playSoundOnce() [3/3]

void playSoundOnce ( Sound  sound,
DVector  position,
Quaternion  orientation,
float  volume,
float  range 
)

Play sound once.

Creates a speaker with the sound and parameters playing it once. If sound it null nothing is done.

◆ playSynthesizerOnce() [1/3]

void playSynthesizerOnce ( SynthesizerInstance  synthesizer,
Element  element,
float  volume,
float  range 
)

Play synthesizer instance once.

Creates speaker with synthesizer instance and parameters playing it once. If synthesizer is null nothing is done.

◆ playSynthesizerOnce() [2/3]

void playSynthesizerOnce ( SynthesizerInstance  synthesizer,
DVector  position,
float  volume,
float  range 
)

Play synthesizer instance once.

Creates speaker with synthesizer instance and parameters playing it once. If synthesizer is null nothing is done.

◆ playSynthesizerOnce() [3/3]

void playSynthesizerOnce ( SynthesizerInstance  synthesizer,
DVector  position,
Quaternion  orientation,
float  volume,
float  range 
)

Play synthesizer instance once.

Creates speaker with synthesizer instance and parameters playing it once. If synthesizer is null nothing is done.

◆ postThink()

void postThink ( float  elapsed)

Make elements think after physics simulation.

◆ processElements()

void processElements ( ElementProcessor  processor)

Process elements.

Deprecated:
Use findElement instead.

◆ readFromFile()

void readFromFile ( PersistencyEnvironment  env,
FileReader  reader 
)

Read from file.

◆ removeAllElements()

void removeAllElements ( )

Remove all elements disposing of them.

◆ removeElement()

void removeElement ( Element  element)

Remove Element without disposing it.

◆ removeEnterFrameOnce()

void removeEnterFrameOnce ( Element  element)

Stop call Element.enterFrame() on element once at start of next frame update.

◆ removeThinker()

void removeThinker ( Element  element)

Remove element requiring thinking on frame updates.

◆ setCachedVegetation()

void setCachedVegetation ( CachedVegetation  cachedVegetation)

Set cached vegetation.

◆ setNextObjectID()

void setNextObjectID ( UniqueID  nextObjectID)

Set next object ID from world file required for saving and remapping ID ranges.

◆ setTemporaryDecalManager()

void setTemporaryDecalManager ( TemporaryDecalManager  manager)

Set temporary decal manager.

◆ setUniqueIDRemapper()

void setUniqueIDRemapper ( UniqueIDRemapper  remapper)

Set Unique ID remapper.

◆ think()

void think ( float  elapsed)

Make elements think.

◆ update()

void update ( float  elapsed)

Update game world.

Call once at beginning of frame update cycle. Afterwards world can be rendered multiple times.

◆ visitElements()

void visitElements ( ElementVisitor  visitor)

Visit elements.

◆ writeDynamicElementDataToFile()

void writeDynamicElementDataToFile ( PersistencyEnvironment  env,
FileWriter  writer 
)

Write dynamic element data to file.

Ignores elements with element classes marked not persistable. For each element the Element.writeToFile() method is called to save dynamic parameters.

The two methods writeElementStubsToFile() and writeDynamicElementDataToFile() are both required to properly restore elements. They are not merged in one to allow preloading. For this to work element stubs have to be read first to start preloading. Once done the elements are created and their dynamic data read. The order of stubs has to stay the same for them to properly read their dynamic data.

◆ writeElementStubsToFile()

void writeElementStubsToFile ( PersistencyEnvironment  env,
FileWriter  writer 
)

Write elemen stubs to file.

Writes first the next object ID and Unique ID remapper. While loading the next object ID and mapper can be used to modify remapping in case the object ID range of the world changed in the mean time.

Ignores elements with element classes marked not persistable. For each element the element stub is written used to load or create the element.

Not persistable elements have to be loaded from a world file even if using a file reader.

The two methods writeElementStubsToFile() and writeDynamicElementDataToFile() are both required to properly restore elements. They are not merged in one to allow preloading. For this to work element stubs have to be read first to start preloading. Once done the elements are created and their dynamic data read. The order of stubs has to stay the same for them to properly read their dynamic data.

◆ writeToFile()

void writeToFile ( PersistencyEnvironment  env,
FileWriter  writer 
)

Write to file.


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