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

Game world. More...

Inheritance diagram for Dragengine.Scenery.GameWorld:

Public Member Functions

void addBehavior (GWBehavior behavior)
 Add behavior. More...
 
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)
 
void addThinker (Element element)
 Add element requiring thinking on frame updates. More...
 
Array collectBehaviors (Block ablock)
 Collect behaviors with block into Array. More...
 
Dictionary debugStatistics ()
 Collect debug statistics. More...
 
Dictionary debugStatisticsSummary ()
 Retrieves some summary statistics. More...
 
void dispose ()
 Dispose of game world. More...
 
GWBehavior findBehavior (Block ablock)
 Find behavior with block. More...
 
Element findElement (Block ablock)
 Find element with block with parameter Element. More...
 
void forEachBehavior (Block ablock)
 Visit behaviors with block. \versoin 1.17. More...
 
void forEachThinker (Block ablock)
 Visit thinkers with block with parameter Element. More...
 
AnchoredElementList getAnchoredElementList ()
 Anchored element list. More...
 
GWBehavior getBehaviorAt (int index)
 Behavior at index. More...
 
CachedVegetation getCachedVegetation ()
 Cached vegetation. More...
 
ConversationActorList getConvoActorList ()
 Conversation actor list. More...
 
ConversationCoordSystemList getConvoCoordSystemList ()
 Conversation coordinate system list. More...
 
Element getElementWithID (UniqueID id)
 Element with identifier or null if absent. More...
 
bool getEnablePersistency ()
 Enable persistency (backward compatibility). More...
 
bool getEnableReadDynDataWithSize ()
 Enable reading dynamic element data from persistency with size. More...
 
Vector getGravity ()
 Gravity. More...
 
LayerMask getLayerMaskOneShotSpeaker ()
 
RailList getRailList ()
 Rail list. More...
 
SpawnPointList getSpawnPoints ()
 Spawn point list. More...
 
StubGameWorld getStub ()
 Stub used to create game world. More...
 
TemporaryDecalManager getTemporaryDecalManager ()
 Temporary decal manager. More...
 
void init (StubGameWorld stub)
 Init game world from stub. More...
 
GameWorld new ()
 Create game world. More...
 
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. More...
 
void removeAllOneShotSpeakers ()
 
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 removeFinishedOneShotSpeakers ()
 
void removeThinker (Element element)
 Remove element requiring thinking on frame updates. More...
 
void requiresThinkChanged ()
 Requires thinking changed. More...
 
void setCachedVegetation (CachedVegetation cachedVegetation)
 Set cached vegetation. More...
 
void setEnablePersistency (bool enable)
 
void setGravity (Vector gravity)
 Set gravity. More...
 
void setLayerMaskOneShotSpeaker (LayerMask layerMask)
 
void setStub (StubGameWorld stub)
 Set stub used to create game world. 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 visitElements (ElementVisitor visitor)
 Visit elements. More...
 

Public Attributes

AnchoredElementList pAnchoredElementList
 
GWBehaviorOneShotSpeaker pBehaviorOneShotSpeaker
 
Array pBehaviors
 
bool pBehaviorsInited
 
CachedVegetation pCachedVegetation
 
ConversationActorList pConvoActorList
 
ConversationCoordSystemList pConvoCoordSystemList
 
Dictionary pElementIDMap
 
SafeArray pElements
 
bool pEnablePersistency
 
bool pEnableReadDynDataWithSize
 
Array pEnterFrameOnce
 
Vector pGravity
 
bool pLockEnterFrameOnce
 
UniqueID pNextObjectID
 
RailList pRailList
 
SpawnPointList pSpawnPoints
 
StubGameWorld pStub
 
TemporaryDecalManager pTempDecalMgr
 
SafeArray pThinkers
 
Array pThinkingBehaviors
 
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)

Add behavior.

Version
1.17

This is called by constructors of class implementing GWBehavior. Usually you do not have to call this manually.

◆ addElement()

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

Add Element.

◆ addEnterFrameOnce()

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

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

◆ addOneShotSpeaker()

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

◆ addThinker()

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

Add element requiring thinking on frame updates.

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

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

◆ debugStatisticsSummary()

Dictionary Dragengine.Scenery.GameWorld.debugStatisticsSummary ( )

Retrieves some summary statistics.

Returns a dictionary with these values.

  • 'thinkers': Dictionary containing as keys the element class name of all thinkers with value occurance count.
  • 'enterFrameOnce': Dictionary containing as keys the element class name of all enter frame once with value occurance count.

◆ dispose()

void Dragengine.Scenery.GameWorld.dispose ( )

