Skip to content

Commit 428f5ba

Browse files
TehPersostwilkens
authored andcommitted
Updated docs for ShouldRun (bevyengine#1987)
The documentation for `ShouldRun` doesn't completely explain what each of the variants you can return does. For instance, it isn't very clear that looping systems aren't executed again until after all the systems in a stage have had a chance to run. This PR adds to the documentation for `ShouldRun`, and hopefully clarifies what is happening during a stage's execution when run criteria are checked and systems are being executed.
1 parent d78fa76 commit 428f5ba

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

crates/bevy_ecs/src/schedule/run_criteria.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,39 @@ use crate::{
88
};
99
use std::borrow::Cow;
1010

11+
/// Determines whether a system should be executed or not, and how many times it should be ran each
12+
/// time the stage is executed.
13+
///
14+
/// A stage will loop over its run criteria and systems until no more systems need to be executed
15+
/// and no more run criteria need to be checked.
16+
/// - Any systems with run criteria that returns [`Yes`] will be ran exactly one more time during
17+
/// the stage's execution that tick.
18+
/// - Any systems with run criteria that returns [`No`] are not ran for the rest of the stage's
19+
/// execution that tick.
20+
/// - Any systems with run criteria that returns [`YesAndCheckAgain`] will be ran during this
21+
/// iteration of the loop. After all the systems that need to run are ran, that criteria will be
22+
/// checked again.
23+
/// - Any systems with run criteria that returns [`NoAndCheckAgain`] will not be ran during this
24+
/// iteration of the loop. After all the systems that need to run are ran, that criteria will be
25+
/// checked again.
26+
///
27+
/// [`Yes`]: ShouldRun::Yes
28+
/// [`No`]: ShouldRun::No
29+
/// [`YesAndCheckAgain`]: ShouldRun::YesAndCheckAgain
30+
/// [`NoAndCheckAgain`]: ShouldRun::NoAndCheckAgain
1131
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1232
pub enum ShouldRun {
13-
/// Yes, the system should run.
33+
/// Yes, the system should run one more time this tick.
1434
Yes,
15-
/// No, the system should not run.
35+
/// No, the system should not run for the rest of this tick.
1636
No,
17-
/// Yes, the system should run, and afterwards the criteria should be checked again.
37+
/// Yes, the system should run, and after all systems in this stage have run, the criteria
38+
/// should be checked again. This will cause the stage to loop over the remaining systems and
39+
/// criteria this tick until they no longer need to be checked.
1840
YesAndCheckAgain,
19-
/// No, the system should not run right now, but the criteria should be checked again later.
41+
/// No, the system should not run right now, but after all systems in this stage have run, the
42+
/// criteria should be checked again. This will cause the stage to loop over the remaining
43+
/// systems and criteria this tick until they no longer need to be checked.
2044
NoAndCheckAgain,
2145
}
2246

0 commit comments

Comments
 (0)