#include "rally_rush_game_mode.hpp"
#include "godot_cpp/classes/resource_loader.hpp"
#include "utils/game_root.hpp"
#include "utils/godot_macros.h"

namespace godot {
void RallyRushGameMode::_bind_methods() {
#define CLASSNAME RallyRushGameMode
    GDSIGNAL("key_found", PropertyInfo(Variant::INT, "total_found"));
    GDSIGNAL("all_keys_found");
    GDSIGNAL("turret_pickup");
    GDSIGNAL("end_turret_pickup");
}

int RallyRushGameMode::get_num_found_keys() {
    return this->num_keys_found;
}

void RallyRushGameMode::notify_key_found() {
    ++this->num_keys_found;
    this->emit_signal("key_found", num_keys_found);
    if(num_keys_found == 3)
        this->emit_signal("all_keys_found");
}

void RallyRushGameMode::notify_turret_pickup() {
    this->emit_signal("turret_pickup");
}

void RallyRushGameMode::notify_end_turret_pickup() {
    this->emit_signal("end_turret_pickup");
}

#define GAME_END_SCENE "res://Levels/game_end_screen.tscn"
void RallyRushGameMode::notify_player_death() {
    GameRoot3D::get_singleton()->replace_levels(ResourceLoader::get_singleton()->load(GAME_END_SCENE));
}

void RallyRushGameMode::notify_player_escaped() {
    GameRoot3D::get_singleton()->replace_levels(ResourceLoader::get_singleton()->load(GAME_END_SCENE));
}
}
