Skip to content

Commit b724a0f

Browse files
committed
Down with the system! (#2496)
# Objective - Remove all the `.system()` possible. - Check for remaining missing cases. ## Solution - Remove all `.system()`, fix compile errors - 32 calls to `.system()` remains, mostly internals, the few others should be removed after #2446
1 parent 234b2ef commit b724a0f

File tree

125 files changed

+544
-732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+544
-732
lines changed

benches/benches/bevy_ecs/stages.rs

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use bevy::ecs::{
2-
world::World,
32
schedule::{Stage, SystemStage},
43
system::{IntoSystem, Query},
4+
world::World,
55
};
66
use criterion::{criterion_group, criterion_main, Criterion};
77

@@ -29,7 +29,7 @@ fn empty_systems(criterion: &mut Criterion) {
2929
for amount in 0..5 {
3030
let mut stage = SystemStage::parallel();
3131
for _ in 0..amount {
32-
stage.add_system(empty.system());
32+
stage.add_system(empty);
3333
}
3434
run_stage(&mut stage, &mut world);
3535
group.bench_function(&format!("{:03}_systems", amount), |bencher| {
@@ -42,11 +42,11 @@ fn empty_systems(criterion: &mut Criterion) {
4242
let mut stage = SystemStage::parallel();
4343
for _ in 0..amount {
4444
stage
45-
.add_system(empty.system())
46-
.add_system(empty.system())
47-
.add_system(empty.system())
48-
.add_system(empty.system())
49-
.add_system(empty.system());
45+
.add_system(empty)
46+
.add_system(empty)
47+
.add_system(empty)
48+
.add_system(empty)
49+
.add_system(empty);
5050
}
5151
run_stage(&mut stage, &mut world);
5252
group.bench_function(&format!("{:03}_systems", 5 * amount), |bencher| {
@@ -85,15 +85,9 @@ fn busy_systems(criterion: &mut Criterion) {
8585
world.spawn_batch((0..ENTITY_BUNCH).map(|_| (A(0.0), B(0.0), C(0.0), E(0.0))));
8686
for system_amount in 0..5 {
8787
let mut stage = SystemStage::parallel();
88-
stage
89-
.add_system(ab.system())
90-
.add_system(cd.system())
91-
.add_system(ce.system());
88+
stage.add_system(ab).add_system(cd).add_system(ce);
9289
for _ in 0..system_amount {
93-
stage
94-
.add_system(ab.system())
95-
.add_system(cd.system())
96-
.add_system(ce.system());
90+
stage.add_system(ab).add_system(cd).add_system(ce);
9791
}
9892
run_stage(&mut stage, &mut world);
9993
group.bench_function(
@@ -142,15 +136,9 @@ fn contrived(criterion: &mut Criterion) {
142136
world.spawn_batch((0..ENTITY_BUNCH).map(|_| (C(0.0), D(0.0))));
143137
for system_amount in 0..5 {
144138
let mut stage = SystemStage::parallel();
145-
stage
146-
.add_system(s_0.system())
147-
.add_system(s_1.system())
148-
.add_system(s_2.system());
139+
stage.add_system(s_0).add_system(s_1).add_system(s_2);
149140
for _ in 0..system_amount {
150-
stage
151-
.add_system(s_0.system())
152-
.add_system(s_1.system())
153-
.add_system(s_2.system());
141+
stage.add_system(s_0).add_system(s_1).add_system(s_2);
154142
}
155143
run_stage(&mut stage, &mut world);
156144
group.bench_function(

crates/bevy_app/src/app.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{CoreStage, Events, Plugin, PluginGroup, PluginGroupBuilder, StartupStage};
22
use bevy_ecs::{
33
component::{Component, ComponentDescriptor},
4-
prelude::{FromWorld, IntoExclusiveSystem, IntoSystem},
4+
prelude::{FromWorld, IntoExclusiveSystem},
55
schedule::{
66
IntoSystemDescriptor, RunOnce, Schedule, Stage, StageLabel, State, SystemSet, SystemStage,
77
},
@@ -28,7 +28,7 @@ use bevy_utils::tracing::info_span;
2828
///
2929
/// fn main() {
3030
/// App::new()
31-
/// .add_system(hello_world_system.system())
31+
/// .add_system(hello_world_system)
3232
/// .run();
3333
/// }
3434
///
@@ -180,7 +180,7 @@ impl App {
180180
/// Adds a system that runs every time `app.update()` is called by the runner
181181
///
182182
/// Systems are the main building block in the Bevy ECS app model. You can define
183-
/// normal rust functions, and call `.system()` to make them be Bevy systems.
183+
/// normal rust functions, and use them as a Bevy system.
184184
///
185185
/// System functions can have parameters, through which one can query and
186186
/// mutate Bevy ECS states.
@@ -201,7 +201,7 @@ impl App {
201201
/// }
202202
///
203203
/// App::new()
204-
/// .add_system(my_system.system());
204+
/// .add_system(my_system);
205205
/// ```
206206
pub fn add_system<Params>(&mut self, system: impl IntoSystemDescriptor<Params>) -> &mut Self {
207207
self.add_system_to_stage(CoreStage::Update, system)
@@ -248,7 +248,7 @@ impl App {
248248
/// }
249249
///
250250
/// App::new()
251-
/// .add_startup_system(my_startup_system.system());
251+
/// .add_startup_system(my_startup_system);
252252
/// ```
253253
pub fn add_startup_system<Params>(
254254
&mut self,
@@ -335,7 +335,7 @@ impl App {
335335
T: Component,
336336
{
337337
self.insert_resource(Events::<T>::default())
338-
.add_system_to_stage(CoreStage::First, Events::<T>::update_system.system())
338+
.add_system_to_stage(CoreStage::First, Events::<T>::update_system)
339339
}
340340

341341
/// Inserts a resource to the current [App] and overwrites any resource previously added of the same type.

crates/bevy_app/src/ci_testing.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use serde::Deserialize;
22

33
use crate::{app::AppExit, App};
4-
use bevy_ecs::system::IntoSystem;
54

65
/// Configuration for automated testing on CI
76
#[derive(Deserialize)]
@@ -32,7 +31,7 @@ pub(crate) fn setup_app(app_builder: &mut App) -> &mut App {
3231
.expect("error deserializing CI testing configuration file");
3332
app_builder
3433
.insert_resource(config)
35-
.add_system(ci_testing_exit_after.system());
34+
.add_system(ci_testing_exit_after);
3635

3736
app_builder
3837
}

crates/bevy_asset/src/assets.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use crate::{
33
RefChange,
44
};
55
use bevy_app::{App, EventWriter, Events};
6-
use bevy_ecs::{
7-
system::{IntoSystem, ResMut},
8-
world::FromWorld,
9-
};
6+
use bevy_ecs::{system::ResMut, world::FromWorld};
107
use bevy_utils::HashMap;
118
use crossbeam_channel::Sender;
129
use std::fmt::Debug;
@@ -217,14 +214,8 @@ impl AddAsset for App {
217214
};
218215

219216
self.insert_resource(assets)
220-
.add_system_to_stage(
221-
AssetStage::AssetEvents,
222-
Assets::<T>::asset_event_system.system(),
223-
)
224-
.add_system_to_stage(
225-
AssetStage::LoadAssets,
226-
update_asset_storage_system::<T>.system(),
227-
)
217+
.add_system_to_stage(AssetStage::AssetEvents, Assets::<T>::asset_event_system)
218+
.add_system_to_stage(AssetStage::LoadAssets, update_asset_storage_system::<T>)
228219
.register_type::<Handle<T>>()
229220
.add_event::<AssetEvent<T>>()
230221
}

crates/bevy_asset/src/diagnostic/asset_count_diagnostics_plugin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{Asset, Assets};
22
use bevy_app::prelude::*;
33
use bevy_diagnostic::{Diagnostic, DiagnosticId, Diagnostics, MAX_DIAGNOSTIC_NAME_WIDTH};
4-
use bevy_ecs::system::{IntoSystem, Res, ResMut};
4+
use bevy_ecs::system::{Res, ResMut};
55

66
/// Adds "asset count" diagnostic to an App
77
pub struct AssetCountDiagnosticsPlugin<T: Asset> {
@@ -18,8 +18,8 @@ impl<T: Asset> Default for AssetCountDiagnosticsPlugin<T> {
1818

1919
impl<T: Asset> Plugin for AssetCountDiagnosticsPlugin<T> {
2020
fn build(&self, app: &mut App) {
21-
app.add_startup_system(Self::setup_system.system())
22-
.add_system(Self::diagnostic_system.system());
21+
app.add_startup_system(Self::setup_system)
22+
.add_system(Self::diagnostic_system);
2323
}
2424
}
2525

crates/bevy_asset/src/lib.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ pub use loader::*;
2727
pub use path::*;
2828

2929
use bevy_app::{prelude::Plugin, App};
30-
use bevy_ecs::{
31-
schedule::{StageLabel, SystemStage},
32-
system::IntoSystem,
33-
};
30+
use bevy_ecs::schedule::{StageLabel, SystemStage};
3431
use bevy_tasks::IoTaskPool;
3532

3633
/// The names of asset stages in an App Schedule
@@ -106,16 +103,13 @@ impl Plugin for AssetPlugin {
106103
.register_type::<HandleId>()
107104
.add_system_to_stage(
108105
bevy_app::CoreStage::PreUpdate,
109-
asset_server::free_unused_assets_system.system(),
106+
asset_server::free_unused_assets_system,
110107
);
111108

112109
#[cfg(all(
113110
feature = "filesystem_watcher",
114111
all(not(target_arch = "wasm32"), not(target_os = "android"))
115112
))]
116-
app.add_system_to_stage(
117-
AssetStage::LoadAssets,
118-
io::filesystem_watcher_system.system(),
119-
);
113+
app.add_system_to_stage(AssetStage::LoadAssets, io::filesystem_watcher_system);
120114
}
121115
}

crates/bevy_core/src/label.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ pub(crate) fn entity_labels_system(
123123
mod tests {
124124
use bevy_ecs::{
125125
schedule::{Schedule, Stage, SystemStage},
126-
system::IntoSystem,
127126
world::World,
128127
};
129128

@@ -134,7 +133,7 @@ mod tests {
134133
world.insert_resource(EntityLabels::default());
135134
let mut schedule = Schedule::default();
136135
schedule.add_stage("test", SystemStage::single_threaded());
137-
schedule.add_system_to_stage("test", entity_labels_system.system());
136+
schedule.add_system_to_stage("test", entity_labels_system);
138137
(world, schedule)
139138
}
140139

crates/bevy_core/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use bevy_app::prelude::*;
2121
use bevy_ecs::{
2222
entity::Entity,
2323
schedule::{ExclusiveSystemDescriptorCoercion, SystemLabel},
24-
system::{IntoExclusiveSystem, IntoSystem},
24+
system::IntoExclusiveSystem,
2525
};
2626
use bevy_utils::HashSet;
2727
use std::ops::Range;
@@ -62,8 +62,8 @@ impl Plugin for CorePlugin {
6262
CoreStage::First,
6363
time_system.exclusive_system().label(CoreSystem::Time),
6464
)
65-
.add_startup_system_to_stage(StartupStage::PostStartup, entity_labels_system.system())
66-
.add_system_to_stage(CoreStage::PostUpdate, entity_labels_system.system());
65+
.add_startup_system_to_stage(StartupStage::PostStartup, entity_labels_system)
66+
.add_system_to_stage(CoreStage::PostUpdate, entity_labels_system);
6767

6868
register_rust_types(app);
6969
register_math_types(app);

crates/bevy_core/src/time/fixed_timestep.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bevy_ecs::{
44
component::ComponentId,
55
query::Access,
66
schedule::ShouldRun,
7-
system::{IntoSystem, Local, Res, ResMut, System, SystemId},
7+
system::{ConfigurableSystem, IntoSystem, Local, Res, ResMut, System, SystemId},
88
world::World,
99
};
1010
use bevy_utils::HashMap;
@@ -179,11 +179,8 @@ impl System for FixedTimestep {
179179
}
180180

181181
fn initialize(&mut self, world: &mut World) {
182-
self.internal_system = Box::new(
183-
Self::prepare_system
184-
.system()
185-
.config(|c| c.0 = Some(self.state.clone())),
186-
);
182+
self.internal_system =
183+
Box::new(Self::prepare_system.config(|c| c.0 = Some(self.state.clone())));
187184
self.internal_system.initialize(world);
188185
if let Some(ref label) = self.state.label {
189186
let mut fixed_timesteps = world.get_resource_mut::<FixedTimesteps>().unwrap();

crates/bevy_diagnostic/src/entity_count_diagnostics_plugin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bevy_app::{App, Plugin};
22
use bevy_ecs::{
3-
system::{IntoExclusiveSystem, IntoSystem, ResMut},
3+
system::{IntoExclusiveSystem, ResMut},
44
world::World,
55
};
66

@@ -12,7 +12,7 @@ pub struct EntityCountDiagnosticsPlugin;
1212

1313
impl Plugin for EntityCountDiagnosticsPlugin {
1414
fn build(&self, app: &mut App) {
15-
app.add_startup_system(Self::setup_system.system())
15+
app.add_startup_system(Self::setup_system)
1616
.add_system(Self::diagnostic_system.exclusive_system());
1717
}
1818
}

crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{Diagnostic, DiagnosticId, Diagnostics};
22
use bevy_app::prelude::*;
33
use bevy_core::Time;
4-
use bevy_ecs::system::{IntoSystem, Res, ResMut};
4+
use bevy_ecs::system::{Res, ResMut};
55

66
/// Adds "frame time" diagnostic to an App, specifically "frame time", "fps" and "frame count"
77
#[derive(Default)]
@@ -13,9 +13,9 @@ pub struct FrameTimeDiagnosticsState {
1313

1414
impl Plugin for FrameTimeDiagnosticsPlugin {
1515
fn build(&self, app: &mut bevy_app::App) {
16-
app.add_startup_system(Self::setup_system.system())
16+
app.add_startup_system(Self::setup_system)
1717
.insert_resource(FrameTimeDiagnosticsState { frame_count: 0.0 })
18-
.add_system(Self::diagnostic_system.system());
18+
.add_system(Self::diagnostic_system);
1919
}
2020
}
2121

crates/bevy_diagnostic/src/log_diagnostics_plugin.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::{Diagnostic, DiagnosticId, Diagnostics};
22
use bevy_app::prelude::*;
33
use bevy_core::{Time, Timer};
4-
use bevy_ecs::system::{IntoSystem, Res, ResMut};
4+
use bevy_ecs::system::{Res, ResMut};
55
use bevy_log::{debug, info};
66
use bevy_utils::Duration;
77

@@ -36,12 +36,9 @@ impl Plugin for LogDiagnosticsPlugin {
3636
});
3737

3838
if self.debug {
39-
app.add_system_to_stage(
40-
CoreStage::PostUpdate,
41-
Self::log_diagnostics_debug_system.system(),
42-
);
39+
app.add_system_to_stage(CoreStage::PostUpdate, Self::log_diagnostics_debug_system);
4340
} else {
44-
app.add_system_to_stage(CoreStage::PostUpdate, Self::log_diagnostics_system.system());
41+
app.add_system_to_stage(CoreStage::PostUpdate, Self::log_diagnostics_system);
4542
}
4643
}
4744
}

crates/bevy_ecs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn main() {
131131
// Add a Stage to our schedule. Each Stage in a schedule runs all of its systems
132132
// before moving on to the next Stage
133133
schedule.add_stage("update", SystemStage::parallel()
134-
.with_system(movement.system())
134+
.with_system(movement)
135135
);
136136

137137
// Run the schedule once. If your app has a "loop", you would run this once per loop

crates/bevy_ecs/examples/change_detection.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,11 @@ fn main() {
2424

2525
// Add systems to the Stage to execute our app logic
2626
// We can label our systems to force a specific run-order between some of them
27-
update.add_system(spawn_entities.system().label(SimulationSystem::Spawn));
28-
update.add_system(
29-
print_counter_when_changed
30-
.system()
31-
.after(SimulationSystem::Spawn),
32-
);
33-
update.add_system(age_all_entities.system().label(SimulationSystem::Age));
34-
update.add_system(remove_old_entities.system().after(SimulationSystem::Age));
35-
update.add_system(print_changed_entities.system().after(SimulationSystem::Age));
27+
update.add_system(spawn_entities.label(SimulationSystem::Spawn));
28+
update.add_system(print_counter_when_changed.after(SimulationSystem::Spawn));
29+
update.add_system(age_all_entities.label(SimulationSystem::Age));
30+
update.add_system(remove_old_entities.after(SimulationSystem::Age));
31+
update.add_system(print_changed_entities.after(SimulationSystem::Age));
3632
// Add the Stage with our systems to the Schedule
3733
schedule.add_stage("update", update);
3834

crates/bevy_ecs/examples/component_storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222
// Setup a schedule and stage to add a system querying for the just spawned entities
2323
let mut schedule = Schedule::default();
2424
let mut update = SystemStage::parallel();
25-
update.add_system(query_entities.system());
25+
update.add_system(query_entities);
2626
schedule.add_stage("update", update);
2727

2828
schedule.run(&mut world);

crates/bevy_ecs/examples/events.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ fn main() {
1616
// called "second". In "first" we update the events and in "second" we run our systems
1717
// sending and receiving events.
1818
let mut first = SystemStage::parallel();
19-
first.add_system(Events::<MyEvent>::update_system.system());
19+
first.add_system(Events::<MyEvent>::update_system);
2020
schedule.add_stage("first", first);
2121

2222
// Add systems sending and receiving events to a "second" Stage
2323
let mut second = SystemStage::parallel();
24-
second.add_system(sending_system.system().label(EventSystem::Sending));
25-
second.add_system(receiving_system.system().after(EventSystem::Sending));
24+
second.add_system(sending_system.label(EventSystem::Sending));
25+
second.add_system(receiving_system.after(EventSystem::Sending));
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);

0 commit comments

Comments
 (0)