#include "register_types.h"
#include "beacon_powerup.hpp"
#include "beam.hpp"
#include "car_physics.hpp"
#include "car_player.hpp"
#include "damage_area.hpp"
#include "drone.hpp"
#include "drone_target.hpp"
#include "end_screen.hpp"
#include "enemy_car.hpp"
#include "enemy_spawnpoint.hpp"
#include "exit_door.hpp"
#include "exit_trigger.hpp"
#include "game_ui.hpp"
#include "key_pickup.hpp"
#include "menu_ui.hpp"
#include "rally_rush_game_mode.hpp"
#include "spawner.hpp"
#include "turret.hpp"
#include "utils/game_mode.hpp"
#include "utils/game_root.hpp"
#include "utils/game_state.hpp"
#include "utils/level.hpp"
#include "utils/player_input.hpp"
#include "utils/spawn_point.hpp"
#include "weapon_pickup.hpp"
#include <gdextension_interface.h>
#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/godot.hpp>

using namespace godot;

void initialize_gdextension_types(ModuleInitializationLevel p_level)
{
    if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
        return;
    }
    ClassDB::register_class<GameMode>();
    ClassDB::register_class<GameRoot3D>();
    ClassDB::register_class<GameState>();
    ClassDB::register_class<Level3D>();
    ClassDB::register_class<PlayerInput>();
    ClassDB::register_class<SpawnPoint3D>();

    ClassDB::register_class<CarPhysics>();
    ClassDB::register_class<CarPlayer>();
    ClassDB::register_class<RallyRushGameMode>();
    ClassDB::register_class<KeyPickup>();
    ClassDB::register_class<GameUI>();
    ClassDB::register_class<MenuUI>();
    ClassDB::register_class<EndScreen>();
    ClassDB::register_class<Turret>();
    ClassDB::register_class<Beam>();
    ClassDB::register_class<ExitDoor>();
    ClassDB::register_class<ExitTrigger>();
    ClassDB::register_class<Spawner>();
    ClassDB::register_class<EnemySpawnpoint>();
    ClassDB::register_class<Drone>();
    ClassDB::register_class<DamageArea>();
    ClassDB::register_class<EnemyTargetBody>();
    ClassDB::register_class<WeaponPickup>();
    ClassDB::register_class<BeaconPowerup>();
    ClassDB::register_class<EnemyCar>();
}

extern "C"
{
    // Initialization
    GDExtensionBool GDE_EXPORT dirt_racer_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization)
    {
        GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
        init_obj.register_initializer(initialize_gdextension_types);
        init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);

        return init_obj.init();
    }
}
