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

Behavior element behavior adding speaker support. More...

Inheritance diagram for Dragengine.Scenery.ECBehaviorSpeaker:
Dragengine.Scenery.DefaultECBehavior Dragengine.Scenery.ECBehavior Dragengine.Scenery.BehaviorCompatiblePersistency

Classes

class  BlockListenerFactory
 Factory creating listeners using block. More...
 
class  DefaultListener
 Default implementation of behavior instance listener. More...
 
class  Instance
 Behavior instance. More...
 
interface  Listener
 Listener for behavior instance events. More...
 
interface  ListenerFactory
 Factory creating listeners. More...
 

Public Member Functions

void addListenerFactory (Block blockFactory)
 Add listener factory using block. More...
 
void addListenerFactory (ListenerFactory factory)
 Add listener factory. More...
 
void createListeners (Instance instance)
 Create listeners from factories adding them to behavior instance. More...
 
void dispose ()
 Dispose of behavior. More...
 
void forEachListenerFactory (Block ablock)
 Visit listener factories with block with argument ListenerFactory. More...
 
ECComposeAttachResource getAttach ()
 Attach resource. More...
 
ECBehaviorCollider getCollider ()
 Collider behavior or null to not attach. More...
 
ECComposeSpeaker getSpeaker ()
 Composeable speaker for element class. More...
 
ECBehaviorSpeaker getSyncTrigger ()
 ECBehaviorSpeaker to synchronize triggers with or null to disable. More...
 
ECBehaviorTriggered getTrigger ()
 Trigger playing. More...
 
ECBehaviorTriggered getTriggerMuted ()
 Trigger muted. More...
 
TSTriggerTable getTriggerTable ()
 Trigger table or null if not used. More...
 
Instance instance (BehaviorElement element)
 Get instance in element from owner element class. More...
 
ECBehaviorSpeaker new (BehaviorElementClass eclass, ECBehaviorCollider collider)
 Create behavior element class. More...
 
ECBehaviorSpeaker new (BehaviorElementClass eclass, ECBehaviorCollider collider, Loaders loaders, TSTriggerTable triggerTable)
 Create behavior element class. More...
 
ECBehaviorSpeaker new (BehaviorElementClass eclass, ECBehaviorCollider collider, Loaders loaders, TSTriggerTable triggerTable, String id)
 Create behavior element class. More...
 
ECBehaviorSpeaker new (BehaviorElementClass eclass, ECBehaviorCollider collider, Loaders loaders, TSTriggerTable triggerTable, String id, String subID)
 
ECBehaviorSpeaker new (BehaviorElementClass eclass, ECBehaviorCollider collider, Loaders loaders, TSTriggerTable triggerTable, String id, String subID, String prefix)
 
ECBehaviorSpeaker new (BehaviorElementClass eclass, ECBehaviorCollider collider, String id)
 Create behavior element class. More...
 
void set (String sound, float range, float volume, Vector position)
 
void set (String sound, float range, float volume, Vector position, Vector orientation)
 
void set (String sound, float range, float volume, Vector position, Vector orientation, String bone)
 
void setSyncTrigger (ECBehaviorSpeaker behavior)
 Set ECBehaviorSpeaker to synchronize triggers with or null to disable. More...
 
- Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
void assignInstanceIndex (int instanceIndex)
 Assign instance index. More...
 
String getBehaviorID ()
 Unique identifier of behavior. More...
 
String getID ()
 Identifier. More...
 
int getInstanceIndex ()
 Instance index. More...
 
void loadSupportedData (String identifier, PersistencyEnvironment env, FileReader reader, ECBehaviorInstance instance)
 Load instance data of another behavior. More...
 
bool supportsBehaviorID (String identifier)
 Behavior supports loading instance data of another behavior. More...
 
- Public Member Functions inherited from Dragengine.Scenery.ECBehavior
ECBehaviorInstance createInstance (BehaviorElement element)
 Create Behavior instance. More...
 

Static Public Member Functions

static ECBehaviorSpeaker getBehaviorIn (BehaviorElementClass eclass)
 Get behavior in element class or null if absent. More...
 

