Skip to content

Commit 28b46ca

Browse files
committed
Move register_runtime_scripts to NOTIFICATION_POSTINITIALIZE
1 parent 491daa4 commit 28b46ca

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Godex is a Godot Engine ecs library.
1313
**Disclaimer:** this module is still in development, open an [issues](https://github.com/GodotECS/godex/issues) to report any problem or a new [discussion](https://github.com/GodotECS/godex/discussions) if you need any help. Any form of contribution is welcome.
1414

1515
### The tested Godot version
16-
Is `master` `889868cbbc8beac74d5f49f9b7ef41efc4ae7d5a`, please open an issue if the current master is not working or doesn't compile.
16+
Is `master` `c4fb119f03477ad9a494ba6cdad211b35a8efcce`, please open an issue if the current master is not working or doesn't compile.
1717

1818
### What is ECS
1919
Shortened as ECS, the Entity Component System is an architectural design pattern that allow to organize the data in a way so that the workload can be split into small and easy programs.

modules/godot/nodes/ecs_world.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ const ExecutionGraph *PipelineECS::editor_get_execution_graph_or_null() const {
166166
}
167167

168168
void PipelineECS::editor_reload_execution_graph() {
169-
editor_clear_execution_graph();
169+
if (Engine::get_singleton()->is_editor_hint()) {
170+
editor_clear_execution_graph();
171+
}
170172
// Re-build the execution graph.
171173
editor_get_execution_graph();
172174
}
@@ -326,6 +328,11 @@ void WorldECS::_get_property_list(List<PropertyInfo> *p_list) const {
326328

327329
void WorldECS::_notification(int p_what) {
328330
switch (p_what) {
331+
case NOTIFICATION_POSTINITIALIZE:
332+
// Make sure to register all scripted components/databags/systems
333+
// at this point.
334+
ScriptEcs::get_singleton()->register_runtime_scripts();
335+
break;
329336
case NOTIFICATION_READY:
330337
#ifdef TOOLS_ENABLED
331338
if (Engine::get_singleton()->is_editor_hint()) {
@@ -335,10 +342,6 @@ void WorldECS::_notification(int p_what) {
335342
}
336343
#endif
337344

338-
// Make sure to register all scripted components/databags/systems
339-
// at this point.
340-
ScriptEcs::get_singleton()->register_runtime_scripts(); // TODO do I need this?
341-
342345
add_to_group("_world_ecs");
343346
if (Engine::get_singleton()->is_editor_hint() == false) {
344347
active_world();

modules/godot/nodes/script_ecs.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ void ScriptEcs::flush_scripts_preparation() {
445445
}
446446

447447
void ScriptEcs::save_script(const String &p_setting_list_name, const String &p_script_path) {
448+
if (!Engine::get_singleton()->is_editor_hint())
449+
return;
448450
ERR_FAIL_COND_MSG(EditorNode::get_singleton() == nullptr, "The editor is not defined.");
449451

450452
Array scripts;

0 commit comments

Comments
 (0)