#include "enemy_spawnpoint.hpp"
#include "spawner.hpp"
#include "utils/godot_macros.h"
#include <godot_cpp/classes/physics_ray_query_parameters3d.hpp>
#include <godot_cpp/classes/viewport.hpp>
#include <godot_cpp/classes/camera3d.hpp>
#include <godot_cpp/classes/world3d.hpp>
#include <godot_cpp/classes/physics_direct_space_state3d.hpp>

namespace godot {
void EnemySpawnpoint::_bind_methods() {
#define CLASSNAME EnemySpawnpoint
    GDPROPERTY(keys, Variant::BOOL);
    GDPROPERTY(cars, Variant::BOOL);
    GDPROPERTY(drones, Variant::BOOL);
}

bool EnemySpawnpoint::player_can_see() const {
    Dictionary result = this->get_world_3d()->get_direct_space_state()
        ->intersect_ray(PhysicsRayQueryParameters3D::create(this->get_global_position(), this->get_viewport()->get_camera_3d()->get_global_position()));
    return result.is_empty();
}

void EnemySpawnpoint::set_keys(bool val) {
    this->keys = val;
}

bool EnemySpawnpoint::get_keys() const {
    return this->keys;
}

void EnemySpawnpoint::set_cars(bool val) {
    this->cars = val;
}

bool EnemySpawnpoint::get_cars() const {
    return this->cars;
}

void EnemySpawnpoint::set_drones(bool val) {
    this->drones = val;
}

bool EnemySpawnpoint::get_drones() const {
    return this->drones;
}
}
