Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorAnnouncer
Behavior element behavior adding announcer support.
Behavior uses an Announcer to play back announcer files. The speaker created by the Announcer instance is added to the game world.
If the ECBehaviorCollider is present the announcer speaker is attached. The speaker is attached to the named bone if defined otherwise it is attached statically.
This behavior contains a property to set the announcement text. Other behaviors can change this text at runtime to make this alter the announcement. Changing the announcement text will stop playing back the current announcement.
This behavior can be added multiple times to an element. Each instance creates one announcer speaker attached to the element collider which can be individually modified. To distinguish the announcers each instance has an identifier which can be used to retrieve a specific instance.
Element class properties have the prefix announcer.
or announcer({id}).
if id is not empty.
Path to announcer file to load.
announcer.path
or announcer({id}).path
*.announcer.xml
<string name='announcer.path'>speaker.announcer.xml</string>
Speaker type.
announcer.type
or announcer({id}).type
Allowed Values:
Value | Description |
---|---|
point | Omnidirectional. |
directed | Directed. |
point
<string name='announcer.type'>directed</string>
Speaker volume.
announcer.volume
or announcer({id}).volume
1
0
<float name='announcer.volume'>0.8</float>
Speaker range in meters. Speaker is inaudible beyond range.
announcer.range
or announcer({id}).range
30
0
<float name='announcer.range'>20</float>
Roll off. Value 1
is realistic (normal) roll-off. Values larger than 1
reduce volume faster near the sound source. Values smaller than 1
reduce volume faster near the sound range.
announcer.rollOff
or announcer({id}).rollOff
1
0
<float name='announcer.rollOff'>1.5</float>
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.
announcer.distanceOffset
or announcer({id}).distanceOffset
0
0
<float name='announcer.distanceOffset'>500</float>
Speaker shape.
announcer.shape
or announcer({id}).shape
<string name='announcer.shape'>box:position,0,0.5,0:extends,2,1,0.5</string>
Announcement text.
announcer.text
or announcer({id}).text
<string name='announcer.text'>This is an announcement.</string>
Position to attach resource to collider.
announcer.position
or announcer({id}).position
<vector name='announcer.position' x='0' y='0' z='0.1'/>
Orientation to attach resource to collider in degrees.
announcer.orientation
or announcer({id}).orientation
<vector name='announcer.orientation' x='30' y='0' z='0'/>
Bone to attach resource to. If empty string attach to collider.
announcer.bone
or announcer({id}).bone
<string name='announcer.bone'>attach</string>
Play announcement whenever trigger evaluates to true.
announcer.trigger
or announcer({id}).trigger
<string name='announcer.trigger'>@switchOnVent & @powerEnabled</string>
Start playing back announcement.
Stop playing back announcement.
This behavior requires no other behaviors.
This behavior does not required element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which supports playing announcements.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorAnnouncer announcer func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) announcer = ECBehaviorAnnouncer.new(this, collider) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorAnnouncer'> <!-- optional: set layer mask (default '2' meaning BaseGameApp.WorldLayerBit.audio). list of bits to set. --> <string name='layerMask'>0 1 4</string> <!-- optional: use BaseGameApp trigger table. game can add more supported values --> <string name='triggerTable'>default</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.text'>This is an announcement.</string> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorAnnouncer' id='second'/> </elementClass>