-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
What problem does this solve or what need does it fill?
Doing some work based on the subapp changes in #2535 for bevy_ecs and bevy_app, and ran into a couple things. Though I understand they're heavy WIP still.
But regardless, it doesn't seem possible to manually execute all of the stages contained in a subapp's schedule. For example, in Render2, we currently fetch all the stages explicitly and run them - since we need to run the extract stage on another world. This means that if another plugin wants to add stages to the render subapp, they won't be executed - as far as I understand.
There's also no way to run the run_criteria check for when you're explicitly executing a schedule like this. Additionally, run_criteria can't be aware of the parent/extract world currently unless you inject that world ahead of time. That might be enough, but might be something to keep in mind with any solution.
What solution would you like?
A neat solution might be to add per-stage runners, or a SystemStageWithRunner type, though I'm not certain how you'd feed temporary state into them - still learning how far lifetimes can be pushed. In the case of Render2, the logic to run the on the parent's world would be implemented in the stage runner, and then just the subapp's run method could be called - removing the issue of run_criteria and mut iteration. This would allow the stage runner to attach the world before the run_criteria check.
What alternative(s) have you considered?
Currently I've implemented some escape-valve function in a fork. They allow me to call the run_criteria manually and iterate stages mutably. There's probably a much neater way to implement what I've attempted to implement, see additional context.
Only other plausible option that comes to mind to me is to push the "extract" stage logic down into bevy_ecs, so that bevy_app and subapp implementers don't need to concerns themselves with manual schedule execution. Probably be through the introduction of add_extract_system type methods, and some method to provide the "parent" world so that the extract stages can be run. This also makes things a lot more standardized and rigid, which may or may not be a plus in this situation.
Additional context
The fork implementation I mentioned can be found here:
https://github.com/butterscotch-rs/bevy/blob/81387d3ecfb1421d288a856c21c6da8a69f71151/crates/bevy_ecs/src/schedule/mod.rs#L216