Skip to content

Commit a18519f

Browse files
DJMcNabaevyrie
authored andcommitted
Remove unnecessary system labels (bevyengine#4340)
# Objective - Since bevyengine#4224, using labels which only refer to one system doesn't make sense. ## Solution - Remove some of those. ## Future work - We should remove the ability to use strings as system labels entirely. I haven't in this PR because there are tests which use this, and that's a lot of code to change. - The only use cases for labels are either intra-crate, which use bevyengine#4224, or inter-crate, which should either use bevyengine#4224 or explicit types. Neither of those should use strings.
1 parent d121b9c commit a18519f

File tree

7 files changed

+25
-54
lines changed

7 files changed

+25
-54
lines changed

crates/bevy_ecs/examples/events.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ fn main() {
2121

2222
// Add systems sending and receiving events to a "second" Stage
2323
let mut second = SystemStage::parallel();
24-
second.add_system(sending_system.label(EventSystem::Sending));
25-
second.add_system(receiving_system.after(EventSystem::Sending));
24+
second.add_system(sending_system);
25+
second.add_system(receiving_system.after(sending_system));
2626

2727
// Run the "second" Stage after the "first" Stage, so our Events always get updated before we use them
2828
schedule.add_stage_after("first", "second", second);
@@ -34,12 +34,6 @@ fn main() {
3434
}
3535
}
3636

37-
// System label to enforce a run order of our systems
38-
#[derive(SystemLabel, Debug, Clone, PartialEq, Eq, Hash)]
39-
enum EventSystem {
40-
Sending,
41-
}
42-
4337
// This is our event that we will send and receive in systems
4438
struct MyEvent {
4539
pub message: String,

crates/bevy_ecs/examples/resources.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn main() {
1616
let mut update = SystemStage::parallel();
1717

1818
// Add systems to increase the counter and to print out the current value
19-
update.add_system(increase_counter.label(CounterSystem::Increase));
20-
update.add_system(print_counter.after(CounterSystem::Increase));
19+
update.add_system(increase_counter);
20+
update.add_system(print_counter.after(increase_counter));
2121
schedule.add_stage("update", update);
2222

2323
for iteration in 1..=10 {
@@ -32,12 +32,6 @@ struct Counter {
3232
pub value: i32,
3333
}
3434

35-
// System label to enforce a run order of our systems
36-
#[derive(SystemLabel, Debug, Clone, PartialEq, Eq, Hash)]
37-
enum CounterSystem {
38-
Increase,
39-
}
40-
4135
fn increase_counter(mut counter: ResMut<Counter>) {
4236
if rand::thread_rng().gen_bool(0.5) {
4337
counter.value += 1;

examples/2d/many_sprites.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ fn main() {
1717
.add_plugin(FrameTimeDiagnosticsPlugin::default())
1818
.add_plugins(DefaultPlugins)
1919
.add_startup_system(setup)
20-
.add_system(print_sprite_count.label("Tick"))
21-
.add_system(move_camera.after("Tick"))
20+
.add_system(print_sprite_count)
21+
.add_system(move_camera.after(print_sprite_count))
2222
.run();
2323
}
2424

examples/ecs/custom_query_param.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,10 @@ use std::{fmt::Debug, marker::PhantomData};
2020
fn main() {
2121
App::new()
2222
.add_startup_system(spawn)
23-
.add_system(print_components_read_only.label("print_components_read_only"))
24-
.add_system(
25-
print_components_iter_mut
26-
.label("print_components_iter_mut")
27-
.after("print_components_read_only"),
28-
)
29-
.add_system(
30-
print_components_iter
31-
.label("print_components_iter")
32-
.after("print_components_iter_mut"),
33-
)
34-
.add_system(print_components_tuple.after("print_components_iter"))
23+
.add_system(print_components_read_only)
24+
.add_system(print_components_iter_mut.after(print_components_read_only))
25+
.add_system(print_components_iter.after(print_components_iter_mut))
26+
.add_system(print_components_tuple.after(print_components_iter))
3527
.run();
3628
}
3729

examples/ecs/ecs_guide.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,6 @@ enum MyStage {
255255
AfterRound,
256256
}
257257

258-
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemLabel)]
259-
enum MyLabels {
260-
ScoreCheck,
261-
}
262-
263258
// Our Bevy app's entry point
264259
fn main() {
265260
// Bevy apps are created using the builder pattern. We use the builder to add systems,
@@ -331,22 +326,18 @@ fn main() {
331326
.add_system_to_stage(MyStage::BeforeRound, new_player_system)
332327
.add_system_to_stage(
333328
MyStage::BeforeRound,
329+
// Systems which take `&mut World` as an argument must call `.exclusive_system()`.
330+
// The following will not compile.
331+
//.add_system_to_stage(MyStage::BeforeRound, exclusive_player_system)
334332
exclusive_player_system.exclusive_system(),
335333
)
336-
// Systems which take `&mut World` as an argument must call `.exclusive_system()`.
337-
// The following will not compile.
338-
//.add_system_to_stage(MyStage::BeforeRound, exclusive_player_system)
339-
//
340-
// We can ensure that game_over system runs after score_check_system using explicit ordering
341-
// constraints First, we label the system we want to refer to using `.label`
342-
// Then, we use either `.before` or `.after` to describe the order we want the relationship
343-
.add_system_to_stage(
344-
MyStage::AfterRound,
345-
score_check_system.label(MyLabels::ScoreCheck),
346-
)
334+
.add_system_to_stage(MyStage::AfterRound, score_check_system)
347335
.add_system_to_stage(
336+
// We can ensure that `game_over_system` runs after `score_check_system` using explicit ordering
337+
// To do this we use either `.before` or `.after` to describe the order we want the relationship
338+
// Since we are using `after`, `game_over_system` runs after `score_check_system`
348339
MyStage::AfterRound,
349-
game_over_system.after(MyLabels::ScoreCheck),
340+
game_over_system.after(score_check_system),
350341
)
351342
// We can check our systems for execution order ambiguities by examining the output produced
352343
// in the console by using the `LogPlugin` and adding the following Resource to our App :)

examples/tools/scene_viewer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ Controls:
4545
.add_startup_system(setup)
4646
.add_system_to_stage(CoreStage::PreUpdate, scene_load_check)
4747
.add_system_to_stage(CoreStage::PreUpdate, camera_spawn_check)
48-
.add_system(camera_controller_check.label(CameraControllerCheckSystem))
48+
.add_system(check_camera_controller)
4949
.add_system(update_lights)
50-
.add_system(camera_controller.after(CameraControllerCheckSystem))
50+
.add_system(camera_controller.after(check_camera_controller))
5151
.run();
5252
}
5353

@@ -221,7 +221,7 @@ fn camera_spawn_check(
221221
}
222222
}
223223

224-
fn camera_controller_check(
224+
fn check_camera_controller(
225225
mut commands: Commands,
226226
camera: Query<Entity, (With<Camera>, Without<CameraController>)>,
227227
mut found_camera: Local<bool>,

tests/how_to_test_systems.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ fn did_hurt_enemy() {
3232

3333
// Setup stage with our two systems
3434
let mut update_stage = SystemStage::parallel();
35-
update_stage.add_system(hurt_enemies.before("death"));
36-
update_stage.add_system(despawn_dead_enemies.label("death"));
35+
update_stage.add_system(hurt_enemies.before(despawn_dead_enemies));
36+
update_stage.add_system(despawn_dead_enemies);
3737

3838
// Setup test entities
3939
let enemy_id = world.spawn().insert(Enemy { hit_points: 5 }).id();
@@ -53,8 +53,8 @@ fn did_despawn_enemy() {
5353

5454
// Setup stage with our two systems
5555
let mut update_stage = SystemStage::parallel();
56-
update_stage.add_system(hurt_enemies.before("death"));
57-
update_stage.add_system(despawn_dead_enemies.label("death"));
56+
update_stage.add_system(hurt_enemies.before(despawn_dead_enemies));
57+
update_stage.add_system(despawn_dead_enemies);
5858

5959
// Setup test entities
6060
let enemy_id = world.spawn().insert(Enemy { hit_points: 1 }).id();

0 commit comments

Comments
 (0)