#include "key_pickup.hpp"
#include "car_player.hpp"
#include "rally_rush_game_mode.hpp"
#include "utils/game_root.hpp"
#include "utils/godot_macros.h"

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

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

void KeyPickup::body_entered(Node *node) {
    if(!this->is_queued_for_deletion() && cast_to<CarPlayer>(node) != nullptr) {
        Ref<RallyRushGameMode>(GameRoot3D::get_singleton()->get_game_mode())->notify_key_found();
        this->queue_free();
    }
}
}
