Drag[en]gine Script Module DragonScript
1.23
|
Behavior element behavior play sound using one shot speaker. More...
Classes | |
class | Instance |
Behavior instance. More... | |
Public Member Functions | |
void | dispose () |
Dispose of behavior. More... | |
ECPString | getBone () |
Name of bone to use to null if not used. More... | |
ECBehaviorCollider | getCollider () |
Collider behavior or null if not used. More... | |
ECBehaviorComponent | getComponent () |
Component behavior or null if not used. More... | |
ECPFloat | getDistanceOffset () |
Distance offset for attenuation calculation. More... | |
LayerMask | getLayerMask () |
Layer mask. More... | |
ECPVector | getOrientation () |
Orientation relative to element. More... | |
ECPFloat | getPlaySpeed () |
Play speed. More... | |
ECPVector | getPosition () |
Position relative to element. More... | |
String | getPrefix () |
Prefix. More... | |
ECPFloat | getRange () |
Speaker range. More... | |
ECPFloat | getRollOff () |
Half volume distance. More... | |
ECPSound | getSound () |
Speaker sound. More... | |
ECPEnumeration | getSpeakerType () |
Speaker type. More... | |
ECBehaviorTriggered | getTrigger () |
Trigger play sound. More... | |
TSTriggerTable | getTriggerTable () |
Trigger table or null if not used. More... | |
ECPFloat | getVolume () |
Speaker volume. More... | |
Instance | instance (BehaviorElement element) |
Get instance in element from owner element class. More... | |
ECBehaviorPlaySound | new (BehaviorElementClass eclass, ECBehaviorComponent component, ECBehaviorCollider collider) |
Create behavior element class. More... | |
ECBehaviorPlaySound | new (BehaviorElementClass eclass, ECBehaviorComponent component, ECBehaviorCollider collider, String id) |
Create behavior element class. More... | |
ECBehaviorPlaySound | new (BehaviorElementClass eclass, ECBehaviorComponent component, ECBehaviorCollider collider, String id, String prefix) |
Create behavior element class. More... | |
ECBehaviorPlaySound | new (BehaviorElementClass eclass, ECBehaviorComponent component, ECBehaviorCollider collider, TSTriggerTable triggerTable) |
Create behavior element class. More... | |
ECBehaviorPlaySound | new (BehaviorElementClass eclass, ECBehaviorComponent component, ECBehaviorCollider collider, TSTriggerTable triggerTable, String id) |
Create behavior element class. More... | |
ECBehaviorPlaySound | new (BehaviorElementClass eclass, ECBehaviorComponent component, ECBehaviorCollider collider, TSTriggerTable triggerTable, String id, String subID) |
ECBehaviorPlaySound | new (BehaviorElementClass eclass, ECBehaviorComponent component, ECBehaviorCollider collider, TSTriggerTable triggerTable, String id, String subID, String prefix) |
void | set (String sound, float range, float volume) |
Set to point speaker with parameters. 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 | setLayerMask (LayerMask layerMask) |
Set layer mask. 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 ECBehaviorPlaySound | getBehaviorIn (BehaviorElementClass eclass) |
Get behavior in element class or null if absent. More... | |
Protected Member Functions | |
void | setTriggerTable (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... | |
Behavior element behavior play sound using one shot speaker.
Behavior is comparable to ECBehaviorSpeaker but does not add a permanent speaker to the element. Instead GWBehaviorOneShotSpeaker.addSpeaker() is used to play a short sound event. One shot speakers are constructed the same way as ECBehaviorSpeaker does. Once deployed the one shot speaker stays in place and vanishes once it finished playing. This is the preferred way to play short sound events like a door lock toggling or firing gun shots.
This behavior can be added multiple times to an element. This allows to play different sound events. Each instance has an identifier which can be used to retrieve a specific instance to play a one shot speaker. The prefix of the speaker class properties is "playSound." . If the identifier is not empty the speaker element class properties have the prefix "{id}.playSound." . This can be overwritten if required.
Hence to use more than one speaker use code like this in your subclass constructor:
You can now define the parameters to use for both speakers using for example the properties "volume" for the first speaker and "subPlaySound.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.
Typical parameters can be set quickly using ECBehaviorPlaySound.set() methods. This is an example of door element class playing a sound for opening and a sound for closing. Both sounds have a range of 30m and play at a volume of 0.8 and play at the center of the door. In XML element classes these sound parameters can be modified using "playSound.open.*" and "playSound.close.*".
Element class properties have the prefix "playSound{(id)}.".
If a trigger table is set the trigger expression "triggerPlay" or "{prefix}.triggerPlay" can be used to play sound each time the trigger expression changes and evaluates to true. Using a trigger table is usually only useful if the element can be used by mappers.
This behavior does not require the element class to be persistable (setPersistable).
void Dragengine.Scenery.ECBehaviorPlaySound.dispose | ( | ) |
Dispose of behavior.
Reimplemented from Dragengine.Scenery.DefaultECBehavior.
|
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.
ECPString Dragengine.Scenery.ECBehaviorPlaySound.getBone | ( | ) |
Name of bone to use to null if not used.
ECBehaviorCollider Dragengine.Scenery.ECBehaviorPlaySound.getCollider | ( | ) |
Collider behavior or null if not used.
ECBehaviorComponent Dragengine.Scenery.ECBehaviorPlaySound.getComponent | ( | ) |
Component behavior or null if not used.
ECPFloat Dragengine.Scenery.ECBehaviorPlaySound.getDistanceOffset | ( | ) |
Distance offset for attenuation calculation.
For use by distance sounds. Offsets the true distance to the sound source for attenuation calculation to make the sound appear coming from far away. Requires increasing the volume to compensate for the distance increased attenuation.
LayerMask Dragengine.Scenery.ECBehaviorPlaySound.getLayerMask | ( | ) |
Layer mask.
ECPVector Dragengine.Scenery.ECBehaviorPlaySound.getOrientation | ( | ) |
Orientation relative to element.
ECPFloat Dragengine.Scenery.ECBehaviorPlaySound.getPlaySpeed | ( | ) |
Play speed.
ECPVector Dragengine.Scenery.ECBehaviorPlaySound.getPosition | ( | ) |
Position relative to element.
String Dragengine.Scenery.ECBehaviorPlaySound.getPrefix | ( | ) |
Prefix.
ECPFloat Dragengine.Scenery.ECBehaviorPlaySound.getRollOff | ( | ) |
Half volume distance.
ECPEnumeration Dragengine.Scenery.ECBehaviorPlaySound.getSpeakerType | ( | ) |
Speaker type.
ECBehaviorTriggered Dragengine.Scenery.ECBehaviorPlaySound.getTrigger | ( | ) |
Trigger play sound.
TSTriggerTable Dragengine.Scenery.ECBehaviorPlaySound.getTriggerTable | ( | ) |
Trigger table or null if not used.
Instance Dragengine.Scenery.ECBehaviorPlaySound.instance | ( | BehaviorElement | element | ) |
Get instance in element from owner element class.
ECBehaviorPlaySound Dragengine.Scenery.ECBehaviorPlaySound.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
ECBehaviorCollider | collider | ||
) |
Create behavior element class.
These values are optional and can be null: component, collider.
Reimplemented in Dragengine.Scenery.ECBehaviorPlaySoundRandom.
ECBehaviorPlaySound Dragengine.Scenery.ECBehaviorPlaySound.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
ECBehaviorCollider | collider, | ||
String | id | ||
) |
Create behavior element class.
Reimplemented in Dragengine.Scenery.ECBehaviorPlaySoundRandom.
ECBehaviorPlaySound Dragengine.Scenery.ECBehaviorPlaySound.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
ECBehaviorCollider | collider, | ||
String | id, | ||
String | prefix | ||
) |
Create behavior element class.
Reimplemented in Dragengine.Scenery.ECBehaviorPlaySoundRandom.
ECBehaviorPlaySound Dragengine.Scenery.ECBehaviorPlaySound.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
ECBehaviorCollider | collider, | ||
TSTriggerTable | triggerTable | ||
) |
Create behavior element class.
Reimplemented in Dragengine.Scenery.ECBehaviorPlaySoundRandom.
ECBehaviorPlaySound Dragengine.Scenery.ECBehaviorPlaySound.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
ECBehaviorCollider | collider, | ||
TSTriggerTable | triggerTable, | ||
String | id | ||
) |
Create behavior element class.
Reimplemented in Dragengine.Scenery.ECBehaviorPlaySoundRandom.
ECBehaviorPlaySound Dragengine.Scenery.ECBehaviorPlaySound.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
ECBehaviorCollider | collider, | ||
TSTriggerTable | triggerTable, | ||
String | id, | ||
String | subID | ||
) |
Reimplemented in Dragengine.Scenery.ECBehaviorPlaySoundRandom.
ECBehaviorPlaySound Dragengine.Scenery.ECBehaviorPlaySound.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
ECBehaviorCollider | collider, | ||
TSTriggerTable | triggerTable, | ||
String | id, | ||
String | subID, | ||
String | prefix | ||
) |
Reimplemented in Dragengine.Scenery.ECBehaviorPlaySoundRandom.
void Dragengine.Scenery.ECBehaviorPlaySound.set | ( | String | sound, |
float | range, | ||
float | volume | ||
) |
Set to point speaker with parameters.
Helper method to quickly set up playing sound.
void Dragengine.Scenery.ECBehaviorPlaySound.set | ( | String | sound, |
float | range, | ||
float | volume, | ||
Vector | position | ||
) |
void Dragengine.Scenery.ECBehaviorPlaySound.set | ( | String | sound, |
float | range, | ||
float | volume, | ||
Vector | position, | ||
Vector | orientation | ||
) |
void Dragengine.Scenery.ECBehaviorPlaySound.set | ( | String | sound, |
float | range, | ||
float | volume, | ||
Vector | position, | ||
Vector | orientation, | ||
String | bone | ||
) |
void Dragengine.Scenery.ECBehaviorPlaySound.setLayerMask | ( | LayerMask | layerMask | ) |
Set layer mask.
|
protected |
Set trigger table or null if not used.