Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Scenery.GameWorld Class Reference

Game world. More...

Inheritance diagram for Dragengine.Scenery.GameWorld:

Public Member Functions

void addBehavior (GWBehavior behavior)
 Add behavior.
void addElement (Element element)
 Add Element.
void addEnterFrameOnce (Element element)
 Call Element.enterFrame() on element once at start of next frame update.
void addOneShotSpeaker (Speaker speaker)
void addThinker (Element element)
 Add element requiring thinking on frame updates.
Array collectBehaviors (Block ablock)
 Collect behaviors with block into Array.
Dictionary debugStatistics ()
 Collect debug statistics.
Dictionary debugStatisticsSummary ()
 Retrieves some summary statistics.
void dispose ()
 Dispose of game world.
GWBehavior findBehavior (Block ablock)
 Find behavior with block.
Element findElement (Block ablock)
 Find element with block with parameter Element.
void forEachBehavior (Block ablock)
 Visit behaviors with block.
void forEachThinker (Block ablock)
 Visit thinkers with block with parameter Element.
AnchoredElementList getAnchoredElementList ()
GWBehaviorAnchoredElements getBehaviorAnchoredElements ()
 Anchored elements behavior.
GWBehavior getBehaviorAt (int index)
 Behavior at index.
GWBehaviorBTSM getBehaviorBTSM ()
 Behavior tree and state machine support game world behavior.
GWBehaviorParameterTree getBehaviorParameterTree ()
 Parameter tree game world behavior.
CachedVegetation getCachedVegetation ()
 Cached vegetation.
ConversationActorList getConvoActorList ()
 Conversation actor list.
ConversationCoordSystemList getConvoCoordSystemList ()
 Conversation coordinate system list.
Element getElementWithID (UniqueID id)
 Element with identifier or null if absent.
bool getEnablePersistency ()
 Enable persistency (backward compatibility).
bool getEnableReadDynDataWithSize ()
 Enable reading dynamic element data from persistency with size.
Vector getGravity ()
 Gravity.
LayerMask getLayerMaskOneShotSpeaker ()
RailList getRailList ()
 Rail list.
SpawnPointList getSpawnPoints ()
 Spawn point list.
StubGameWorld getStub ()
 Stub used to create game world.
TemporaryDecalManager getTemporaryDecalManager ()
 Temporary decal manager.
float getTimeScale ()
 Time scale applied to elapsed time.
void init (StubGameWorld stub)
 Init game world from stub.
GameWorld new ()
 Create game world.
void playSoundOnce (Sound sound, DVector position, float volume, float range)
void playSoundOnce (Sound sound, DVector position, Quaternion orientation, float volume, float range)
void playSoundOnce (Sound sound, Element element, float volume, float range)
void playSynthesizerOnce (SynthesizerInstance synthesizer, DVector position, float volume, float range)
void playSynthesizerOnce (SynthesizerInstance synthesizer, DVector position, Quaternion orientation, float volume, float range)
void playSynthesizerOnce (SynthesizerInstance synthesizer, Element element, float volume, float range)
void removeAllElements ()
 Remove all elements calling safeDispose() on them.
void removeAllOneShotSpeakers ()
void removeElement (Element element)
 Remove Element without disposing it.
void removeEnterFrameOnce (Element element)
 Stop call Element.enterFrame() on element once at start of next frame update.
void removeFinishedOneShotSpeakers ()
void removeThinker (Element element)
 Remove element requiring thinking on frame updates.
void requiresThinkChanged ()
 Requires thinking changed.
void setCachedVegetation (CachedVegetation cachedVegetation)
 Set cached vegetation.
void setEnablePersistency (bool enable)
void setGravity (Vector gravity)
 Set gravity.
void setLayerMaskOneShotSpeaker (LayerMask layerMask)
void setStub (StubGameWorld stub)
 Set stub used to create game world.
void setTemporaryDecalManager (TemporaryDecalManager manager)
 Set temporary decal manager.
