Add a resources_present
run condition
#8710
Labels
A-ECS
Entities, components, systems, and events
C-Usability
A simple quality-of-life change that makes Bevy easier to use
What problem does this solve or what need does it fill?
The
.run_if(resource_exists::<LateResource>())
run condition pattern is very helpful for avoiding silly panics when doing deferred resource initialization.However, the exact identity of the resource type(s) rarely matters. When you have multiple, you need to either combine run conditions, use an
Option<Res<T>>
system parameter, or write your own one-off run condition.What solution would you like?
Add a
resources_present
run condition, exported incommon_conditions
(and demonstrated with an example).This checks all of the resources requested, and validates that they each exist. If they all do, it returns true. Otherwise, false.
What alternative(s) have you considered?
It may be easier to check if all of the system parameters can be fetched. In that case, we should change the name to something like
system_param_exist
to better match the functionality.The text was updated successfully, but these errors were encountered: