bevyengine/bevy

API for dynamic management of systems (adding and removing at runtime)

inodentry opened this issue ยท 10 comments

It would be great to have a way to remove and add systems to the ECS as the game is running.

MNTRA commented

Agreed, maybe a version of add_system(...) that also takes a predicate that only runs the system if the predicate returns true?
Something along the lines of this.

    app.add_system_with_pred(my_system.system(), |my_resource| {
           /* code that returns bool */
    });

I know there's been discussion of the possibility of multiple schedulers, or having systems run based on some kind of condition. Related: #128

Agreed, maybe a version of add_system(...) that also takes a predicate that only runs the system if the predicate returns true?

"Run criteria" is the name for the tool that we ended up using for this.

#2507 is an initial attempt to add support for true dynamic schedule modifications.

Well, "true dynamic schedule modifications" would be infinitely more flexible than run criteria. Makes sense to keep this issue open for that.

From #2192 by @cart:

To add to this: I think we should have a way to queue runs of systems (in the same stage as the queuing system or some future stage) via their labels. This is slightly different than disabling and enabling at runtime, because queuing twice should result in two runs of the system.

(I agree with this position, I'm cross-posting it here so we can track the feature requirements a bit better) for #2801.

Closing as duplicate of #2192 + #142.

That was a mistake; this is much better scoped than #142...

It seems we still lack the dynamic removing systems ability. Is that planned to be implemented?

It's controversial, but we're leaning towards including it with warnings on the performance cost of doing so.

hymm commented

I think a fairly uncontroversial first step towards this is to add a method to Schedule to get a Vec's using a SystemSet label. The next step after that would be to try and use that method to remove those systems. The tricky bit here is what to do it that set is connected to other systems. I suspect we'll want some configuration here to by default return an error, but let people ignore the error and remove the dangling edges when wanted. Probably some complexity here around plugins that we'll need to iterate on.