Skip to content

Commit 1b44497

Browse files
committed
Fix panics in ecs_guide example (#7525)
# Objective Fixes #7565 `ecs_guide` example is currently panicking. This seems to just be a problem with the example only caused by the base sets PR. ## Solution First, changed a few `in_set` to `in_base_set` to fix a few of ``` thread 'main' panicked at 'Systems cannot be added to 'base' system sets using 'in_set'. Use 'in_base_set' instead.', examples/ecs/ecs_guide.rs:301:45 ``` And then added an `in_base_set` to fix the resulting (confusing) cycle error ``` 2023-02-06T13:54:29.213843Z ERROR bevy_ecs::schedule_v3::schedule: schedule contains at least 1 cycle(s) -- cycle(s) found within: ---- 0: ["ecs_guide::game_over_system", "ecs_guide::score_check_system"] ``` I also changed this `add_system` call so the comment above and below make sense: ```diff // add_system(system) adds systems to the Update system set by default // However we can manually specify the set if we want to. The following is equivalent to // add_system(score_system) - .add_system(score_system) + .add_system(score_system.in_base_set(CoreSet::Update)) // There are other `CoreSets`, such as `Last` which runs at the very end of each run. ``` ## Notes - Does `MySet` even need to be a base set? Seems like yes. - Is that cycle error when there is no explicit `in_base_set` actually expected?
1 parent 09cb590 commit 1b44497

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

examples/ecs/ecs_guide.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
2727
use bevy::{
2828
app::{AppExit, ScheduleRunnerPlugin, ScheduleRunnerSettings},
29-
log::LogPlugin,
3029
prelude::*,
3130
utils::Duration,
3231
};
@@ -282,7 +281,7 @@ fn main() {
282281
// add_system(system) adds systems to the Update system set by default
283282
// However we can manually specify the set if we want to. The following is equivalent to
284283
// add_system(score_system)
285-
.add_system(score_system)
284+
.add_system(score_system.in_base_set(CoreSet::Update))
286285
// There are other `CoreSets`, such as `Last` which runs at the very end of each run.
287286
.add_system(print_at_end_round.in_base_set(CoreSet::Last))
288287
// We can also create new system sets, and order them relative to other system sets.
@@ -298,19 +297,16 @@ fn main() {
298297
.after(new_round_system)
299298
.in_base_set(MySet::BeforeRound),
300299
)
301-
.add_system(exclusive_player_system.in_set(MySet::BeforeRound))
302-
.add_system(score_check_system.in_set(MySet::AfterRound))
300+
.add_system(exclusive_player_system.in_base_set(MySet::BeforeRound))
301+
.add_system(score_check_system.in_base_set(MySet::AfterRound))
303302
.add_system(
304303
// We can ensure that `game_over_system` runs after `score_check_system` using explicit ordering
305304
// To do this we use either `.before` or `.after` to describe the order we want the relationship
306305
// Since we are using `after`, `game_over_system` runs after `score_check_system`
307-
game_over_system.after(score_check_system),
306+
game_over_system
307+
.after(score_check_system)
308+
.in_base_set(MySet::AfterRound),
308309
)
309-
// We can check our systems for execution order ambiguities by examining the output produced
310-
// in the console by using the `LogPlugin` and adding the following Resource to our App :)
311-
// Be aware that not everything reported by this checker is a potential problem, you'll have
312-
// to make that judgement yourself.
313-
.add_plugin(LogPlugin::default())
314310
// This call to run() starts the app we just built!
315311
.run();
316312
}

0 commit comments

Comments
 (0)