feat: added sound events for enemy awareness

This commit is contained in:
Sara 2025-08-04 17:00:23 +02:00
parent 1373656f90
commit 66aede32bd
15 changed files with 234 additions and 16 deletions

View file

@ -0,0 +1,27 @@
#include "sound_event_patchboard.h"
SoundEventPatchboard *SoundEventPatchboard::singleton_instance{ nullptr };
String const SoundEventPatchboard::sig_sound_triggered{ "sound_triggered" };
void SoundEventPatchboard::_bind_methods() {
ClassDB::bind_method(D_METHOD("trigger_sound", "at", "range"), &self_type::trigger_sound);
ADD_SIGNAL(MethodInfo(sig_sound_triggered, PropertyInfo(Variant::VECTOR3, "at"), PropertyInfo(Variant::FLOAT, "range")));
}
SoundEventPatchboard::SoundEventPatchboard() {
singleton_instance = this;
}
SoundEventPatchboard::~SoundEventPatchboard() {
if (singleton_instance == this) {
singleton_instance = nullptr;
}
}
SoundEventPatchboard *SoundEventPatchboard::get_singleton() {
return singleton_instance;
}
void SoundEventPatchboard::trigger_sound(Vector3 at, float range) {
emit_signal(sig_sound_triggered, at, range);
}