Skip systems that require a non-existing resource instead of panicking. #1604
Labels
A-ECS
Entities, components, systems, and events
C-Docs
An addition or correction to our documentation
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
What problem does this solve or what need does it fill?
Right now (release 0.4.0), when a system is registered that requires are resource. and that resource is not yet inserted, then you get a panic. I propose that the scheduler would simply skip systems whose resource needs are unfulfilled instead of panicking.
This would make it easy to keep systems registered, even though they might occasionally not be useful. For example:
I have a permanently registered network polling system, which requires a Socket resource.
In the main menu the user must select Join or Host, and after this choice a Socket is added as resource.
What solution would you like?
Let the scheduler skip systems whose resource needs are not met.
What alternative(s) have you considered?
Only run the required systems in specific app states where you know that the resource will be available. However, this is not ideal, since the app states are app-specific, which would disallow me to bundle my networking logic in a separate module or crate and make a bevy Plugin out of it.
Additional context
I was expecting this behaviour since I wanted to make something similar to amethyst_networking for bevy. In amethyst_networking you simple include a NetworkBundle which registers all sorts of polling systems for you. They automatically kick into action when you insert the resource for the socket manually.
I saw that in 0.5 a rewrite of the resources is coming, so excuse me if this issue is already solved for 0.5!
Really enjoying Bevy so far. Thanks a lot :)
The text was updated successfully, but these errors were encountered: