45 lines
953 B
C++
45 lines
953 B
C++
#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;
|
|
}
|