-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Merged by Bors] - Add example for run conditions #7652
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
// this is useful for small, simple run conditions you don't need to reuse. | ||
// All the normal rules still apply, all parameters must be read only except for local parameters | ||
// In this case we will only run if the input counter resource exists and has changed but not just been added | ||
.run_if(|res: Option<Res<InputCounter>>| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct in thinking that once #7605 in merged we could do something like this?
.run_if(resource_exists::<InputCounter>())
.and_then(|counter: Res<InputCounter>| counter.is_changed() && !counter.is_added())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, precisely :) Interestingly, the short circuiting nature would make sure that the second run condition doesn't panic. That's nice.
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I'm happy with this, I just have a few grammar nitpicks.
Co-authored-by: JoJoJet <21144246+JoJoJet@users.noreply.github.com>
bors r+ |
Timed out. |
Github plz. bors r+ |
Pull request successfully merged into main. Build succeeded:
|
Added an example for run conditions. Fixes bevyengine#7646 if we wait till bevyengine#7605 is merged and include some of it features.
Added an example for run conditions. Fixes #7646 if we wait till #7605 is merged and include some of it features.