Skip to content
1 change: 1 addition & 0 deletions ecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void ECS::_bind_methods() {
BIND_ENUM_CONSTANT(PHASE_PRE_PROCESS);
BIND_ENUM_CONSTANT(PHASE_PROCESS);
BIND_ENUM_CONSTANT(PHASE_POST_PROCESS);
BIND_ENUM_CONSTANT(PHASE_FINALIZE_PROCESS);
BIND_ENUM_CONSTANT(PHASE_PRE_RENDER);
}

Expand Down
21 changes: 12 additions & 9 deletions iterators/dynamic_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ using godex::DynamicQuery;

void DynamicQuery::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_space", "space"), &DynamicQuery::set_space);
ClassDB::bind_method(D_METHOD("with_component", "component_id", "mutable"), &DynamicQuery::with_component);
ClassDB::bind_method(D_METHOD("maybe_component", "component_id", "mutable"), &DynamicQuery::maybe_component);
ClassDB::bind_method(D_METHOD("changed_component", "component_id", "mutable"), &DynamicQuery::changed_component);
ClassDB::bind_method(D_METHOD("with_component", "component_id", "is_mutable"), &DynamicQuery::with_component, DEFVAL(false));
ClassDB::bind_method(D_METHOD("maybe_component", "component_id", "is_mutable"), &DynamicQuery::maybe_component, DEFVAL(false));
ClassDB::bind_method(D_METHOD("changed_component", "component_id", "is_mutable"), &DynamicQuery::changed_component, DEFVAL(false));
ClassDB::bind_method(D_METHOD("not_component", "component_id"), &DynamicQuery::not_component);

ClassDB::bind_method(D_METHOD("is_valid"), &DynamicQuery::is_valid);
Expand All @@ -27,6 +27,9 @@ void DynamicQuery::_bind_methods() {

ClassDB::bind_method(D_METHOD("get_current_entity_id"), &DynamicQuery::script_get_current_entity_id);
ClassDB::bind_method(D_METHOD("count"), &DynamicQuery::count);

BIND_ENUM_CONSTANT(LOCAL);
BIND_ENUM_CONSTANT(GLOBAL);
}