void setTimeScale (float scale)
 Set time scale applied to elapsed time.
void setUniqueIDRemapper (UniqueIDRemapper remapper)
 Set Unique ID remapper.
void think (float elapsed)
 Make elements think.
void visitElements (ElementVisitor visitor)
 Visit elements.

Public Attributes

GWBehaviorAnchoredElements pBehaviorAnchoredElements
GWBehaviorBTSM pBehaviorBTSM
GWBehaviorOneShotSpeaker pBehaviorOneShotSpeaker
GWBehaviorParameterTree pBehaviorParameterTree
Array pBehaviors
bool pBehaviorsInited
CachedVegetation pCachedVegetation
ConversationActorList pConvoActorList
ConversationCoordSystemList pConvoCoordSystemList
Dictionary pElementIDMap
SafeArray pElements
bool pEnablePersistency
Array pEnterFrameOnce
Vector pGravity
UniqueID pNextObjectID
RailList pRailList
SpawnPointList pSpawnPoints
StubGameWorld pStub
TemporaryDecalManager pTempDecalMgr
Array pThinkingBehaviors
float pTimeScale
UniqueIDRemapper pUniqueIDRemapper
World pWorld

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

◆ addBehavior()

void Dragengine.Scenery.GameWorld.addBehavior ( GWBehavior behavior)

◆ addElement()

void Dragengine.Scenery.GameWorld.addElement ( Element element)

Add Element.

References pBehaviors.

Referenced by getConvoActorList().

◆ addEnterFrameOnce()

void Dragengine.Scenery.GameWorld.addEnterFrameOnce ( Element element)

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

References pBehaviors.

Referenced by debugStatisticsSummary().

◆ addOneShotSpeaker()

void Dragengine.Scenery.GameWorld.addOneShotSpeaker ( Speaker speaker)
Deprecated
Use getBehaviorOneShotSpeaker().

Referenced by debugStatisticsSummary().

◆ addThinker()

void Dragengine.Scenery.GameWorld.addThinker ( Element element)

Add element requiring thinking on frame updates.

Referenced by debugStatisticsSummary().

◆ collectBehaviors()

Array Dragengine.Scenery.GameWorld.collectBehaviors ( Block ablock)

Collect behaviors with block into Array.

Version
1.17

Block is required to have one parameter GWBehavior or subclass thereof and returning true if the right behavior is found otherwise false. Block is called only for behaviors castable to block parameter type.

References pBehaviorAnchoredElements, pBehaviorBTSM, pBehaviorOneShotSpeaker, pBehaviorParameterTree, pBehaviors, and pThinkingBehaviors.

Referenced by setCachedVegetation().

◆ debugStatistics()

Dictionary Dragengine.Scenery.GameWorld.debugStatistics ( )

Collect debug statistics.

Returns a dictionary with these values:

  • 'elements': Number of elements.
  • 'thinkers': Number of thinking elements.
  • 'enterFrameOnce': Number of enter frame once elements.
  • 'oneShotSpeakers': Number of one shot speakers.
  • 'spawnPoints': Number of spawn points.
  • 'temporaryDecals': Number of temporary decals.
  • 'resources.camera': Number of camera resources.
  • 'resources.speaker': Number of speaker resources.
  • 'resources.microphone': Number of microphone resources.
  • 'resources.networkState': Number of network state resources.
  • 'resources.component': Number of component resources.
  • 'resources.light': Number of light resources.
  • 'resources.collider': Number of collider resources.
  • 'resources.lumimeter': Number of lumimeter resources.
  • 'resources.touchSensor': Number of touch sensor resources.
  • 'resources.propField': Number of prop field resources.
  • 'resources.forceField': Number of force field resources.
  • 'resources.particleEmitter': Number of particle emitter instance resources.
  • 'resources.debugDrawer': Number of debug drawer resources.
  • 'resources.navigationSpace': Number of navigation space resources.
  • 'resources.navigationBlocker': Number of navigation blocker resources.
  • 'resources.navigator': Number of navigator resources.
  • 'resources.envMapProbe': Number of environment map probe resources.

