// register_types.cpp — GDExtension 模块注册入口
// 新增 C++ 类：在 initialize 里 GDREGISTER_CLASS(YourClass); 并包含其头文件。
#include "register_types.h"

#include "spellforge_native.h"

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

using namespace godot;

void initialize_spellforge_module(ModuleInitializationLevel p_level) {
	if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
		return;
	}
	GDREGISTER_CLASS(SpellforgeNative);
}

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

extern "C" {
// 入口符号，须与 .gdextension 的 entry_symbol 一致。
GDExtensionBool GDE_EXPORT spellforge_library_init(
		GDExtensionInterfaceGetProcAddress p_get_proc_address,
		GDExtensionClassLibraryPtr p_library,
		GDExtensionInitialization *r_initialization) {
	godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);

	init_obj.register_initializer(initialize_spellforge_module);
	init_obj.register_terminator(uninitialize_spellforge_module);
	init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);

	return init_obj.init();
}
}