DynamicQuery::DynamicQuery() {
Expand All @@ -36,23 +39,23 @@ void DynamicQuery::set_space(Space p_space) {
space = p_space;
}

void DynamicQuery::with_component(uint32_t p_component_id, bool p_mutable) {
_with_component(p_component_id, p_mutable, WITH_MODE);
void DynamicQuery::with_component(uint32_t p_component_id, bool p_is_mutable) {
_with_component(p_component_id, p_is_mutable, WITH_MODE);
}

void DynamicQuery::maybe_component(uint32_t p_component_id, bool p_mutable) {
_with_component(p_component_id, p_mutable, MAYBE_MODE);
}

void DynamicQuery::changed_component(uint32_t p_component_id, bool p_mutable) {
_with_component(p_component_id, p_mutable, CHANGED_MODE);
void DynamicQuery::changed_component(uint32_t p_component_id, bool p_is_mutable) {
_with_component(p_component_id, p_is_mutable, CHANGED_MODE);
}

void DynamicQuery::not_component(uint32_t p_component_id) {
_with_component(p_component_id, false, WITHOUT_MODE);
}

void DynamicQuery::_with_component(uint32_t p_component_id, bool p_mutable, FetchMode p_mode) {
void DynamicQuery::_with_component(uint32_t p_component_id, bool p_is_mutable, FetchMode p_mode) {
ERR_FAIL_COND_MSG(is_valid() == false, "This query is not valid.");
ERR_FAIL_COND_MSG(can_change == false, "This query can't change at this point, you have to `clear` it.");
if (unlikely(ECS::verify_component_id(p_component_id) == false)) {
Expand All @@ -66,7 +69,7 @@ void DynamicQuery::_with_component(uint32_t p_component_id, bool p_mutable, Fetc
DynamicQueryElement data;
data.id = p_component_id;
data.name = ECS::get_component_name(p_component_id);
data.mutability = p_mutable;
data.mutability = p_is_mutable;
data.mode = p_mode;
data.entity_list_index = UINT32_MAX;
elements.push_back(data);
Expand Down
8 changes: 4 additions & 4 deletions iterators/dynamic_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ class DynamicQuery : public GodexWorldFetcher {
void set_space(Space p_space);

/// Add component.
void with_component(uint32_t p_component_id, bool p_mutable = false);
void maybe_component(uint32_t p_component_id, bool p_mutable = false);
void changed_component(uint32_t p_component_id, bool p_mutable = false);
void with_component(uint32_t p_component_id, bool p_is_mutable = false);
void maybe_component(uint32_t p_component_id, bool p_is_mutable = false);
void changed_component(uint32_t p_component_id, bool p_is_mutable = false);

/// Excludes this component from the query.
void not_component(uint32_t p_component_id);

void _with_component(uint32_t p_component_id, bool p_mutable, FetchMode p_mode);
void _with_component(uint32_t p_component_id, bool p_is_mutable, FetchMode p_mode);

/// Returns true if this query is valid.
bool is_valid() const;
Expand Down
3 changes: 2 additions & 1 deletion modules/godot/editor_plugins/editor_world_ecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "editor/editor_scale.h"
#include "scene/gui/color_rect.h"
#include "scene/gui/reference_rect.h"
#include "scene/gui/separator.h"

PipelineElementInfoBox::PipelineElementInfoBox(EditorNode *p_editor, EditorWorldECS *p_editor_world_ecs) :
editor(p_editor),
Expand Down Expand Up @@ -42,7 +43,7 @@ PipelineElementInfoBox::PipelineElementInfoBox(EditorNode *p_editor, EditorWorld
remove_btn->set_h_size_flags(0);
remove_btn->set_v_size_flags(0);
remove_btn->set_flat(true);
remove_btn->connect(SNAME("pressed"), callable_mp(this, &PipelineElementInfoBox::system_remove), Vector<Variant>(), CONNECT_DEFERRED);
remove_btn->connect(SNAME("pressed"), callable_mp(this, &PipelineElementInfoBox::system_remove), CONNECT_DEFERRED);
box->add_child(remove_btn);

system_name_lbl = memnew(Label);
Expand Down
2 changes: 1 addition & 1 deletion modules/godot/editor_plugins/entity_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void EntityEditor::update_editors() {
del_btn->set_icon(editor->get_theme_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
del_btn->set_flat(false);
del_btn->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
del_btn->connect(SNAME("pressed"), callable_mp(this, &EntityEditor::_remove_component_pressed), varray(*it.key));
del_btn->connect(SNAME("pressed"), callable_mp(this, &EntityEditor::_remove_component_pressed).bind(*it.key));
component_section->get_vbox()->add_child(del_btn);

create_component_inspector(*it.key, *it.value, component_section->get_vbox());
Expand Down
8 changes: 8 additions & 0 deletions modules/godot/nodes/ecs_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ void System::_bind_methods() {
BIND_ENUM_CONSTANT(IMMUTABLE);
BIND_ENUM_CONSTANT(MUTABLE);

BIND_ENUM_CONSTANT(PHASE_CONFIG);
BIND_ENUM_CONSTANT(PHASE_INPUT);
BIND_ENUM_CONSTANT(PHASE_PRE_PROCESS);
BIND_ENUM_CONSTANT(PHASE_PROCESS);
BIND_ENUM_CONSTANT(PHASE_POST_PROCESS);
BIND_ENUM_CONSTANT(PHASE_FINALIZE_PROCESS);
BIND_ENUM_CONSTANT(PHASE_PRE_RENDER);

ClassDB::add_virtual_method(get_class_static(), MethodInfo("_prepare"));
// TODO how to define `_execute`? It has dynamic argument, depending on the `_prepare` function.
}
Expand Down
7 changes: 2 additions & 5 deletions modules/godot/nodes/ecs_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void WorldECS::_notification(int p_what) {
if (Engine::get_singleton()->is_editor_hint()) {
init_default();

ScriptEcs::get_singleton()->connect("ecs_script_reloaded", callable_mp(this, &WorldECS::on_ecs_script_reloaded), Vector<Variant>(), CONNECT_DEFERRED);
ScriptEcs::get_singleton()->connect("ecs_script_reloaded", callable_mp(this, &WorldECS::on_ecs_script_reloaded), CONNECT_DEFERRED);
}
#endif

Expand Down Expand Up @@ -467,12 +467,9 @@ void WorldECS::add_pipeline(Ref<PipelineECS> p_pipeline) {
if (Engine::get_singleton()->is_editor_hint()) {
update_configuration_warnings();

Vector<Variant> vars;
vars.push_back(p_pipeline);
p_pipeline->connect(
CoreStringNames::get_singleton()->property_list_changed,
callable_mp(this, &WorldECS::on_pipeline_changed),
vars);
callable_mp(this, &WorldECS::on_pipeline_changed).bind(p_pipeline));
}
#endif
}
Expand Down
6 changes: 6 additions & 0 deletions modules/godot/nodes/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ void Entity3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_reference_by_nodepath", "active"), &Entity3D::set_reference_by_nodepath);
ClassDB::bind_method(D_METHOD("get_reference_by_nodepath"), &Entity3D::get_reference_by_nodepath);

BIND_ENUM_CONSTANT(LOCAL);
BIND_ENUM_CONSTANT(GLOBAL);

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync_transform"), "set_sync_transform", "get_sync_transform");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reference_by_nodepath"), "set_reference_by_nodepath", "get_reference_by_nodepath");
}
Expand All @@ -67,6 +70,9 @@ void Entity2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_reference_by_nodepath", "active"), &Entity2D::set_reference_by_nodepath);
ClassDB::bind_method(D_METHOD("get_reference_by_nodepath"), &Entity2D::get_reference_by_nodepath);

BIND_ENUM_CONSTANT(LOCAL);
BIND_ENUM_CONSTANT(GLOBAL);

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync_transform"), "set_sync_transform", "get_sync_transform");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reference_by_nodepath"), "set_reference_by_nodepath", "get_reference_by_nodepath");
}
2 changes: 1 addition & 1 deletion systems/dynamic_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "../pipeline/pipeline.h"
#include "../utils/fetchers.h"
#include "modules/gdscript/gdscript.cpp"
#include "modules/gdscript/gdscript.h"

godex::DynamicSystemExecutionData::DynamicSystemExecutionData() {}

Expand Down