References pElementIDMap, and pEnterFrameOnce.

Referenced by debugStatisticsSummary().

◆ debugStatisticsSummary()

◆ dispose()

void Dragengine.Scenery.GameWorld.dispose ( )

Dispose of game world.

References pElementIDMap, pEnterFrameOnce, pSpawnPoints, pTempDecalMgr, and pUniqueIDRemapper.

Referenced by forEachBehavior().

◆ findBehavior()

GWBehavior Dragengine.Scenery.GameWorld.findBehavior ( Block ablock)

Find behavior with block.

Version
1.17

Block is required to have one parameter GWBehavior or subclass thereof and returning true if the right behavior is found otherwise false. Block is called only for behaviors castable to block parameter type.

References pBehaviors, and pElements.

Referenced by forEachThinker().

◆ findElement()

Element Dragengine.Scenery.GameWorld.findElement ( Block ablock)

Find element with block with parameter Element.

References forEachBehavior(), and pBehaviors.

Referenced by debugStatisticsSummary().

◆ forEachBehavior()

void Dragengine.Scenery.GameWorld.forEachBehavior ( Block ablock)

Visit behaviors with block.

Version
1.17

Block is required to have one parameter of type GWBehavior or subclass thereof. Block is called only for behaviors castable to block parameter type.

References dispose().

Referenced by findElement().

◆ forEachThinker()

void Dragengine.Scenery.GameWorld.forEachThinker ( Block ablock)

Visit thinkers with block with parameter Element.

References findBehavior().

Referenced by debugStatisticsSummary().

◆ getAnchoredElementList()

AnchoredElementList Dragengine.Scenery.GameWorld.getAnchoredElementList ( )

◆ getBehaviorAnchoredElements()

GWBehaviorAnchoredElements Dragengine.Scenery.GameWorld.getBehaviorAnchoredElements ( )

Anchored elements behavior.

Version
1.35

References pBehaviors, pStub, and pWorld.

Referenced by removeFinishedOneShotSpeakers().

◆ getBehaviorAt()

GWBehavior Dragengine.Scenery.GameWorld.getBehaviorAt ( int index)

Behavior at index.

Version
1.17

References pBehaviors, pConvoActorList, pConvoCoordSystemList, pGravity, pRailList, and pThinkingBehaviors.

Referenced by setEnablePersistency().

◆ getBehaviorBTSM()

GWBehaviorBTSM Dragengine.Scenery.GameWorld.getBehaviorBTSM ( )

Behavior tree and state machine support game world behavior.

Version
1.35

References pCachedVegetation, pConvoActorList, pConvoCoordSystemList, and pTempDecalMgr.

Referenced by playSoundOnce().

◆ getBehaviorParameterTree()

GWBehaviorParameterTree Dragengine.Scenery.GameWorld.getBehaviorParameterTree ( )

Parameter tree game world behavior.

Version
1.35

References pRailList, and pSpawnPoints.

Referenced by playSynthesizerOnce().

◆ getCachedVegetation()

CachedVegetation Dragengine.Scenery.GameWorld.getCachedVegetation ( )

Cached vegetation.

Referenced by debugStatisticsSummary().

◆ getConvoActorList()

ConversationActorList Dragengine.Scenery.GameWorld.getConvoActorList ( )

Conversation actor list.

References addElement().

Referenced by debugStatisticsSummary().

◆ getConvoCoordSystemList()

ConversationCoordSystemList Dragengine.Scenery.GameWorld.getConvoCoordSystemList ( )

Conversation coordinate system list.

Referenced by debugStatisticsSummary().

◆ getElementWithID()

Element Dragengine.Scenery.GameWorld.getElementWithID ( UniqueID id)

