apotapov / gdx-artemis

Fork of artemis entity-system (http://gamadu.com/artemis/) refactored to integrate with Libgdx (http://libgdx.badlogicgames.com/)
Other
53 stars 5 forks source link

ComponentManager does not Recycle components correctly when replacing. #25

Closed apotapov closed 10 years ago

apotapov commented 10 years ago

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.