-
Notifications
You must be signed in to change notification settings - Fork 69
/
register_types.cpp
55 lines (46 loc) · 1.78 KB
/
register_types.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "./register_types.h"
#include "components/child.h"
#include "core/config/engine.h"
#include "databags/frame_time.h"
#include "ecs.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "iterators/dynamic_query.h"
#include "modules/godot/editor_plugins/components_gizmo_3d.h"
#include "pipeline/pipeline_commands.h"
#include "systems/dynamic_system.h"
#include "utils/fetchers.h"
Ref<Components3DGizmoPlugin> component_gizmo;
void initialize_godex_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
ClassDB::register_class<ECS>();
GDREGISTER_ABSTRACT_CLASS(GodexWorldFetcher);
ClassDB::register_class<godex::DynamicQuery>();
ClassDB::register_class<ComponentDynamicExposer>();
ClassDB::register_class<DatabagDynamicFetcher>();
ClassDB::register_class<StorageDynamicFetcher>();
ClassDB::register_class<EventsEmitterDynamicFetcher>();
ClassDB::register_class<EventsReceiverDynamicFetcher>();
// One day this will be inverted.
ClassDB::add_compatibility_class("Entity", "Entity3D");
// Create and register singleton
ECS *ecs = memnew(ECS);
ECS::__set_singleton(ecs);
Engine::get_singleton()->add_singleton(Engine::Singleton("ECS", ecs));
ECS::register_databag<WorldCommands>();
ECS::register_databag<World>();
ECS::register_databag<PipelineCommands>();
ECS::register_databag<FrameTime>();
} else if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
component_gizmo.instantiate();
}
}
void uninitialize_godex_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
// Clear ECS static memory.
ECS::__static_destructor();
ECS *ecs = ECS::get_singleton();
ECS::__set_singleton(nullptr);
memdelete(ecs);
component_gizmo = Ref<Components3DGizmoPlugin>();
}
}