Element with identifier or null if absent.

Referenced by debugStatisticsSummary().

◆ getEnablePersistency()

bool Dragengine.Scenery.GameWorld.getEnablePersistency ( )

Enable persistency (backward compatibility).

Version
1.17

Since Drag[en]gine 1.17 GameWorld supports persistency to load and save game world behavior states. This is incompatible with old saves where GameWorld did not persist any data. To support loading and saving saves prior to 1.17 use this method.

  • While loading save states created prior to 1.17 set false
  • While loading save states created using 1.17 or later set to true
  • While saving converted save states supported 1.17 and later set to true
  • While saving save states not supporting 1.17 or later set to false

Hence to support loading old saves and saving new saves load with false and save with true.

By default enable persistency is set to true if the required version of the game project is set to 1.17 or newer and false otherwise. Hence projects require an earlier version will always operate with enable persistency set to false keeping them compatible while projects requiring 1.17 or newer enable persistency.

Referenced by setStub().

◆ getEnableReadDynDataWithSize()

bool Dragengine.Scenery.GameWorld.getEnableReadDynDataWithSize ( )

Enable reading dynamic element data from persistency with size.

Version
1.23

Returns true if readElementStubsFromFile() encountered version 1 or higher.

References addBehavior(), and pBehaviors.

Referenced by init().

◆ getGravity()

Vector Dragengine.Scenery.GameWorld.getGravity ( )

Gravity.

Referenced by debugStatisticsSummary().

◆ getLayerMaskOneShotSpeaker()

LayerMask Dragengine.Scenery.GameWorld.getLayerMaskOneShotSpeaker ( )
Deprecated
Use getBehaviorOneShotSpeaker().

Referenced by debugStatisticsSummary().

◆ getRailList()

RailList Dragengine.Scenery.GameWorld.getRailList ( )

Rail list.

Referenced by debugStatisticsSummary().

◆ getSpawnPoints()

SpawnPointList Dragengine.Scenery.GameWorld.getSpawnPoints ( )

Spawn point list.

Referenced by debugStatisticsSummary().

◆ getStub()

StubGameWorld Dragengine.Scenery.GameWorld.getStub ( )

Stub used to create game world.

Version
1.17

Referenced by debugStatisticsSummary().

◆ getTemporaryDecalManager()

TemporaryDecalManager Dragengine.Scenery.GameWorld.getTemporaryDecalManager ( )

Temporary decal manager.

References pElementIDMap.

Referenced by debugStatisticsSummary().

◆ getTimeScale()

float Dragengine.Scenery.GameWorld.getTimeScale ( )

Time scale applied to elapsed time.

Version
1.35

References pBehaviors, pThinkingBehaviors, and requiresThinkChanged().

Referenced by debugStatisticsSummary().

◆ init()

void Dragengine.Scenery.GameWorld.init ( StubGameWorld stub)

Init game world from stub.

Version
1.17

Subclass is required to super-call init() to init behaviors properly.

References getEnableReadDynDataWithSize().

Referenced by debugStatisticsSummary().

◆ new()

GameWorld Dragengine.Scenery.GameWorld.new ( )

Create game world.

References new(), pElements, pEnablePersistency, and pWorld.

Referenced by new().

◆ playSoundOnce() [1/3]

void Dragengine.Scenery.GameWorld.playSoundOnce ( Sound sound,
DVector position,
float volume,
float range )
Deprecated
Use getBehaviorOneShotSpeaker().

References pBehaviorBTSM.

◆ playSoundOnce() [2/3]

void Dragengine.Scenery.GameWorld.playSoundOnce ( Sound sound,
DVector position,
Quaternion orientation,
float volume,
float range )
Deprecated
Use getBehaviorOneShotSpeaker().

◆ playSoundOnce() [3/3]

void Dragengine.Scenery.GameWorld.playSoundOnce ( Sound sound,
Element element,
float volume,
float range )
Deprecated
Use getBehaviorOneShotSpeaker().

