Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a resources_present run condition #8710

Open
alice-i-cecile opened this issue May 29, 2023 · 2 comments
Open

Add a resources_present run condition #8710

alice-i-cecile opened this issue May 29, 2023 · 2 comments
Labels
A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use

Comments

@alice-i-cecile
Copy link
Member

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 in common_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.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use labels May 29, 2023
@AnthonyKalaitzis
Copy link
Contributor

AnthonyKalaitzis commented Jul 3, 2023

@alice-i-cecile Wouldn't mind giving this one a go if no one else is doing it

@alice-i-cecile
Copy link
Member Author

Awesome, please feel free! Ask around in #ecs-dev if you get stuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

2 participants