@@ -34,13 +34,6 @@ Ref<GFComponent> GFComponent::from_id(
3434) {
3535 world = GFWorld::world_or_singleton (world);
3636
37- const EcsComponent* comp_data = GFComponent::get_component_ptr (world, comp);
38- // if (comp_data == nullptr) {
39- // ERR(nullptr,
40- // "Could not instantiate ", get_class_static(), "\n",
41- // " Entity ", world->id_to_text(comp), " is not a component"
42- // );
43- // }
4437 Ref<GFComponent> comp_ref = memnew (GFComponent (entity, comp, world));
4538 return setup_template<GFComponent>(comp_ref);
4639}
@@ -51,13 +44,6 @@ Ref<GFComponent> GFComponent::from_id_no_source(
5144) {
5245 world = GFWorld::world_or_singleton (world);
5346
54- // const EcsComponent* comp_data = GFComponent::get_component_ptr(world, comp);
55- // if (comp_data == nullptr) {
56- // ERR(nullptr,
57- // "Could not instantiate ", get_class_static(), "\n",
58- // " Entity ", world->id_to_text(comp), " is not a component"
59- // );
60- // }
6147 Ref<GFComponent> comp_ref = Ref (memnew (GFComponent (0 , comp, world)));
6248 comp_ref->update_script ();
6349 return comp_ref;
@@ -78,27 +64,34 @@ void GFComponent::_register_internal() {
7864 GFRegisterableEntity::_register_internal ();
7965}
8066
81- void GFComponent::setm (const String member, const Variant value) const {
67+ bool GFComponent::setm (const String member, const Variant value) const {
68+ if (!setm_no_notify (member, value)) {
69+ return false ;
70+ }
71+ ecs_modified_id (get_world ()->raw (), get_source_id (), get_id ());
72+ return true ;
73+ }
74+
75+ bool GFComponent::setm_no_notify (const String member, const Variant value) const {
8276 ecs_world_t * raw = get_world ()->raw ();
8377
8478 // Get member data
8579 const EcsMember* member_data = get_member_data (member);
8680 if (member_data == nullptr ) {
8781 // Member data is null. This should never happen.
88- ERR (/* */ ,
82+ ERR (false ,
8983 " Member metadata is null"
9084 );
9185 }
9286 void * member_ptr = get_member_ptr_mut_at (member_data->offset );
9387 if (member_ptr == nullptr ) {
94- ERR (/* */ ,
88+ ERR (false ,
9589 " Member pointer is null"
9690 );
9791 }
9892
99- // Return member
10093 Utils::set_type_from_variant (value, member_data->type , raw, member_ptr);
101- ecs_modified_id ( get_world ()-> raw (), get_source_id (), get_id ()) ;
94+ return true ;
10295}
10396
10497Variant GFComponent::getm (const String member) const {
@@ -412,11 +405,12 @@ void GFComponent::_bind_methods() {
412405 GDVIRTUAL_BIND (_build, " b" );
413406 godot::ClassDB::bind_method (D_METHOD (" _register_internal" ), &GFComponent::_register_internal);
414407
415- godot::ClassDB::bind_static_method (GFComponent:: get_class_static (), D_METHOD (" from" , " component" , " world" ), &GFComponent::from, nullptr );
416- godot::ClassDB::bind_static_method (GFComponent:: get_class_static (), D_METHOD (" from_id" , " id" , " world" ), &GFComponent::from_id, nullptr );
408+ godot::ClassDB::bind_static_method (get_class_static (), D_METHOD (" from" , " component" , " world" ), &GFComponent::from, nullptr );
409+ godot::ClassDB::bind_static_method (get_class_static (), D_METHOD (" from_id" , " id" , " world" ), &GFComponent::from_id, nullptr );
417410
418411 godot::ClassDB::bind_method (D_METHOD (" getm" , " member" ), &GFComponent::getm);
419412 godot::ClassDB::bind_method (D_METHOD (" setm" , " member" , " value" ), &GFComponent::setm);
413+ godot::ClassDB::bind_method (D_METHOD (" setm_no_notify" , " member" , " value" ), &GFComponent::setm_no_notify);
420414
421415 godot::ClassDB::bind_method (D_METHOD (" get_source_entity" ), &GFComponent::get_source_entity);
422416 godot::ClassDB::bind_method (D_METHOD (" get_source_id" ), &GFComponent::get_source_id);
0 commit comments