References getBehaviorBTSM().

Referenced by debugStatisticsSummary().

◆ playSynthesizerOnce() [1/3]

void Dragengine.Scenery.GameWorld.playSynthesizerOnce ( SynthesizerInstance synthesizer,
DVector position,
float volume,
float range )
Deprecated
Use getBehaviorOneShotSpeaker().

◆ playSynthesizerOnce() [2/3]

void Dragengine.Scenery.GameWorld.playSynthesizerOnce ( SynthesizerInstance synthesizer,
DVector position,
Quaternion orientation,
float volume,
float range )
Deprecated
Use getBehaviorOneShotSpeaker().

◆ playSynthesizerOnce() [3/3]

void Dragengine.Scenery.GameWorld.playSynthesizerOnce ( SynthesizerInstance synthesizer,
Element element,
float volume,
float range )
Deprecated
Use getBehaviorOneShotSpeaker().

References getBehaviorParameterTree(), and pBehaviorParameterTree.

Referenced by debugStatisticsSummary().

◆ removeAllElements()

void Dragengine.Scenery.GameWorld.removeAllElements ( )

Remove all elements calling safeDispose() on them.

References pBehaviorsInited, and pStub.

Referenced by debugStatisticsSummary().

◆ removeAllOneShotSpeakers()

void Dragengine.Scenery.GameWorld.removeAllOneShotSpeakers ( )
Deprecated
Use getBehaviorOneShotSpeaker().

Referenced by debugStatisticsSummary().

◆ removeElement()

void Dragengine.Scenery.GameWorld.removeElement ( Element element)

Remove Element without disposing it.

References pThinkingBehaviors.

Referenced by setTemporaryDecalManager().

◆ removeEnterFrameOnce()

void Dragengine.Scenery.GameWorld.removeEnterFrameOnce ( Element element)

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

Referenced by debugStatisticsSummary().

◆ removeFinishedOneShotSpeakers()

void Dragengine.Scenery.GameWorld.removeFinishedOneShotSpeakers ( )
Deprecated
Use getBehaviorOneShotSpeaker().

References getBehaviorAnchoredElements(), and pBehaviorAnchoredElements.

Referenced by debugStatisticsSummary().

◆ removeThinker()

void Dragengine.Scenery.GameWorld.removeThinker ( Element element)

Remove element requiring thinking on frame updates.

Referenced by debugStatisticsSummary().

◆ requiresThinkChanged()

void Dragengine.Scenery.GameWorld.requiresThinkChanged ( )

Requires thinking changed.

Version
1.17

Called by GWBehavior if their requirement for thinking changed. This means requiresThink() implementations return different values than last time they have been checked. Game world will check all behaviors for their thinking requirements changes. Using this method helps to reduce script processing load by not making calling update(), think() and postThink() on behaviors not requiring it.

References pCachedVegetation, pElementIDMap, and pEnterFrameOnce.

Referenced by getTimeScale().

◆ setCachedVegetation()

void Dragengine.Scenery.GameWorld.setCachedVegetation ( CachedVegetation cachedVegetation)

Set cached vegetation.

References collectBehaviors(), and pBehaviors.

Referenced by debugStatisticsSummary().

◆ setEnablePersistency()

void Dragengine.Scenery.GameWorld.setEnablePersistency ( bool enable)

References getBehaviorAt(), and pBehaviors.

Referenced by setStub().

◆ setGravity()

void Dragengine.Scenery.GameWorld.setGravity ( Vector gravity)

Set gravity.

Referenced by debugStatisticsSummary().

◆ setLayerMaskOneShotSpeaker()

void Dragengine.Scenery.GameWorld.setLayerMaskOneShotSpeaker ( LayerMask layerMask)
Deprecated
Use getBehaviorOneShotSpeaker().

References pBehaviorOneShotSpeaker.

Referenced by debugStatisticsSummary().

