Closed pavelvasev closed 9 months ago
I've definitely thought about adding a priority system but I haven't given it much careful thought yet.. Something like this could work.
If you need to re-order the systems right now, you can adjust the values in world.systems
:
const world = ECS.createWorld()
// swap order of systems 0 and 2
const tmp = world.systems[0]
world.systems[0] = world.systems[2]
world.systems[2] = tmp
Mike thank you for explaining the work-around!
Still open to supporting this if you'd like to PR. :)
I'm closing this for now because I think one can achieve this by ordering how systems are added to the ECS instance.
Today's behavior, which is easy-ish to reason about:
// initial setup
ECS.addSystem(world, system1)
ECS.addSystem(world, system2)
// later, in the sim loop...
ECS.update(world, dt) // invocation order is system1.onUpdate then system2.onUpdate
That said I'm open to considering it if anyone comes along and feels they must have it.
Hi Mike!
In my case there is a need to specify priorities for systems. I understand that there are
onFixedUpdate, onPreUpdate,onUpdate,onPostUpdate
order, thus priorities (4 ones) are already presented. But I think it will be more usable to use digital priorities. For example:Actually I need all these just to catch
added
andremoved
"events" carefully. Probably there are other solutions.One of solution I see is to add a system in a correct order. However in my case it is not an option, because I would like to add systems dynamically via GUI.
One of caveat with approach of specifiyng priority in addSystem is an inability to change that priority dinamically. Aside that it breaks your super-elegant optionless design. Probably better way will be something like this:
What do you think about that?