HammeriteAudioHearing
Audio. Inherits RefCounted
What a map's listeners can hear: the gameplay half of acoustics, apart from the mixing.
One per map, on its HammeriteAudioManager.hearing. A game's AI touches this and little else: a guard's HammeriteAudioReceiver3D registers itself here, and whatever makes a noise reports it - through HammeriteAudio.report_sound(), or by playing an HammeriteAudioEmitter3D with a HammeriteAudioEmitter3D.sound_type, both of which end up at report_sound().
Nothing happens for a type nothing has subscribed to. That is the whole cost model: a footstep in a level where nothing listens for footsteps is not propagated, or even measured.
It asks the mixer how sound gets from one place to another, so that what a guard hears and what the player hears are one answer rather than two that disagree. What it decides itself is who was in earshot, how loud it arrived, and where it seemed to come from.
Listeners by the sound types they subscribe to. Indexed this way because the type is the routing decision: a sound whose type nobody listens for costs nothing, not even a distance check.
Native since 2.0 (#269): made with create(), which takes the mixer the script's constructor took.
Methods
| Returns | Method |
|---|---|
bool | anyone_hears(type: StringName) const |
HammeriteAudioHearing | create(mixer: HammeriteAudioManager) static |
void | register_listener(listener: HammeriteAudioReceiver3D) |
void | report_sound(type: StringName, position: Vector3, emitter: Node = null) |
void | unregister_listener(listener: HammeriteAudioReceiver3D) |
Method descriptions
anyone_hears()
func anyone_hears(type: StringName) -> bool
Undocumented.
create()
static func create(mixer: HammeriteAudioManager) -> HammeriteAudioHearing
A native class is made with no arguments, so this stands in for new(mixer).
register_listener()
func register_listener(listener: HammeriteAudioReceiver3D) -> void
Undocumented.
report_sound()
func report_sound(type: StringName, position: Vector3, emitter: Node = null) -> void
Undocumented.
unregister_listener()
func unregister_listener(listener: HammeriteAudioReceiver3D) -> void
Undocumented.