EntityListner issue
xa4atur opened this issue · 4 comments
I use EntityListner to get notification when I add/remove a component to/from an entity. But I don't get notification in method entityAdded of EntityListner when I add a component to an entity which had been added before. Is that a bug or is it intended behavior?
see https://github.com/libgdx/ashley/blob/master/ashley/src/com/badlogic/ashley/core/Entity.java#L179
It seams to be an intended behavior if you add the same object twice, listener won't be called. If you add a different object of same component type, listeners will be called.
I add the same component but not the same object. There are different instances of the same component. On adding a component the old component if it exists it will be removed see Entity.java line 183.
When I add a component for the first time addListenerBits in method updateFamilyMembership of FamilyManager class is filled correctly. But when I add the another instance of the same component addListnerBits is not filled at all, because varibale belongsToFamily is equal to variable matches and is equal to TRUE see FamilyManager.java line 96.
I assumed if a component is removed then added again appropriate events should be raised but they are not raised.
It is crucial for my game to find out is this intended behavior or it is a bug.
could you provide a JUnit test case (as short as possible) it would help understand the context, specially when you remove / add components and when you expect listener to be called.