Dispose of game world.

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

◆ findElement()

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

Find element with block with parameter Element.

◆ forEachBehavior()

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

Visit behaviors with block. \versoin 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.

◆ forEachThinker()

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

Visit thinkers with block with parameter Element.

◆ getAnchoredElementList()

AnchoredElementList Dragengine.Scenery.GameWorld.getAnchoredElementList ( )

Anchored element list.

◆ getBehaviorAt()

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

Behavior at index.

Version
1.17

◆ getCachedVegetation()

CachedVegetation Dragengine.Scenery.GameWorld.getCachedVegetation ( )

Cached vegetation.

◆ getConvoActorList()

ConversationActorList Dragengine.Scenery.GameWorld.getConvoActorList ( )

Conversation actor list.

◆ getConvoCoordSystemList()

ConversationCoordSystemList Dragengine.Scenery.GameWorld.getConvoCoordSystemList ( )

Conversation coordinate system list.

◆ getElementWithID()

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

Element with identifier or null if absent.

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

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

◆ getGravity()

Vector Dragengine.Scenery.GameWorld.getGravity ( )

Gravity.

◆ getLayerMaskOneShotSpeaker()

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

◆ getRailList()

RailList Dragengine.Scenery.GameWorld.getRailList ( )

Rail list.

◆ getSpawnPoints()

SpawnPointList Dragengine.Scenery.GameWorld.getSpawnPoints ( )

Spawn point list.

◆ getStub()

StubGameWorld Dragengine.Scenery.GameWorld.getStub ( )

Stub used to create game world.

Version
1.17

◆ getTemporaryDecalManager()

TemporaryDecalManager Dragengine.Scenery.GameWorld.getTemporaryDecalManager ( )

Temporary decal manager.

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

◆ new()

GameWorld Dragengine.Scenery.GameWorld.new ( )

Create game world.

◆ playSoundOnce() [1/3]

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

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

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

◆ removeAllElements()

void Dragengine.Scenery.GameWorld.removeAllElements ( )

Remove all elements calling safeDispose() on them.

◆ removeAllOneShotSpeakers()

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

◆ removeElement()

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

Remove Element without disposing it.

◆ removeEnterFrameOnce()

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

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

◆ removeFinishedOneShotSpeakers()

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

◆ removeThinker()

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

Remove element requiring thinking on frame updates.

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

◆ setCachedVegetation()

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

Set cached vegetation.

◆ setEnablePersistency()

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

◆ setGravity()

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

Set gravity.

◆ setLayerMaskOneShotSpeaker()

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

◆ setStub()

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

Set stub used to create game world.

Version
1.17

◆ setTemporaryDecalManager()

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

Set temporary decal manager.

◆ setUniqueIDRemapper()

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

Set Unique ID remapper.

◆ think()

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

Make elements think.

◆ visitElements()

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

Visit elements.

Member Data Documentation

◆ pAnchoredElementList

AnchoredElementList Dragengine.Scenery.GameWorld.pAnchoredElementList

◆ pBehaviorOneShotSpeaker

GWBehaviorOneShotSpeaker Dragengine.Scenery.GameWorld.pBehaviorOneShotSpeaker

◆ pBehaviors

Array Dragengine.Scenery.GameWorld.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

◆ pEnableReadDynDataWithSize

bool Dragengine.Scenery.GameWorld.pEnableReadDynDataWithSize

◆ pEnterFrameOnce

Array Dragengine.Scenery.GameWorld.pEnterFrameOnce

◆ pGravity

Vector Dragengine.Scenery.GameWorld.pGravity

◆ pLockEnterFrameOnce

bool Dragengine.Scenery.GameWorld.pLockEnterFrameOnce

◆ pNextObjectID

UniqueID Dragengine.Scenery.GameWorld.pNextObjectID

◆ pRailList

RailList Dragengine.Scenery.GameWorld.pRailList

◆ pSpawnPoints

SpawnPointList Dragengine.Scenery.GameWorld.pSpawnPoints

◆ pStub

StubGameWorld Dragengine.Scenery.GameWorld.pStub

◆ pTempDecalMgr

TemporaryDecalManager Dragengine.Scenery.GameWorld.pTempDecalMgr

◆ pThinkers

SafeArray Dragengine.Scenery.GameWorld.pThinkers

◆ pThinkingBehaviors

Array Dragengine.Scenery.GameWorld.pThinkingBehaviors

◆ pUniqueIDRemapper

UniqueIDRemapper Dragengine.Scenery.GameWorld.pUniqueIDRemapper

◆ pWorld

World Dragengine.Scenery.GameWorld.pWorld

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