◆ setStub()

void Dragengine.Scenery.GameWorld.setStub ( StubGameWorld stub)

Set stub used to create game world.

Version
1.17

References getEnablePersistency(), pEnablePersistency, and setEnablePersistency().

Referenced by debugStatisticsSummary().

◆ setTemporaryDecalManager()

void Dragengine.Scenery.GameWorld.setTemporaryDecalManager ( TemporaryDecalManager manager)

Set temporary decal manager.

References pElements, and removeElement().

Referenced by debugStatisticsSummary().

◆ setTimeScale()

void Dragengine.Scenery.GameWorld.setTimeScale ( float scale)

Set time scale applied to elapsed time.

Version
1.35

Referenced by debugStatisticsSummary().

◆ setUniqueIDRemapper()

void Dragengine.Scenery.GameWorld.setUniqueIDRemapper ( UniqueIDRemapper remapper)

Set Unique ID remapper.

Referenced by debugStatisticsSummary().

◆ think()

void Dragengine.Scenery.GameWorld.think ( float elapsed)

Make elements think.

Referenced by debugStatisticsSummary().

◆ visitElements()

void Dragengine.Scenery.GameWorld.visitElements ( ElementVisitor visitor)

Visit elements.

Referenced by debugStatisticsSummary().

Member Data Documentation

◆ pBehaviorAnchoredElements

GWBehaviorAnchoredElements Dragengine.Scenery.GameWorld.pBehaviorAnchoredElements

◆ pBehaviorBTSM

GWBehaviorBTSM Dragengine.Scenery.GameWorld.pBehaviorBTSM

◆ pBehaviorOneShotSpeaker

GWBehaviorOneShotSpeaker Dragengine.Scenery.GameWorld.pBehaviorOneShotSpeaker

◆ pBehaviorParameterTree

GWBehaviorParameterTree Dragengine.Scenery.GameWorld.pBehaviorParameterTree

◆ pBehaviors

◆ pBehaviorsInited

bool Dragengine.Scenery.GameWorld.pBehaviorsInited

◆ pCachedVegetation

CachedVegetation Dragengine.Scenery.GameWorld.pCachedVegetation

◆ pConvoActorList

ConversationActorList Dragengine.Scenery.GameWorld.pConvoActorList

◆ pConvoCoordSystemList

ConversationCoordSystemList Dragengine.Scenery.GameWorld.pConvoCoordSystemList

◆ pElementIDMap

Dictionary Dragengine.Scenery.GameWorld.pElementIDMap

◆ pElements

SafeArray Dragengine.Scenery.GameWorld.pElements

◆ pEnablePersistency

bool Dragengine.Scenery.GameWorld.pEnablePersistency

◆ pEnterFrameOnce

Array Dragengine.Scenery.GameWorld.pEnterFrameOnce

◆ pGravity

Vector Dragengine.Scenery.GameWorld.pGravity

◆ pNextObjectID

UniqueID Dragengine.Scenery.GameWorld.pNextObjectID

Referenced by debugStatisticsSummary().

◆ pRailList

RailList Dragengine.Scenery.GameWorld.pRailList

◆ pSpawnPoints

SpawnPointList Dragengine.Scenery.GameWorld.pSpawnPoints

◆ pStub

StubGameWorld Dragengine.Scenery.GameWorld.pStub

◆ pTempDecalMgr

TemporaryDecalManager Dragengine.Scenery.GameWorld.pTempDecalMgr

◆ pThinkingBehaviors

Array Dragengine.Scenery.GameWorld.pThinkingBehaviors

◆ pTimeScale

float Dragengine.Scenery.GameWorld.pTimeScale

◆ pUniqueIDRemapper

UniqueIDRemapper Dragengine.Scenery.GameWorld.pUniqueIDRemapper

Referenced by debugStatisticsSummary(), and dispose().

◆ pWorld

World Dragengine.Scenery.GameWorld.pWorld

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