Open GoogleCodeExporter opened 9 years ago
The Bag is used in Artemis to ensure high performance, but it does not have
objects ordered by the insertion order.
The EntitySystem has two methods, inserted() and removed(), which you can
override, and there you can put the entities into an ordered collection like
ArrayList inside your system. A bit of a duplication, but solves the issue.
I do this here:
http://code.google.com/p/spaceship-warrior/source/browse/src/com/gamadu/spaceshi
pwarrior/systems/SpriteRenderSystem.java
I'm looking into how to add ordered support into Artemis without sacrificing
performance. Not sure when I'll add it.
Original comment by arniar...@gmail.com
on 2 Sep 2012 at 2:56
Why not order only systems, and only to some level?
From API point of view, for my needs something like
world.setSystem(..., false, order (int with default 0))
would be enough - and then for certain "order" value, the order of calls does
not matter, but one could place some systems (especially render ones) on higher
levels. About implementation, I'm wasn't thinking about it yet (Array of
Bag<EntitySystem> maybe? no idea), but I believe, that:
1) it is enough to solve most cases when we would want ordered processing -
including original issue (UseShaderProgramSystem updated before any other
rendering related systems), although it wouldn't solve everything (cases when
one needs ordered entities, like in SpriteRenderSystem example posted)
2) it does not break compatibility with current code (in old code all would be
in same "order" at level 0 (default), so it would be same behaviour - at the
price of maybe single check per world.process to access element of Array (or
something else) containing Bag with EntitySystems)
3) seems to be potentially faster than fully ordered approach
4) requires least work to solve the issue
what do you think?
Original comment by ggi...@gmail.com
on 1 Jan 2013 at 10:10
Original issue reported on code.google.com by
robertma...@gmail.com
on 12 Aug 2012 at 4:22