Closed nimble0 closed 1 week ago
Describe the bug Observers don't trigger for override components added from a prefab. Behaviour is as expected in v3.2.11.
To Reproduce Edited flecs/examples/cpp/prefabs/src/main.cpp
flecs/examples/cpp/prefabs/src/main.cpp
#include <basics.h> #include <iostream> struct Defense { double value; }; struct Armour { double value; }; int main() { flecs::world ecs; // inherited components trigger observer //ecs.component<Defense>().add(flecs::OnInstantiate, flecs::Inherit); //ecs.component<Armour>().add(flecs::OnInstantiate, flecs::Inherit); ecs.observer<const Defense, Armour>("CalculateArmour") .event(flecs::OnSet) .each([&](const Defense& defense, Armour& armour) { armour.value = 1.0 / defense.value; std::cout << "observer trigger\n"; }); // Create a SpaceShip prefab with a Defense component. std::cout << "make prefab\n"; flecs::entity SpaceShip = ecs.prefab("SpaceShip") .set<Defense>({ 50 }) .set(Armour{}); // Create a prefab instance std::cout << "make prefab instance\n"; flecs::entity inst = ecs.entity("my_spaceship").is_a(SpaceShip); // calling modified triggers the observer as expected //inst.modified<Armour>(); }
Expected output (v3.2.11)
make prefab make prefab instance observer trigger
Actual output
make prefab make prefab instance
Fixed!
Describe the bug Observers don't trigger for override components added from a prefab. Behaviour is as expected in v3.2.11.
To Reproduce Edited
flecs/examples/cpp/prefabs/src/main.cpp
Expected output (v3.2.11)
make prefab make prefab instance observer trigger
Actual output
make prefab make prefab instance