ComponentManager.addComponent() should check for existence of component as part of the entity and recycle the old component before setting the new one.
To reproduce:
Entity e = world.createEntity();
C c = world.createComponent(C.class);
e.addComponent(c);
world.addEntity(e);
....
C c2 = world.createComponent(C.class);
e.addComponent(c2);
c will be garbage collected instead of being returned to the pool.
ComponentManager.addComponent() should check for existence of component as part of the entity and recycle the old component before setting the new one.
To reproduce:
Entity e = world.createEntity(); C c = world.createComponent(C.class); e.addComponent(c); world.addEntity(e); .... C c2 = world.createComponent(C.class); e.addComponent(c2);
c will be garbage collected instead of being returned to the pool.