Protected Member Functions

void setTriggerTable (Loaders loaders, TSTriggerTable triggerTable)
 Set trigger table or null if not used. More...
 
- Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
DefaultECBehavior new (BehaviorElementClass eclass)
 Create default composeable behavior with empty identifier. More...
 
DefaultECBehavior new (BehaviorElementClass eclass, String id)
 Create default composeable behavior. More...
 
void setBehaviorID (String identifier)
 Set behavior identifier. More...
 
void useClassNameAsBehaviorID ()
 Set behavior identifier to "<class-name>:<identifier>". More...
 
void useFullyQualifiedClassNameAsBehaviorID ()
 Set behavior identifier to "<fully-qualified-class-name>:<identifier>". More...
 

Detailed Description

Behavior element behavior adding speaker support.

Behavior adds a Speaker resource to the the behavior element. This behavior can be added multiple times to an element. Each instance creates one speaker attached to the element collider which can be individually modified. To distinguish the speakers each instance has an identifier which can be used to retrieve a specific instance. Hence to use more than one speaker use code like this in your subclass constructor:

class MyElement extends BehaviorElementClass
public func new()
ECBehaviorSpeaker.new(this)
ECBehaviorSpeaker.new(this, "subSpeaker")
end
end
ECBehaviorSpeaker new(BehaviorElementClass eclass, ECBehaviorCollider collider)
Create behavior element class.

You can now define the parameters to use for both speakers using for example the properties "speaker.volume" for the first speaker and "speaker(subSpeaker).volume" for the second speaker.

It is recommended to always specify an identifier even if only one speaker is used. This avoids potentially name conflicts especially if other behaviors are added attaching other resources too.

If the ECBehaviorCollider behavior is present in the behavior element before this behavior is added the speaker is attached. The speaker is attached to the named bone if defined otherwise it is attached statically.

Element class properties have the prefix "speaker{(id)}.".

This behavior does require the element class to be persistable (setPersistable).

Synthesizer Handling

Speakers can play either a static Sound resource or use a Synthesizer. By using a synthesizer dynamic sound can be played. To use a synthesizer use the "speaker{(id)}.synthesizer" property instead of the "speaker{(id)}.sound" property. If both properties are present the synthesizer one is used if valid otherwise sound.

If synthesizer is valid a SynthesizerInstance will be created. Subclasses of ECBehaviorSpeaker or other behaviors can then obtain SynthesizerController from the SynthesizerInstance to modify the played sound. Since controllers use curves behaviors have to set the value ahead of time before playing back the speaker. It is possible to change the controller curves while sound is playing. In this case though care has to be taken to be set the curve early enough since audio modules typically render sound into buffered blocks. If the curve is changed too late the changes can be missed or result in strange sound jumping.

Member Function Documentation

◆ addListenerFactory() [1/2]

void Dragengine.Scenery.ECBehaviorSpeaker.addListenerFactory ( Block  blockFactory)

Add listener factory using block.

Block receives as parameter Instance and returns Listener.

◆ addListenerFactory() [2/2]

void Dragengine.Scenery.ECBehaviorSpeaker.addListenerFactory ( ListenerFactory  factory)

Add listener factory.

◆ createListeners()

void Dragengine.Scenery.ECBehaviorSpeaker.createListeners ( Instance  instance)

Create listeners from factories adding them to behavior instance.

◆ dispose()

void Dragengine.Scenery.ECBehaviorSpeaker.dispose ( )

Dispose of behavior.

Reimplemented from Dragengine.Scenery.DefaultECBehavior.

◆ forEachListenerFactory()

void Dragengine.Scenery.ECBehaviorSpeaker.forEachListenerFactory ( Block  ablock)

Visit listener factories with block with argument ListenerFactory.

◆ getAttach()

ECComposeAttachResource Dragengine.Scenery.ECBehaviorSpeaker.getAttach ( )

Attach resource.

◆ getBehaviorIn()

static ECBehaviorSpeaker Dragengine.Scenery.ECBehaviorSpeaker.getBehaviorIn ( BehaviorElementClass  eclass)
static

Get behavior in element class or null if absent.

Use this method to check if a particular BehaviorElementClass contains a behavior of type ECBehaviorCollider.

◆ getCollider()

ECBehaviorCollider Dragengine.Scenery.ECBehaviorSpeaker.getCollider ( )

Collider behavior or null to not attach.

◆ getSpeaker()

ECComposeSpeaker Dragengine.Scenery.ECBehaviorSpeaker.getSpeaker ( )

Composeable speaker for element class.

◆ getSyncTrigger()

ECBehaviorSpeaker Dragengine.Scenery.ECBehaviorSpeaker.getSyncTrigger ( )

ECBehaviorSpeaker to synchronize triggers with or null to disable.

◆ getTrigger()

ECBehaviorTriggered Dragengine.Scenery.ECBehaviorSpeaker.getTrigger ( )

Trigger playing.

◆ getTriggerMuted()

ECBehaviorTriggered Dragengine.Scenery.ECBehaviorSpeaker.getTriggerMuted ( )

Trigger muted.

◆ getTriggerTable()

TSTriggerTable Dragengine.Scenery.ECBehaviorSpeaker.getTriggerTable ( )

Trigger table or null if not used.

◆ instance()

Instance Dragengine.Scenery.ECBehaviorSpeaker.instance ( BehaviorElement  element)

Get instance in element from owner element class.

◆ new() [1/6]

ECBehaviorSpeaker Dragengine.Scenery.ECBehaviorSpeaker.new ( BehaviorElementClass  eclass,
ECBehaviorCollider  collider 
)

Create behavior element class.

These value are optional and can be null: collider.

◆ new() [2/6]

ECBehaviorSpeaker Dragengine.Scenery.ECBehaviorSpeaker.new ( BehaviorElementClass  eclass,
ECBehaviorCollider  collider,
Loaders  loaders,
TSTriggerTable  triggerTable 
)

Create behavior element class.

◆ new() [3/6]

ECBehaviorSpeaker Dragengine.Scenery.ECBehaviorSpeaker.new ( BehaviorElementClass  eclass,
ECBehaviorCollider  collider,
Loaders  loaders,
TSTriggerTable  triggerTable,
String  id 
)

Create behavior element class.

◆ new() [4/6]

ECBehaviorSpeaker Dragengine.Scenery.ECBehaviorSpeaker.new ( BehaviorElementClass  eclass,
ECBehaviorCollider  collider,
Loaders  loaders,
TSTriggerTable  triggerTable,
String  id,
String  subID 
)

◆ new() [5/6]

ECBehaviorSpeaker Dragengine.Scenery.ECBehaviorSpeaker.new ( BehaviorElementClass  eclass,
ECBehaviorCollider  collider,
Loaders  loaders,
TSTriggerTable  triggerTable,
String  id,
String  subID,
String  prefix 
)

◆ new() [6/6]

ECBehaviorSpeaker Dragengine.Scenery.ECBehaviorSpeaker.new ( BehaviorElementClass  eclass,
ECBehaviorCollider  collider,
String  id 
)

Create behavior element class.

◆ set() [1/3]

void Dragengine.Scenery.ECBehaviorSpeaker.set ( String  sound,
float  range,
float  volume,
Vector  position 
)

◆ set() [2/3]

void Dragengine.Scenery.ECBehaviorSpeaker.set ( String  sound,
float  range,
float  volume,
Vector  position,
Vector  orientation 
)

◆ set() [3/3]

void Dragengine.Scenery.ECBehaviorSpeaker.set ( String  sound,
float  range,
float  volume,
Vector  position,
Vector  orientation,
String  bone 
)

◆ setSyncTrigger()

void Dragengine.Scenery.ECBehaviorSpeaker.setSyncTrigger ( ECBehaviorSpeaker  behavior)

Set ECBehaviorSpeaker to synchronize triggers with or null to disable.

◆ setTriggerTable()

void Dragengine.Scenery.ECBehaviorSpeaker.setTriggerTable ( Loaders  loaders,
TSTriggerTable  triggerTable 
)
protected

Set trigger table or null if not used.


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