#include "level_status.h" void LevelStatus::_bind_methods() { ClassDB::bind_method(D_METHOD("object_destroyed", "value"), &self_type::object_destroyed); ADD_SIGNAL(MethodInfo(sig_object_destroyed, PropertyInfo(Variant::FLOAT, "style"), PropertyInfo(Variant::INT, "score"))); } void LevelStatus::process(double delta) { this->time_since_last += delta; } void LevelStatus::_notification(int what) { if (Engine::get_singleton()->is_editor_hint()) { return; } switch (what) { default: return; case NOTIFICATION_ENTER_TREE: instance = this; return; case NOTIFICATION_EXIT_TREE: if (instance == this) { instance = nullptr; } return; case NOTIFICATION_READY: set_process(true); return; case NOTIFICATION_PROCESS: process(get_process_delta_time()); return; } } void LevelStatus::object_destroyed(int value) { double style_value{ 1 + (this->max_time_between > this->time_since_last ? this->max_time_between - this->time_since_last : 0.0) }; this->style += this->base_style_per_object * style_value; this->score += value * (1 + this->style); emit_signal(sig_object_destroyed, this->style, this->score); } String const LevelStatus::sig_object_destroyed{ "object_destroyed" }; LevelStatus *LevelStatus::instance{ nullptr }; LevelStatus *LevelStatus::get_instance() { return instance; }