#include "register_types.h"
#include "mpq_manager.h"
#include "wmo_loader.h"
#include "adt_loader.h"
#include "adt_baker.h"
#include "blp_loader.h"
#include "m2_loader.h"
#include "wdt_loader.h"

#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/godot.hpp>

using namespace godot;

void initialize_mpq_extractor_module(ModuleInitializationLevel p_level) {
    if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) return;
    ClassDB::register_class<MPQManager>();
    ClassDB::register_class<WMOLoader>();
    ClassDB::register_class<ADTLoader>();
    ClassDB::register_class<ADTBaker>();
    ClassDB::register_class<BLPLoader>();
    ClassDB::register_class<M2Loader>();
    ClassDB::register_class<WDTLoader>();
}

void uninitialize_mpq_extractor_module(ModuleInitializationLevel p_level) {
    if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) return;
}

extern "C" {

GDExtensionBool GDE_EXPORT mpq_extractor_init(
    GDExtensionInterfaceGetProcAddress p_get_proc_address,
    const GDExtensionClassLibraryPtr   p_library,
    GDExtensionInitialization         *r_initialization)
{
    godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
    init_obj.register_initializer(initialize_mpq_extractor_module);
    init_obj.register_terminator(uninitialize_mpq_extractor_module);
    init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
    return init_obj.init();
}

} // extern "C"
