How can get one remove Component from entities.getRemovedEntities()?

how can get one remove Component from entities.getRemovedEntities()?

    entities.getAddedEntities().forEach((entity -> {
        NodeComponent component = entity.get(NodeComponent.class);
        Node value = component.getValue();
        scene.attachChild(value);
    }));


    entities.getRemovedEntities().forEach(entity -> {
        NodeComponent component = entity.get(NodeComponent.class);
        Node value = component.getValue();
        scene.detachChild(value);
    });

this code will get NPE !

I assume now that you are talking about the Zay-ES. You really don’t give any information on what is what.

So the answer is you can’t. The data is gone. I can just guess that you have this NodeComponent that has an actual graphical node reference in it? Or maybe a node index? Anyway, this design is not really good. To manage you scene graph, you could use an AppState. The AppState can link (hashmap) EntityIDs to Nodes. The EntityID should still be available when it is removed.

Or then you can use the EntityContainer to do this management.

it is Zay-ES!
if i cant get the removed Component from EntitySet.getRemovedEntities()
so what is the useful of EntitySet.getRemovedEntities()?

You still get the ID. You just need to have the bookkeeping elsewhere…

ok maybe the zay-es need give a Entity.getRemovedComponent(), like other ECS lib

It doesn’t know what the removed component is. There could be a bunch of removed components all at once that removed the entity from the set.

But already you should not be putting your scene graph into your components. It’s like storing a UI text field directly into the database. It doesn’t really make sense.

The SiO2 library has a utility class (EntityContainer) that makes these sorts of UI-code → entity management situations easier. Here is an example from one of the sim-ethereal demos: