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,44 @@
#include "sound_event_node.h"
#include "macros.h"
#include "sound_event_patchboard.h"
void SoundEventNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("trigger_event"), &self_type::trigger_event);
BIND_PROPERTY(Variant::BOOL, trigger_on_ready);
}
void SoundEventNode::ready() {
if (this->trigger_on_ready) {
trigger_event();
}
}
void SoundEventNode::_notification(int what) {
if (Engine::get_singleton()->is_editor_hint()) {
return;
}
if (what == NOTIFICATION_READY) {
ready();
}
}
void SoundEventNode::trigger_event() {
SoundEventPatchboard::get_singleton()->trigger_sound(get_global_position(), this->range);
}
void SoundEventNode::set_trigger_on_ready(bool value) {
this->trigger_on_ready = value;
}
bool SoundEventNode::get_trigger_on_ready() const {
return this->trigger_on_ready;
}
void SoundEventNode::set_range(float value) {
this->range = value;
}
float SoundEventNode::get_range() const {
return this->range;
}