libgdx/ashley

order of systems changes after removing a system from the engine

Heerdam opened this issue · 1 comments

Engine.class line 80:
systems = new Array<EntitySystem>(false, 16);

In the comments of the Array it says:

ordered If false, methods that remove elements may change the order of other elements in the array, which avoids a memory copy.

thus, after removing a system it may or may not change order. I think in the Engine.removeSystem(EntitySystem system) a re-sorting would be in order.

Good spot.

We could either sort the array again after every removal, which would beO(nlogn) or instantiate the systems array as sorted, which makes removals O(n).

I'd be inclined to choose the second option.

Will try to reproduce this reliable in a test case and fix it.