#include "exit_trigger.hpp"
#include "rally_rush_game_mode.hpp"
#include "utils/game_root.hpp"
#include "utils/godot_macros.h"

namespace godot {
void ExitTrigger::_bind_methods() {
#define CLASSNAME ExitTrigger
}

void ExitTrigger::_enter_tree() { GDGAMEONLY();
    this->connect("body_entered", callable_mp(this, &ExitTrigger::body_entered));
}

void ExitTrigger::body_entered(Node3D *node) {
    Ref<RallyRushGameMode> game_mode{GameRoot3D::get_singleton()->get_game_mode()};
    if(game_mode->get_num_found_keys() == 3)
        game_mode->notify_player_escaped();
}
}
