#ifndef SPAWNER_HPP
#define SPAWNER_HPP

#include "enemy_spawnpoint.hpp"
#include "godot_cpp/classes/packed_scene.hpp"
#include "godot_cpp/classes/random_number_generator.hpp"
#include "godot_cpp/templates/vector.hpp"
#include "rally_rush_game_mode.hpp"
#include <godot_cpp/classes/node.hpp>

namespace godot {
class EnemySpawnpoint;
class Spawner : public Node {
    GDCLASS(Spawner, Node);
    static void _bind_methods();
public:
    virtual void _enter_tree() override;
    virtual void _process(double delta_time) override;

    int max_enemy_cars();
    int max_enemy_drones();
protected:
    void spawn_enemy_car();
    void spawn_enemy_drone();
    void spawn_key();
    void decrement_cars();
    void decrement_drones();
    void set_drone_scene(Ref<PackedScene> scene);
    Ref<PackedScene> get_drone_scene() const;
    void set_car_scene(Ref<PackedScene> scene);
    Ref<PackedScene> get_car_scene() const;
    void set_key_scene(Ref<PackedScene> scene);
    Ref<PackedScene> get_key_scene() const;
private:
    double next{0};
    unsigned tick{0};
    RallyRushGameMode *game_mode;
    Vector<EnemySpawnpoint *> spawnpoints{};
    Ref<PackedScene> drone_scene{};
    Ref<PackedScene> car_scene{};
    Ref<PackedScene> key_scene{};
    RandomNumberGenerator rng{};
    unsigned num_cars{0};
    unsigned num_drones{0};
};
}

#endif // !SPAWNER_HPP
