YouDunIt/modules/you_done_it/clue_finder.cpp

54 lines
1 KiB
C++

#include "clue_finder.h"
#include "scene/main/node.h"
#include <core/config/engine.h>
ClueFinder *ClueFinder::singleton_instance{ nullptr };
void ClueFinder::_bind_methods() {}
void ClueFinder::enter_tree() {
if (singleton_instance == nullptr) {
singleton_instance = this;
} else {
queue_free();
}
}
void ClueFinder::exit_tree() {
if (singleton_instance == this) {
singleton_instance = nullptr;
}
}
void ClueFinder::_notification(int what) {
if (Engine::get_singleton()->is_editor_hint()) {
return;
}
switch (what) {
case NOTIFICATION_ENTER_TREE:
enter_tree();
return;
case NOTIFICATION_EXIT_TREE:
exit_tree();
return;
default:
return;
}
}
ClueFinder *ClueFinder::get_singleton() {
return singleton_instance;
}
ClueMarker *ClueFinder::find_current_clue() {
for (ClueMarker *marker : this->clue_markers) {
if (marker->is_visible()) {
return marker;
}
}
return nullptr;
}
void ClueFinder::register_clue_marker(ClueMarker *marker) {
this->clue_markers.insert(marker);
}