Replace multiple calls to add_system with add_systems (#8001)

This commit is contained in:
JoJoJet 2023-03-10 13:15:22 -05:00 committed by GitHub
parent 729458815c
commit fd1af7c8b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
124 changed files with 505 additions and 540 deletions

View file

@ -21,12 +21,7 @@ pub fn run_condition_yes(criterion: &mut Criterion) {
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(empty.run_if(yes)); schedule.add_system(empty.run_if(yes));
for _ in 0..amount { for _ in 0..amount {
schedule schedule.add_systems((empty, empty, empty, empty, empty).distributive_run_if(yes));
.add_system(empty.run_if(yes))
.add_system(empty.run_if(yes))
.add_system(empty.run_if(yes))
.add_system(empty.run_if(yes))
.add_system(empty.run_if(yes));
} }
// run once to initialize systems // run once to initialize systems
schedule.run(&mut world); schedule.run(&mut world);
@ -49,12 +44,7 @@ pub fn run_condition_no(criterion: &mut Criterion) {
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(empty.run_if(no)); schedule.add_system(empty.run_if(no));
for _ in 0..amount { for _ in 0..amount {
schedule schedule.add_systems((empty, empty, empty, empty, empty).distributive_run_if(no));
.add_system(empty.run_if(no))
.add_system(empty.run_if(no))
.add_system(empty.run_if(no))
.add_system(empty.run_if(no))
.add_system(empty.run_if(no));
} }
// run once to initialize systems // run once to initialize systems
schedule.run(&mut world); schedule.run(&mut world);
@ -84,12 +74,9 @@ pub fn run_condition_yes_with_query(criterion: &mut Criterion) {
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(empty.run_if(yes_with_query)); schedule.add_system(empty.run_if(yes_with_query));
for _ in 0..amount { for _ in 0..amount {
schedule schedule.add_systems(
.add_system(empty.run_if(yes_with_query)) (empty, empty, empty, empty, empty).distributive_run_if(yes_with_query),
.add_system(empty.run_if(yes_with_query)) );
.add_system(empty.run_if(yes_with_query))
.add_system(empty.run_if(yes_with_query))
.add_system(empty.run_if(yes_with_query));
} }
// run once to initialize systems // run once to initialize systems
schedule.run(&mut world); schedule.run(&mut world);
@ -116,12 +103,9 @@ pub fn run_condition_yes_with_resource(criterion: &mut Criterion) {
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(empty.run_if(yes_with_resource)); schedule.add_system(empty.run_if(yes_with_resource));
for _ in 0..amount { for _ in 0..amount {
schedule schedule.add_systems(
.add_system(empty.run_if(yes_with_resource)) (empty, empty, empty, empty, empty).distributive_run_if(yes_with_resource),
.add_system(empty.run_if(yes_with_resource)) );
.add_system(empty.run_if(yes_with_resource))
.add_system(empty.run_if(yes_with_resource))
.add_system(empty.run_if(yes_with_resource));
} }
// run once to initialize systems // run once to initialize systems
schedule.run(&mut world); schedule.run(&mut world);

View file

@ -35,12 +35,7 @@ pub fn empty_systems(criterion: &mut Criterion) {
for amount in 1..21 { for amount in 1..21 {
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
for _ in 0..amount { for _ in 0..amount {
schedule schedule.add_systems((empty, empty, empty, empty, empty));
.add_system(empty)
.add_system(empty)
.add_system(empty)
.add_system(empty)
.add_system(empty);
} }
schedule.run(&mut world); schedule.run(&mut world);
group.bench_function(&format!("{:03}_systems", 5 * amount), |bencher| { group.bench_function(&format!("{:03}_systems", 5 * amount), |bencher| {
@ -79,9 +74,9 @@ pub fn busy_systems(criterion: &mut Criterion) {
world.spawn_batch((0..ENTITY_BUNCH).map(|_| (A(0.0), B(0.0), C(0.0), E(0.0)))); world.spawn_batch((0..ENTITY_BUNCH).map(|_| (A(0.0), B(0.0), C(0.0), E(0.0))));
for system_amount in 0..5 { for system_amount in 0..5 {
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(ab).add_system(cd).add_system(ce); schedule.add_systems((ab, cd, ce));
for _ in 0..system_amount { for _ in 0..system_amount {
schedule.add_system(ab).add_system(cd).add_system(ce); schedule.add_systems((ab, cd, ce));
} }
schedule.run(&mut world); schedule.run(&mut world);
group.bench_function( group.bench_function(
@ -130,9 +125,9 @@ pub fn contrived(criterion: &mut Criterion) {
world.spawn_batch((0..ENTITY_BUNCH).map(|_| (C(0.0), D(0.0)))); world.spawn_batch((0..ENTITY_BUNCH).map(|_| (C(0.0), D(0.0))));
for system_amount in 0..5 { for system_amount in 0..5 {
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(s_0).add_system(s_1).add_system(s_2); schedule.add_systems((s_0, s_1, s_2));
for _ in 0..system_amount { for _ in 0..system_amount {
schedule.add_system(s_0).add_system(s_1).add_system(s_2); schedule.add_systems((s_0, s_1, s_2));
} }
schedule.run(&mut world); schedule.run(&mut world);
group.bench_function( group.bench_function(

View file

@ -47,9 +47,7 @@ pub fn schedule(c: &mut Criterion) {
world.spawn_batch((0..10000).map(|_| (A(0.0), B(0.0), C(0.0), E(0.0)))); world.spawn_batch((0..10000).map(|_| (A(0.0), B(0.0), C(0.0), E(0.0))));
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(ab); schedule.add_systems((ab, cd, ce));
schedule.add_system(cd);
schedule.add_system(ce);
schedule.run(&mut world); schedule.run(&mut world);
b.iter(move || schedule.run(&mut world)); b.iter(move || schedule.run(&mut world));

View file

@ -33,8 +33,8 @@ pub mod prelude {
use bevy_ecs::{ use bevy_ecs::{
schedule::{ schedule::{
apply_system_buffers, IntoSystemConfig, IntoSystemSetConfig, IntoSystemSetConfigs, apply_system_buffers, IntoSystemConfig, IntoSystemSetConfigs, Schedule, ScheduleLabel,
Schedule, ScheduleLabel, SystemSet, SystemSet,
}, },
system::Local, system::Local,
world::World, world::World,
@ -136,11 +136,13 @@ impl CoreSet {
// Create "stage-like" structure using buffer flushes + ordering // Create "stage-like" structure using buffer flushes + ordering
schedule schedule
.set_default_base_set(Update) .set_default_base_set(Update)
.add_system(apply_system_buffers.in_base_set(FirstFlush)) .add_systems((
.add_system(apply_system_buffers.in_base_set(PreUpdateFlush)) apply_system_buffers.in_base_set(FirstFlush),
.add_system(apply_system_buffers.in_base_set(UpdateFlush)) apply_system_buffers.in_base_set(PreUpdateFlush),
.add_system(apply_system_buffers.in_base_set(PostUpdateFlush)) apply_system_buffers.in_base_set(UpdateFlush),
.add_system(apply_system_buffers.in_base_set(LastFlush)) apply_system_buffers.in_base_set(PostUpdateFlush),
apply_system_buffers.in_base_set(LastFlush),
))
.configure_sets( .configure_sets(
( (
First, First,
@ -197,13 +199,23 @@ impl StartupSet {
schedule.set_default_base_set(Startup); schedule.set_default_base_set(Startup);
// Create "stage-like" structure using buffer flushes + ordering // Create "stage-like" structure using buffer flushes + ordering
schedule.add_system(apply_system_buffers.in_base_set(PreStartupFlush)); schedule.add_systems((
schedule.add_system(apply_system_buffers.in_base_set(StartupFlush)); apply_system_buffers.in_base_set(PreStartupFlush),
schedule.add_system(apply_system_buffers.in_base_set(PostStartupFlush)); apply_system_buffers.in_base_set(StartupFlush),
apply_system_buffers.in_base_set(PostStartupFlush),
));
schedule.configure_set(PreStartup.before(PreStartupFlush)); schedule.configure_sets(
schedule.configure_set(Startup.after(PreStartupFlush).before(StartupFlush)); (
schedule.configure_set(PostStartup.after(StartupFlush).before(PostStartupFlush)); PreStartup,
PreStartupFlush,
Startup,
StartupFlush,
PostStartup,
PostStartupFlush,
)
.chain(),
);
schedule schedule
} }

View file

@ -852,8 +852,10 @@ mod test {
let mut app = App::new(); let mut app = App::new();
app.insert_resource(assets); app.insert_resource(assets);
app.insert_resource(asset_server); app.insert_resource(asset_server);
app.add_system(free_unused_assets_system.in_set(FreeUnusedAssets)); app.add_systems((
app.add_system(update_asset_storage_system::<PngAsset>.after(FreeUnusedAssets)); free_unused_assets_system.in_set(FreeUnusedAssets),
update_asset_storage_system::<PngAsset>.after(FreeUnusedAssets),
));
fn load_asset(path: AssetPath, world: &World) -> HandleUntyped { fn load_asset(path: AssetPath, world: &World) -> HandleUntyped {
let asset_server = world.resource::<AssetServer>(); let asset_server = world.resource::<AssetServer>();

View file

@ -331,8 +331,10 @@ impl AddAsset for App {
}; };
self.insert_resource(assets) self.insert_resource(assets)
.add_system(Assets::<T>::asset_event_system.in_base_set(AssetSet::AssetEvents)) .add_systems((
.add_system(update_asset_storage_system::<T>.in_base_set(AssetSet::LoadAssets)) Assets::<T>::asset_event_system.in_base_set(AssetSet::AssetEvents),
update_asset_storage_system::<T>.in_base_set(AssetSet::LoadAssets),
))
.register_type::<Handle<T>>() .register_type::<Handle<T>>()
.add_event::<AssetEvent<T>>() .add_event::<AssetEvent<T>>()
} }

View file

@ -71,10 +71,12 @@ impl Plugin for BloomPlugin {
.init_resource::<BloomUpsamplingPipeline>() .init_resource::<BloomUpsamplingPipeline>()
.init_resource::<SpecializedRenderPipelines<BloomDownsamplingPipeline>>() .init_resource::<SpecializedRenderPipelines<BloomDownsamplingPipeline>>()
.init_resource::<SpecializedRenderPipelines<BloomUpsamplingPipeline>>() .init_resource::<SpecializedRenderPipelines<BloomUpsamplingPipeline>>()
.add_system(prepare_bloom_textures.in_set(RenderSet::Prepare)) .add_systems((
.add_system(prepare_downsampling_pipeline.in_set(RenderSet::Prepare)) prepare_bloom_textures.in_set(RenderSet::Prepare),
.add_system(prepare_upsampling_pipeline.in_set(RenderSet::Prepare)) prepare_downsampling_pipeline.in_set(RenderSet::Prepare),
.add_system(queue_bloom_bind_groups.in_set(RenderSet::Queue)); prepare_upsampling_pipeline.in_set(RenderSet::Prepare),
queue_bloom_bind_groups.in_set(RenderSet::Queue),
));
// Add bloom to the 3d render graph // Add bloom to the 3d render graph
{ {

View file

@ -52,13 +52,13 @@ impl Plugin for Core2dPlugin {
render_app render_app
.init_resource::<DrawFunctions<Transparent2d>>() .init_resource::<DrawFunctions<Transparent2d>>()
.add_system(extract_core_2d_camera_phases.in_schedule(ExtractSchedule)) .add_systems((
.add_system(sort_phase_system::<Transparent2d>.in_set(RenderSet::PhaseSort)) extract_core_2d_camera_phases.in_schedule(ExtractSchedule),
.add_system( sort_phase_system::<Transparent2d>.in_set(RenderSet::PhaseSort),
batch_phase_system::<Transparent2d> batch_phase_system::<Transparent2d>
.after(sort_phase_system::<Transparent2d>) .after(sort_phase_system::<Transparent2d>)
.in_set(RenderSet::PhaseSort), .in_set(RenderSet::PhaseSort),
); ));
let pass_node_2d = MainPass2dNode::new(&mut render_app.world); let pass_node_2d = MainPass2dNode::new(&mut render_app.world);
let tonemapping = TonemappingNode::new(&mut render_app.world); let tonemapping = TonemappingNode::new(&mut render_app.world);

View file

@ -68,15 +68,15 @@ impl Plugin for Core3dPlugin {
.init_resource::<DrawFunctions<Opaque3d>>() .init_resource::<DrawFunctions<Opaque3d>>()
.init_resource::<DrawFunctions<AlphaMask3d>>() .init_resource::<DrawFunctions<AlphaMask3d>>()
.init_resource::<DrawFunctions<Transparent3d>>() .init_resource::<DrawFunctions<Transparent3d>>()
.add_system(extract_core_3d_camera_phases.in_schedule(ExtractSchedule)) .add_systems((
.add_system( extract_core_3d_camera_phases.in_schedule(ExtractSchedule),
prepare_core_3d_depth_textures prepare_core_3d_depth_textures
.in_set(RenderSet::Prepare) .in_set(RenderSet::Prepare)
.after(bevy_render::view::prepare_windows), .after(bevy_render::view::prepare_windows),
) sort_phase_system::<Opaque3d>.in_set(RenderSet::PhaseSort),
.add_system(sort_phase_system::<Opaque3d>.in_set(RenderSet::PhaseSort)) sort_phase_system::<AlphaMask3d>.in_set(RenderSet::PhaseSort),
.add_system(sort_phase_system::<AlphaMask3d>.in_set(RenderSet::PhaseSort)) sort_phase_system::<Transparent3d>.in_set(RenderSet::PhaseSort),
.add_system(sort_phase_system::<Transparent3d>.in_set(RenderSet::PhaseSort)); ));
let prepass_node = PrepassNode::new(&mut render_app.world); let prepass_node = PrepassNode::new(&mut render_app.world);
let pass_node_3d = MainPass3dNode::new(&mut render_app.world); let pass_node_3d = MainPass3dNode::new(&mut render_app.world);

View file

@ -21,11 +21,13 @@ fn main() {
// Add systems to the Schedule to execute our app logic // Add systems to the Schedule to execute our app logic
// We can label our systems to force a specific run-order between some of them // We can label our systems to force a specific run-order between some of them
schedule.add_system(spawn_entities.in_set(SimulationSystem::Spawn)); schedule.add_systems((
schedule.add_system(print_counter_when_changed.after(SimulationSystem::Spawn)); spawn_entities.in_set(SimulationSet::Spawn),
schedule.add_system(age_all_entities.in_set(SimulationSystem::Age)); print_counter_when_changed.after(SimulationSet::Spawn),
schedule.add_system(remove_old_entities.after(SimulationSystem::Age)); age_all_entities.in_set(SimulationSet::Age),
schedule.add_system(print_changed_entities.after(SimulationSystem::Age)); remove_old_entities.after(SimulationSet::Age),
print_changed_entities.after(SimulationSet::Age),
));
// Simulate 10 frames in our world // Simulate 10 frames in our world
for iteration in 1..=10 { for iteration in 1..=10 {
@ -48,7 +50,7 @@ struct Age {
// System sets can be used to group systems and configured to control relative ordering // System sets can be used to group systems and configured to control relative ordering
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)] #[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
enum SimulationSystem { enum SimulationSet {
Spawn, Spawn,
Age, Age,
} }

View file

@ -19,8 +19,10 @@ fn main() {
schedule.add_system(Events::<MyEvent>::update_system.in_set(FlushEvents)); schedule.add_system(Events::<MyEvent>::update_system.in_set(FlushEvents));
// Add systems sending and receiving events after the events are flushed. // Add systems sending and receiving events after the events are flushed.
schedule.add_system(sending_system.after(FlushEvents)); schedule.add_systems((
schedule.add_system(receiving_system.after(sending_system)); sending_system.after(FlushEvents),
receiving_system.after(sending_system),
));
// Simulate 10 frames of our world // Simulate 10 frames of our world
for iteration in 1..=10 { for iteration in 1..=10 {

View file

@ -15,8 +15,7 @@ fn main() {
let mut schedule = Schedule::default(); let mut schedule = Schedule::default();
// Add systems to increase the counter and to print out the current value // Add systems to increase the counter and to print out the current value
schedule.add_system(increase_counter); schedule.add_systems((increase_counter, print_counter).chain());
schedule.add_system(print_counter.after(increase_counter));
for iteration in 1..=10 { for iteration in 1..=10 {
println!("Simulating frame {iteration}/10"); println!("Simulating frame {iteration}/10");

View file

@ -127,13 +127,13 @@ mod tests {
world.init_resource::<SystemOrder>(); world.init_resource::<SystemOrder>();
schedule.add_system(named_system); schedule.add_systems((
schedule.add_system(make_function_system(1).before(named_system)); named_system,
schedule.add_system( make_function_system(1).before(named_system),
make_function_system(0) make_function_system(0)
.after(named_system) .after(named_system)
.in_set(TestSet::A), .in_set(TestSet::A),
); ));
schedule.run(&mut world); schedule.run(&mut world);
assert_eq!(world.resource::<SystemOrder>().0, vec![1, u32::MAX, 0]); assert_eq!(world.resource::<SystemOrder>().0, vec![1, u32::MAX, 0]);
@ -144,12 +144,12 @@ mod tests {
// modify the schedule after it's been initialized and test ordering with sets // modify the schedule after it's been initialized and test ordering with sets
schedule.configure_set(TestSet::A.after(named_system)); schedule.configure_set(TestSet::A.after(named_system));
schedule.add_system( schedule.add_systems((
make_function_system(3) make_function_system(3)
.before(TestSet::A) .before(TestSet::A)
.after(named_system), .after(named_system),
); make_function_system(4).after(TestSet::A),
schedule.add_system(make_function_system(4).after(TestSet::A)); ));
schedule.run(&mut world); schedule.run(&mut world);
assert_eq!( assert_eq!(
@ -275,10 +275,12 @@ mod tests {
world.init_resource::<Counter>(); world.init_resource::<Counter>();
schedule.add_system(counting_system.run_if(|| false).run_if(|| false)); schedule.add_systems((
schedule.add_system(counting_system.run_if(|| true).run_if(|| false)); counting_system.run_if(|| false).run_if(|| false),
schedule.add_system(counting_system.run_if(|| false).run_if(|| true)); counting_system.run_if(|| true).run_if(|| false),
schedule.add_system(counting_system.run_if(|| true).run_if(|| true)); counting_system.run_if(|| false).run_if(|| true),
counting_system.run_if(|| true).run_if(|| true),
));
schedule.run(&mut world); schedule.run(&mut world);
assert_eq!(world.resource::<Counter>().0.load(Ordering::Relaxed), 1); assert_eq!(world.resource::<Counter>().0.load(Ordering::Relaxed), 1);
@ -535,8 +537,7 @@ mod tests {
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
// Schedule `bar` to run after `foo`. // Schedule `bar` to run after `foo`.
schedule.add_system(foo); schedule.add_systems((foo, bar.after(foo)));
schedule.add_system(bar.after(foo));
// There's only one `foo`, so it's fine. // There's only one `foo`, so it's fine.
let result = schedule.initialize(&mut world); let result = schedule.initialize(&mut world);
@ -790,8 +791,10 @@ mod tests {
schedule schedule
.set_default_base_set(Base::A) .set_default_base_set(Base::A)
.configure_set(Base::A.before(Base::B)) .configure_set(Base::A.before(Base::B))
.add_system(make_function_system(0).in_base_set(Base::B)) .add_systems((
.add_system(make_function_system(1)); make_function_system(0).in_base_set(Base::B),
make_function_system(1),
));
schedule.run(&mut world); schedule.run(&mut world);
assert_eq!(world.resource::<SystemOrder>().0, vec![1, 0]); assert_eq!(world.resource::<SystemOrder>().0, vec![1, 0]);

View file

@ -55,14 +55,18 @@
//! //!
//! ``` //! ```
//! # use bevy_ecs::prelude::*; //! # use bevy_ecs::prelude::*;
//! # let mut app = Schedule::new(); //! # let mut schedule = Schedule::new();
//! // Prints "Hello, World!" each frame.
//! app
//! .add_system(print_first.before(print_mid))
//! .add_system(print_mid)
//! .add_system(print_last.after(print_mid));
//! # let mut world = World::new(); //! # let mut world = World::new();
//! # app.run(&mut world); //! // Configure these systems to run in order using `chain()`.
//! schedule.add_systems((print_first, print_last).chain());
//! // Prints "HelloWorld!"
//! schedule.run(&mut world);
//!
//! // Configure this system to run in between the other two systems
//! // using explicit dependencies.
//! schedule.add_system(print_mid.after(print_first).before(print_last));
//! // Prints "Hello, World!"
//! schedule.run(&mut world);
//! //!
//! fn print_first() { //! fn print_first() {
//! print!("Hello"); //! print!("Hello");
@ -162,7 +166,7 @@ mod tests {
prelude::AnyOf, prelude::AnyOf,
query::{Added, Changed, Or, With, Without}, query::{Added, Changed, Or, With, Without},
removal_detection::RemovedComponents, removal_detection::RemovedComponents,
schedule::{apply_system_buffers, IntoSystemConfig, Schedule}, schedule::{apply_system_buffers, IntoSystemConfigs, Schedule},
system::{ system::{
Commands, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, QueryComponentError, Commands, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, QueryComponentError,
Res, ResMut, Resource, System, SystemState, Res, ResMut, Resource, System, SystemState,
@ -334,9 +338,7 @@ mod tests {
let mut schedule = Schedule::default(); let mut schedule = Schedule::default();
schedule.add_system(incr_e_on_flip); schedule.add_systems((incr_e_on_flip, apply_system_buffers, World::clear_trackers).chain());
schedule.add_system(apply_system_buffers.after(incr_e_on_flip));
schedule.add_system(World::clear_trackers.after(apply_system_buffers));
schedule.run(&mut world); schedule.run(&mut world);
assert_eq!(world.resource::<Added>().0, 1); assert_eq!(world.resource::<Added>().0, 1);

View file

@ -396,8 +396,7 @@ impl_param_set!();
/// resource.value = 0; /// resource.value = 0;
/// assert_eq!(resource.value, 0); /// assert_eq!(resource.value, 0);
/// } /// }
/// # schedule.add_system(read_resource_system); /// # schedule.add_systems((read_resource_system, write_resource_system).chain());
/// # schedule.add_system(write_resource_system.after(read_resource_system));
/// # schedule.run(&mut world); /// # schedule.run(&mut world);
/// ``` /// ```
pub trait Resource: Send + Sync + 'static {} pub trait Resource: Send + Sync + 'static {}
@ -861,10 +860,8 @@ pub trait SystemBuffer: FromWorld + Send + 'static {
/// }); /// });
/// ///
/// let mut schedule = Schedule::new(); /// let mut schedule = Schedule::new();
/// schedule /// // These two systems have no conflicts and will run in parallel.
/// // These two systems have no conflicts and will run in parallel. /// schedule.add_systems((alert_criminal, alert_monster));
/// .add_system(alert_criminal)
/// .add_system(alert_monster);
/// ///
/// // There are no criminals or monsters, so the alarm is not sounded. /// // There are no criminals or monsters, so the alarm is not sounded.
/// schedule.run(&mut world); /// schedule.run(&mut world);

View file

@ -188,22 +188,18 @@ impl Plugin for PbrPlugin {
.in_base_set(CoreSet::PostUpdate), .in_base_set(CoreSet::PostUpdate),
) )
.add_plugin(FogPlugin) .add_plugin(FogPlugin)
.add_system(add_clusters.in_set(SimulationLightSystems::AddClusters)) .add_systems((
.add_system(apply_system_buffers.in_set(SimulationLightSystems::AddClustersFlush)) add_clusters.in_set(SimulationLightSystems::AddClusters),
.add_system( apply_system_buffers.in_set(SimulationLightSystems::AddClustersFlush),
assign_lights_to_clusters assign_lights_to_clusters
.in_set(SimulationLightSystems::AssignLightsToClusters) .in_set(SimulationLightSystems::AssignLightsToClusters)
.after(TransformSystem::TransformPropagate) .after(TransformSystem::TransformPropagate)
.after(VisibilitySystems::CheckVisibility) .after(VisibilitySystems::CheckVisibility)
.after(CameraUpdateSystem), .after(CameraUpdateSystem),
)
.add_system(
update_directional_light_cascades update_directional_light_cascades
.in_set(SimulationLightSystems::UpdateDirectionalLightCascades) .in_set(SimulationLightSystems::UpdateDirectionalLightCascades)
.after(TransformSystem::TransformPropagate) .after(TransformSystem::TransformPropagate)
.after(CameraUpdateSystem), .after(CameraUpdateSystem),
)
.add_system(
update_directional_light_frusta update_directional_light_frusta
.in_set(SimulationLightSystems::UpdateLightFrusta) .in_set(SimulationLightSystems::UpdateLightFrusta)
// This must run after CheckVisibility because it relies on ComputedVisibility::is_visible() // This must run after CheckVisibility because it relies on ComputedVisibility::is_visible()
@ -214,20 +210,14 @@ impl Plugin for PbrPlugin {
// so these systems will run independently of one another. // so these systems will run independently of one another.
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481. // FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
.ambiguous_with(update_spot_light_frusta), .ambiguous_with(update_spot_light_frusta),
)
.add_system(
update_point_light_frusta update_point_light_frusta
.in_set(SimulationLightSystems::UpdateLightFrusta) .in_set(SimulationLightSystems::UpdateLightFrusta)
.after(TransformSystem::TransformPropagate) .after(TransformSystem::TransformPropagate)
.after(SimulationLightSystems::AssignLightsToClusters), .after(SimulationLightSystems::AssignLightsToClusters),
)
.add_system(
update_spot_light_frusta update_spot_light_frusta
.in_set(SimulationLightSystems::UpdateLightFrusta) .in_set(SimulationLightSystems::UpdateLightFrusta)
.after(TransformSystem::TransformPropagate) .after(TransformSystem::TransformPropagate)
.after(SimulationLightSystems::AssignLightsToClusters), .after(SimulationLightSystems::AssignLightsToClusters),
)
.add_system(
check_light_mesh_visibility check_light_mesh_visibility
.in_set(SimulationLightSystems::CheckLightVisibility) .in_set(SimulationLightSystems::CheckLightVisibility)
.after(VisibilitySystems::CalculateBoundsFlush) .after(VisibilitySystems::CalculateBoundsFlush)
@ -237,7 +227,7 @@ impl Plugin for PbrPlugin {
// because that resets entity ComputedVisibility for the first view // because that resets entity ComputedVisibility for the first view
// which would override any results from this otherwise // which would override any results from this otherwise
.after(VisibilitySystems::CheckVisibility), .after(VisibilitySystems::CheckVisibility),
); ));
app.world app.world
.resource_mut::<Assets<StandardMaterial>>() .resource_mut::<Assets<StandardMaterial>>()
@ -267,25 +257,21 @@ impl Plugin for PbrPlugin {
) )
.in_schedule(ExtractSchedule), .in_schedule(ExtractSchedule),
) )
.add_system( .add_systems((
render::prepare_lights render::prepare_lights
.before(ViewSet::PrepareUniforms) .before(ViewSet::PrepareUniforms)
.in_set(RenderLightSystems::PrepareLights), .in_set(RenderLightSystems::PrepareLights),
) // A sync is needed after prepare_lights, before prepare_view_uniforms,
// A sync is needed after prepare_lights, before prepare_view_uniforms, // because prepare_lights creates new views for shadow mapping
// because prepare_lights creates new views for shadow mapping
.add_system(
apply_system_buffers apply_system_buffers
.in_set(RenderSet::Prepare) .in_set(RenderSet::Prepare)
.after(RenderLightSystems::PrepareLights) .after(RenderLightSystems::PrepareLights)
.before(ViewSet::PrepareUniforms), .before(ViewSet::PrepareUniforms),
)
.add_system(
render::prepare_clusters render::prepare_clusters
.after(render::prepare_lights) .after(render::prepare_lights)
.in_set(RenderLightSystems::PrepareClusters), .in_set(RenderLightSystems::PrepareClusters),
) sort_phase_system::<Shadow>.in_set(RenderSet::PhaseSort),
.add_system(sort_phase_system::<Shadow>.in_set(RenderSet::PhaseSort)) ))
.init_resource::<ShadowSamplers>() .init_resource::<ShadowSamplers>()
.init_resource::<LightMeta>() .init_resource::<LightMeta>()
.init_resource::<GlobalLightMeta>(); .init_resource::<GlobalLightMeta>();

View file

@ -199,14 +199,14 @@ where
.init_resource::<ExtractedMaterials<M>>() .init_resource::<ExtractedMaterials<M>>()
.init_resource::<RenderMaterials<M>>() .init_resource::<RenderMaterials<M>>()
.init_resource::<SpecializedMeshPipelines<MaterialPipeline<M>>>() .init_resource::<SpecializedMeshPipelines<MaterialPipeline<M>>>()
.add_system(extract_materials::<M>.in_schedule(ExtractSchedule)) .add_systems((
.add_system( extract_materials::<M>.in_schedule(ExtractSchedule),
prepare_materials::<M> prepare_materials::<M>
.in_set(RenderSet::Prepare) .in_set(RenderSet::Prepare)
.after(PrepareAssetSet::PreAssetPrepare), .after(PrepareAssetSet::PreAssetPrepare),
) render::queue_shadows::<M>.in_set(RenderLightSystems::QueueShadows),
.add_system(render::queue_shadows::<M>.in_set(RenderLightSystems::QueueShadows)) queue_material_meshes::<M>.in_set(RenderSet::Queue),
.add_system(queue_material_meshes::<M>.in_set(RenderSet::Queue)); ));
} }
// PrepassPipelinePlugin is required for shadow mapping and the optional PrepassPlugin // PrepassPipelinePlugin is required for shadow mapping and the optional PrepassPlugin

View file

@ -129,15 +129,15 @@ where
}; };
render_app render_app
.add_system(extract_camera_prepass_phase.in_schedule(ExtractSchedule)) .add_systems((
.add_system( extract_camera_prepass_phase.in_schedule(ExtractSchedule),
prepare_prepass_textures prepare_prepass_textures
.in_set(RenderSet::Prepare) .in_set(RenderSet::Prepare)
.after(bevy_render::view::prepare_windows), .after(bevy_render::view::prepare_windows),
) queue_prepass_material_meshes::<M>.in_set(RenderSet::Queue),
.add_system(queue_prepass_material_meshes::<M>.in_set(RenderSet::Queue)) sort_phase_system::<Opaque3dPrepass>.in_set(RenderSet::PhaseSort),
.add_system(sort_phase_system::<Opaque3dPrepass>.in_set(RenderSet::PhaseSort)) sort_phase_system::<AlphaMask3dPrepass>.in_set(RenderSet::PhaseSort),
.add_system(sort_phase_system::<AlphaMask3dPrepass>.in_set(RenderSet::PhaseSort)) ))
.init_resource::<DrawFunctions<Opaque3dPrepass>>() .init_resource::<DrawFunctions<Opaque3dPrepass>>()
.init_resource::<DrawFunctions<AlphaMask3dPrepass>>() .init_resource::<DrawFunctions<AlphaMask3dPrepass>>()
.add_render_command::<Opaque3dPrepass, DrawPrepass<M>>() .add_render_command::<Opaque3dPrepass, DrawPrepass<M>>()

View file

@ -108,9 +108,11 @@ impl Plugin for MeshRenderPlugin {
.init_resource::<MeshPipeline>() .init_resource::<MeshPipeline>()
.init_resource::<SkinnedMeshUniform>() .init_resource::<SkinnedMeshUniform>()
.add_systems((extract_meshes, extract_skinned_meshes).in_schedule(ExtractSchedule)) .add_systems((extract_meshes, extract_skinned_meshes).in_schedule(ExtractSchedule))
.add_system(prepare_skinned_meshes.in_set(RenderSet::Prepare)) .add_systems((
.add_system(queue_mesh_bind_group.in_set(RenderSet::Queue)) prepare_skinned_meshes.in_set(RenderSet::Prepare),
.add_system(queue_mesh_view_bind_groups.in_set(RenderSet::Queue)); queue_mesh_bind_group.in_set(RenderSet::Queue),
queue_mesh_view_bind_groups.in_set(RenderSet::Queue),
));
} }
} }
} }

View file

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use bevy_app::{App, CoreSchedule, CoreSet, Plugin, StartupSet}; use bevy_app::{App, CoreSchedule, CoreSet, IntoSystemAppConfig, Plugin, StartupSet};
use bevy_ecs::{prelude::*, reflect::ReflectComponent}; use bevy_ecs::{prelude::*, reflect::ReflectComponent};
use bevy_math::{Mat4, Rect, Vec2}; use bevy_math::{Mat4, Rect, Vec2};
use bevy_reflect::{ use bevy_reflect::{
@ -31,22 +31,21 @@ impl<T: CameraProjection + Component + GetTypeRegistration> Plugin for CameraPro
schedule.configure_set(CameraUpdateSystem.in_base_set(StartupSet::PostStartup)); schedule.configure_set(CameraUpdateSystem.in_base_set(StartupSet::PostStartup));
}) })
.configure_set(CameraUpdateSystem.in_base_set(CoreSet::PostUpdate)) .configure_set(CameraUpdateSystem.in_base_set(CoreSet::PostUpdate))
.add_startup_system( .add_systems((
crate::camera::camera_system::<T>
.on_startup()
.in_set(CameraUpdateSystem)
// We assume that each camera will only have one projection,
// so we can ignore ambiguities with all other monomorphizations.
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
.ambiguous_with(CameraUpdateSystem),
crate::camera::camera_system::<T> crate::camera::camera_system::<T>
.in_set(CameraUpdateSystem) .in_set(CameraUpdateSystem)
// We assume that each camera will only have one projection, // We assume that each camera will only have one projection,
// so we can ignore ambiguities with all other monomorphizations. // so we can ignore ambiguities with all other monomorphizations.
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481. // FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
.ambiguous_with(CameraUpdateSystem), .ambiguous_with(CameraUpdateSystem),
) ));
.add_system(
crate::camera::camera_system::<T>
.in_set(CameraUpdateSystem)
// We assume that each camera will only have one projection,
// so we can ignore ambiguities with all other monomorphizations.
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
.ambiguous_with(CameraUpdateSystem),
);
} }
} }

View file

@ -112,18 +112,30 @@ impl RenderSet {
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
// Create "stage-like" structure using buffer flushes + ordering // Create "stage-like" structure using buffer flushes + ordering
schedule.add_system(apply_system_buffers.in_set(PrepareFlush)); schedule.add_systems((
schedule.add_system(apply_system_buffers.in_set(QueueFlush)); apply_system_buffers.in_set(PrepareFlush),
schedule.add_system(apply_system_buffers.in_set(PhaseSortFlush)); apply_system_buffers.in_set(QueueFlush),
schedule.add_system(apply_system_buffers.in_set(RenderFlush)); apply_system_buffers.in_set(PhaseSortFlush),
schedule.add_system(apply_system_buffers.in_set(CleanupFlush)); apply_system_buffers.in_set(RenderFlush),
apply_system_buffers.in_set(CleanupFlush),
));
schedule.configure_set(ExtractCommands.before(Prepare)); schedule.configure_sets(
schedule.configure_set(Prepare.after(ExtractCommands).before(PrepareFlush)); (
schedule.configure_set(Queue.after(PrepareFlush).before(QueueFlush)); ExtractCommands,
schedule.configure_set(PhaseSort.after(QueueFlush).before(PhaseSortFlush)); Prepare,
schedule.configure_set(Render.after(PhaseSortFlush).before(RenderFlush)); PrepareFlush,
schedule.configure_set(Cleanup.after(RenderFlush).before(CleanupFlush)); Queue,
QueueFlush,
PhaseSort,
PhaseSortFlush,
Render,
RenderFlush,
Cleanup,
CleanupFlush,
)
.chain(),
);
schedule schedule
} }

View file

@ -92,8 +92,10 @@ impl<A: RenderAsset> Plugin for RenderAssetPlugin<A> {
.init_resource::<ExtractedAssets<A>>() .init_resource::<ExtractedAssets<A>>()
.init_resource::<RenderAssets<A>>() .init_resource::<RenderAssets<A>>()
.init_resource::<PrepareNextFrameAssets<A>>() .init_resource::<PrepareNextFrameAssets<A>>()
.add_system(extract_render_asset::<A>.in_schedule(ExtractSchedule)) .add_systems((
.add_system(prepare_assets::<A>.in_set(self.prepare_asset_set.clone())); extract_render_asset::<A>.in_schedule(ExtractSchedule),
prepare_assets::<A>.in_set(self.prepare_asset_set.clone()),
));
} }
} }
} }

View file

@ -56,13 +56,13 @@ impl Plugin for ViewPlugin {
render_app render_app
.init_resource::<ViewUniforms>() .init_resource::<ViewUniforms>()
.configure_set(ViewSet::PrepareUniforms.in_set(RenderSet::Prepare)) .configure_set(ViewSet::PrepareUniforms.in_set(RenderSet::Prepare))
.add_system(prepare_view_uniforms.in_set(ViewSet::PrepareUniforms)) .add_systems((
.add_system( prepare_view_uniforms.in_set(ViewSet::PrepareUniforms),
prepare_view_targets prepare_view_targets
.after(WindowSystem::Prepare) .after(WindowSystem::Prepare)
.in_set(RenderSet::Prepare) .in_set(RenderSet::Prepare)
.after(crate::render_asset::prepare_assets::<Image>), .after(crate::render_asset::prepare_assets::<Image>),
); ));
} }
} }
} }

View file

@ -223,8 +223,8 @@ impl Plugin for VisibilityPlugin {
.configure_set(UpdateProjectionFrusta.in_base_set(CoreSet::PostUpdate)) .configure_set(UpdateProjectionFrusta.in_base_set(CoreSet::PostUpdate))
.configure_set(CheckVisibility.in_base_set(CoreSet::PostUpdate)) .configure_set(CheckVisibility.in_base_set(CoreSet::PostUpdate))
.configure_set(VisibilityPropagate.in_base_set(CoreSet::PostUpdate)) .configure_set(VisibilityPropagate.in_base_set(CoreSet::PostUpdate))
.add_system(calculate_bounds.in_set(CalculateBounds)) .add_systems((
.add_system( calculate_bounds.in_set(CalculateBounds),
update_frusta::<OrthographicProjection> update_frusta::<OrthographicProjection>
.in_set(UpdateOrthographicFrusta) .in_set(UpdateOrthographicFrusta)
.after(camera_system::<OrthographicProjection>) .after(camera_system::<OrthographicProjection>)
@ -234,8 +234,6 @@ impl Plugin for VisibilityPlugin {
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481. // FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
.ambiguous_with(update_frusta::<PerspectiveProjection>) .ambiguous_with(update_frusta::<PerspectiveProjection>)
.ambiguous_with(update_frusta::<Projection>), .ambiguous_with(update_frusta::<Projection>),
)
.add_system(
update_frusta::<PerspectiveProjection> update_frusta::<PerspectiveProjection>
.in_set(UpdatePerspectiveFrusta) .in_set(UpdatePerspectiveFrusta)
.after(camera_system::<PerspectiveProjection>) .after(camera_system::<PerspectiveProjection>)
@ -244,15 +242,11 @@ impl Plugin for VisibilityPlugin {
// so these systems will run independently of one another. // so these systems will run independently of one another.
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481. // FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
.ambiguous_with(update_frusta::<Projection>), .ambiguous_with(update_frusta::<Projection>),
)
.add_system(
update_frusta::<Projection> update_frusta::<Projection>
.in_set(UpdateProjectionFrusta) .in_set(UpdateProjectionFrusta)
.after(camera_system::<Projection>) .after(camera_system::<Projection>)
.after(TransformSystem::TransformPropagate), .after(TransformSystem::TransformPropagate),
) visibility_propagate_system.in_set(VisibilityPropagate),
.add_system(visibility_propagate_system.in_set(VisibilityPropagate))
.add_system(
check_visibility check_visibility
.in_set(CheckVisibility) .in_set(CheckVisibility)
.after(CalculateBoundsFlush) .after(CalculateBoundsFlush)
@ -261,7 +255,7 @@ impl Plugin for VisibilityPlugin {
.after(UpdateProjectionFrusta) .after(UpdateProjectionFrusta)
.after(VisibilityPropagate) .after(VisibilityPropagate)
.after(TransformSystem::TransformPropagate), .after(TransformSystem::TransformPropagate),
); ));
} }
} }

View file

@ -161,13 +161,13 @@ where
.init_resource::<ExtractedMaterials2d<M>>() .init_resource::<ExtractedMaterials2d<M>>()
.init_resource::<RenderMaterials2d<M>>() .init_resource::<RenderMaterials2d<M>>()
.init_resource::<SpecializedMeshPipelines<Material2dPipeline<M>>>() .init_resource::<SpecializedMeshPipelines<Material2dPipeline<M>>>()
.add_system(extract_materials_2d::<M>.in_schedule(ExtractSchedule)) .add_systems((
.add_system( extract_materials_2d::<M>.in_schedule(ExtractSchedule),
prepare_materials_2d::<M> prepare_materials_2d::<M>
.in_set(RenderSet::Prepare) .in_set(RenderSet::Prepare)
.after(PrepareAssetSet::PreAssetPrepare), .after(PrepareAssetSet::PreAssetPrepare),
) queue_material2d_meshes::<M>.in_set(RenderSet::Queue),
.add_system(queue_material2d_meshes::<M>.in_set(RenderSet::Queue)); ));
} }
} }
} }

View file

@ -103,9 +103,11 @@ impl Plugin for Mesh2dRenderPlugin {
render_app render_app
.init_resource::<Mesh2dPipeline>() .init_resource::<Mesh2dPipeline>()
.init_resource::<SpecializedMeshPipelines<Mesh2dPipeline>>() .init_resource::<SpecializedMeshPipelines<Mesh2dPipeline>>()
.add_system(extract_mesh2d.in_schedule(ExtractSchedule)) .add_systems((
.add_system(queue_mesh2d_bind_group.in_set(RenderSet::Queue)) extract_mesh2d.in_schedule(ExtractSchedule),
.add_system(queue_mesh2d_view_bind_groups.in_set(RenderSet::Queue)); queue_mesh2d_bind_group.in_set(RenderSet::Queue),
queue_mesh2d_view_bind_groups.in_set(RenderSet::Queue),
));
} }
} }
} }

View file

@ -106,20 +106,20 @@ impl Plugin for TransformPlugin {
TransformSystem::TransformPropagate.in_base_set(StartupSet::PostStartup), TransformSystem::TransformPropagate.in_base_set(StartupSet::PostStartup),
); );
}) })
// FIXME: https://github.com/bevyengine/bevy/issues/4381 .add_startup_systems((
// These systems cannot access the same entities, sync_simple_transforms
// due to subtle query filtering that is not yet correctly computed in the ambiguity detector .in_set(TransformSystem::TransformPropagate)
.add_startup_system( // FIXME: https://github.com/bevyengine/bevy/issues/4381
// These systems cannot access the same entities,
// due to subtle query filtering that is not yet correctly computed in the ambiguity detector
.ambiguous_with(PropagateTransformsSet),
propagate_transforms.in_set(PropagateTransformsSet),
))
.add_systems((
sync_simple_transforms sync_simple_transforms
.in_set(TransformSystem::TransformPropagate) .in_set(TransformSystem::TransformPropagate)
.ambiguous_with(PropagateTransformsSet), .ambiguous_with(PropagateTransformsSet),
) propagate_transforms.in_set(PropagateTransformsSet),
.add_startup_system(propagate_transforms.in_set(PropagateTransformsSet)) ));
.add_system(
sync_simple_transforms
.in_set(TransformSystem::TransformPropagate)
.ambiguous_with(PropagateTransformsSet),
)
.add_system(propagate_transforms.in_set(PropagateTransformsSet));
} }
} }

View file

@ -171,8 +171,7 @@ mod test {
let mut world = World::default(); let mut world = World::default();
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(sync_simple_transforms); schedule.add_systems((sync_simple_transforms, propagate_transforms));
schedule.add_system(propagate_transforms);
// Root entity // Root entity
world.spawn(TransformBundle::from(Transform::from_xyz(1.0, 0.0, 0.0))); world.spawn(TransformBundle::from(Transform::from_xyz(1.0, 0.0, 0.0)));
@ -210,8 +209,7 @@ mod test {
let mut world = World::default(); let mut world = World::default();
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(sync_simple_transforms); schedule.add_systems((sync_simple_transforms, propagate_transforms));
schedule.add_system(propagate_transforms);
// Root entity // Root entity
let mut queue = CommandQueue::default(); let mut queue = CommandQueue::default();
@ -251,8 +249,7 @@ mod test {
let mut world = World::default(); let mut world = World::default();
let mut schedule = Schedule::new(); let mut schedule = Schedule::new();
schedule.add_system(sync_simple_transforms); schedule.add_systems((sync_simple_transforms, propagate_transforms));
schedule.add_system(propagate_transforms);
// Add parent entities // Add parent entities
let mut children = Vec::new(); let mut children = Vec::new();
@ -328,8 +325,7 @@ mod test {
let mut app = App::new(); let mut app = App::new();
ComputeTaskPool::init(TaskPool::default); ComputeTaskPool::init(TaskPool::default);
app.add_system(sync_simple_transforms); app.add_systems((sync_simple_transforms, propagate_transforms));
app.add_system(propagate_transforms);
let translation = vec3(1.0, 0.0, 0.0); let translation = vec3(1.0, 0.0, 0.0);
@ -375,8 +371,7 @@ mod test {
let mut temp = World::new(); let mut temp = World::new();
let mut app = App::new(); let mut app = App::new();
app.add_system(propagate_transforms) app.add_systems((propagate_transforms, sync_simple_transforms));
.add_system(sync_simple_transforms);
fn setup_world(world: &mut World) -> (Entity, Entity) { fn setup_world(world: &mut World) -> (Entity, Entity) {
let mut grandchild = Entity::from_raw(0); let mut grandchild = Entity::from_raw(0);

View file

@ -149,9 +149,6 @@ pub(crate) struct AccessibilityPlugin;
impl Plugin for AccessibilityPlugin { impl Plugin for AccessibilityPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_system(calc_bounds) app.add_systems((calc_bounds, button_changed, image_changed, label_changed));
.add_system(button_changed)
.add_system(image_changed)
.add_system(label_changed);
} }
} }

View file

@ -141,17 +141,15 @@ impl Plugin for UiPlugin {
system system
}) })
.add_system( .add_systems((
flex_node_system flex_node_system
.in_set(UiSystem::Flex) .in_set(UiSystem::Flex)
.before(TransformSystem::TransformPropagate), .before(TransformSystem::TransformPropagate),
) ui_stack_system.in_set(UiSystem::Stack),
.add_system(ui_stack_system.in_set(UiSystem::Stack))
.add_system(
update_clipping_system update_clipping_system
.after(TransformSystem::TransformPropagate) .after(TransformSystem::TransformPropagate)
.in_base_set(CoreSet::PostUpdate), .in_base_set(CoreSet::PostUpdate),
); ));
crate::render::build_ui_render(app); crate::render::build_ui_render(app);
} }

View file

@ -86,9 +86,11 @@ pub fn build_ui_render(app: &mut App) {
) )
.in_schedule(ExtractSchedule), .in_schedule(ExtractSchedule),
) )
.add_system(prepare_uinodes.in_set(RenderSet::Prepare)) .add_systems((
.add_system(queue_uinodes.in_set(RenderSet::Queue)) prepare_uinodes.in_set(RenderSet::Prepare),
.add_system(sort_phase_system::<TransparentUi>.in_set(RenderSet::PhaseSort)); queue_uinodes.in_set(RenderSet::Queue),
sort_phase_system::<TransparentUi>.in_set(RenderSet::PhaseSort),
));
// Render graph // Render graph
let ui_graph_2d = get_ui_graph(render_app); let ui_graph_2d = get_ui_graph(render_app);

View file

@ -163,9 +163,11 @@ impl Plugin for AccessibilityPlugin {
app.init_non_send_resource::<AccessKitAdapters>() app.init_non_send_resource::<AccessKitAdapters>()
.init_resource::<WinitActionHandlers>() .init_resource::<WinitActionHandlers>()
.add_event::<ActionRequest>() .add_event::<ActionRequest>()
.add_system(handle_window_focus) .add_systems((
.add_system(window_closed) handle_window_focus,
.add_system(poll_receivers) window_closed,
.add_system(update_accessibility_nodes); poll_receivers,
update_accessibility_nodes,
));
} }
} }

View file

@ -13,8 +13,7 @@ fn main() {
App::new() App::new()
.insert_resource(ClearColor(Color::DARK_GRAY)) .insert_resource(ClearColor(Color::DARK_GRAY))
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), update_bloom_settings))
.add_system(update_bloom_settings)
.run(); .run();
} }

View file

@ -283,8 +283,10 @@ impl Plugin for ColoredMesh2dPlugin {
.add_render_command::<Transparent2d, DrawColoredMesh2d>() .add_render_command::<Transparent2d, DrawColoredMesh2d>()
.init_resource::<ColoredMesh2dPipeline>() .init_resource::<ColoredMesh2dPipeline>()
.init_resource::<SpecializedRenderPipelines<ColoredMesh2dPipeline>>() .init_resource::<SpecializedRenderPipelines<ColoredMesh2dPipeline>>()
.add_system(extract_colored_mesh2d.in_schedule(ExtractSchedule)) .add_systems((
.add_system(queue_colored_mesh2d.in_set(RenderSet::Queue)); extract_colored_mesh2d.in_schedule(ExtractSchedule),
queue_colored_mesh2d.in_set(RenderSet::Queue),
));
} }
} }

View file

@ -5,8 +5,7 @@ use bevy::prelude::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), sprite_movement))
.add_system(sprite_movement)
.run(); .run();
} }

View file

@ -5,8 +5,7 @@ use bevy::prelude::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_startup_system(setup) .add_systems((setup.on_startup(), sprite_movement))
.add_system(sprite_movement)
.run(); .run();
} }

View file

@ -6,8 +6,7 @@ use bevy::prelude::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) // prevents blurry sprites .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) // prevents blurry sprites
.add_startup_system(setup) .add_systems((setup.on_startup(), animate_sprite))
.add_system(animate_sprite)
.run(); .run();
} }

View file

@ -14,10 +14,12 @@ use bevy::{
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((
.add_system(animate_translation) setup.on_startup(),
.add_system(animate_rotation) animate_translation,
.add_system(animate_scale) animate_rotation,
animate_scale,
))
.run(); .run();
} }

View file

@ -8,9 +8,11 @@ fn main() {
.init_resource::<RpgSpriteHandles>() .init_resource::<RpgSpriteHandles>()
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) // prevents blurry sprites .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) // prevents blurry sprites
.add_state::<AppState>() .add_state::<AppState>()
.add_system(load_textures.in_schedule(OnEnter(AppState::Setup))) .add_systems((
.add_system(check_textures.in_set(OnUpdate(AppState::Setup))) load_textures.in_schedule(OnEnter(AppState::Setup)),
.add_system(setup.in_schedule(OnEnter(AppState::Finished))) check_textures.in_set(OnUpdate(AppState::Setup)),
setup.in_schedule(OnEnter(AppState::Finished)),
))
.run(); .run();
} }

View file

@ -11,8 +11,7 @@ use bevy::{
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_startup_system(setup) .add_systems((setup.on_startup(), rotate))
.add_system(rotate)
.run(); .run();
} }

View file

@ -15,9 +15,7 @@ use bevy::{
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup_camera_fog) .add_startup_systems((setup_camera_fog, setup_terrain_scene, setup_instructions))
.add_startup_system(setup_terrain_scene)
.add_startup_system(setup_instructions)
.add_system(toggle_system) .add_system(toggle_system)
.run(); .run();
} }

View file

@ -17,8 +17,7 @@ fn main() {
let mut app = App::new(); let mut app = App::new();
app.add_plugins(DefaultPlugins) app.add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), example_control_system));
.add_system(example_control_system);
// Unfortunately, MSAA and HDR are not supported simultaneously under WebGL. // Unfortunately, MSAA and HDR are not supported simultaneously under WebGL.
// Since this example uses HDR, we must disable MSAA for WASM builds, at least // Since this example uses HDR, we must disable MSAA for WASM builds, at least

View file

@ -16,9 +16,11 @@ fn main() {
App::new() App::new()
.insert_resource(ClearColor(Color::DARK_GRAY)) .insert_resource(ClearColor(Color::DARK_GRAY))
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup_scene) .add_systems((
.add_system(update_bloom_settings) setup_scene.on_startup(),
.add_system(bounce_spheres) update_bloom_settings,
bounce_spheres,
))
.run(); .run();
} }

View file

@ -22,9 +22,7 @@ use bevy::{
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup_camera_fog) .add_startup_systems((setup_camera_fog, setup_pyramid_scene, setup_instructions))
.add_startup_system(setup_pyramid_scene)
.add_startup_system(setup_instructions)
.add_system(update_system) .add_system(update_system)
.run(); .run();
} }

View file

@ -17,8 +17,7 @@ fn main() {
// Disable MSAA by default // Disable MSAA by default
.insert_resource(Msaa::Off) .insert_resource(Msaa::Off)
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), toggle_fxaa))
.add_system(toggle_fxaa)
.run(); .run();
} }

View file

@ -8,9 +8,7 @@ use bevy::{pbr::CascadeShadowConfigBuilder, prelude::*};
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), movement, animate_light_direction))
.add_system(movement)
.add_system(animate_light_direction)
.run(); .run();
} }

View file

@ -15,8 +15,7 @@ fn main() {
}) })
.insert_resource(DirectionalLightShadowMap { size: 4096 }) .insert_resource(DirectionalLightShadowMap { size: 4096 })
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), animate_light_direction))
.add_system(animate_light_direction)
.run(); .run();
} }

View file

@ -10,8 +10,7 @@ fn main() {
App::new() App::new()
.insert_resource(Msaa::default()) .insert_resource(Msaa::default())
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), cycle_msaa))
.add_system(cycle_msaa)
.run(); .run();
} }

View file

@ -6,8 +6,7 @@ use bevy::prelude::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), rotator_system))
.add_system(rotator_system)
.run(); .run();
} }

View file

@ -5,8 +5,7 @@ use bevy::{asset::LoadState, prelude::*};
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), environment_map_load_finish))
.add_system(environment_map_load_finish)
.run(); .run();
} }

View file

@ -17,9 +17,7 @@ use bevy::{
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), cube_rotator_system, rotator_system))
.add_system(cube_rotator_system)
.add_system(rotator_system)
.run(); .run();
} }

View file

@ -19,11 +19,13 @@ fn main() {
); );
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((
.add_system(adjust_point_light_biases) setup.on_startup(),
.add_system(toggle_light) adjust_point_light_biases,
.add_system(adjust_directional_light_biases) toggle_light,
.add_system(camera_controller) adjust_directional_light_biases,
camera_controller,
))
.run(); .run();
} }

View file

@ -16,9 +16,7 @@ fn main() {
); );
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), toggle_light, toggle_shadows))
.add_system(toggle_light)
.add_system(toggle_shadows)
.run(); .run();
} }

View file

@ -46,11 +46,13 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(MaterialPlugin::<CubemapMaterial>::default()) .add_plugin(MaterialPlugin::<CubemapMaterial>::default())
.add_startup_system(setup) .add_systems((
.add_system(cycle_cubemap_asset) setup.on_startup(),
.add_system(asset_loaded.after(cycle_cubemap_asset)) cycle_cubemap_asset,
.add_system(camera_controller) asset_loaded.after(cycle_cubemap_asset),
.add_system(animate_light_direction) camera_controller,
animate_light_direction,
))
.run(); .run();
} }

View file

@ -10,8 +10,7 @@ use bevy::{
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), set_camera_viewports))
.add_system(set_camera_viewports)
.run(); .run();
} }

View file

@ -12,9 +12,7 @@ fn main() {
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_startup_system(setup) .add_systems((setup.on_startup(), light_sway, movement))
.add_system(light_sway)
.add_system(movement)
.run(); .run();
} }

View file

@ -27,15 +27,19 @@ fn main() {
.init_resource::<PerMethodSettings>() .init_resource::<PerMethodSettings>()
.insert_resource(CurrentScene(1)) .insert_resource(CurrentScene(1))
.insert_resource(SelectedParameter { value: 0, max: 4 }) .insert_resource(SelectedParameter { value: 0, max: 4 })
.add_startup_system(setup) .add_startup_systems((
.add_startup_system(setup_basic_scene) setup,
.add_startup_system(setup_color_gradient_scene) setup_basic_scene,
.add_startup_system(setup_image_viewer_scene) setup_color_gradient_scene,
.add_system(update_image_viewer) setup_image_viewer_scene,
.add_system(toggle_scene) ))
.add_system(toggle_tonemapping_method) .add_systems((
.add_system(update_color_grading_settings) update_image_viewer,
.add_system(update_ui) toggle_scene,
toggle_tonemapping_method,
update_color_grading_settings,
update_ui,
))
.run(); .run();
} }

View file

@ -6,8 +6,7 @@ use bevy::prelude::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), move_scene_entities))
.add_system(move_scene_entities)
.run(); .run();
} }

View file

@ -13,9 +13,11 @@ fn main() {
color: Color::WHITE, color: Color::WHITE,
brightness: 1.0, brightness: 1.0,
}) })
.add_startup_system(setup) .add_systems((
.add_system(setup_scene_once_loaded) setup.on_startup(),
.add_system(keyboard_animation_control) setup_scene_once_loaded,
keyboard_animation_control,
))
.run(); .run();
} }

View file

@ -20,8 +20,7 @@ fn main() {
brightness: 1.0, brightness: 1.0,
..default() ..default()
}) })
.add_startup_system(setup) .add_systems((setup.on_startup(), joint_animation))
.add_system(joint_animation)
.run(); .run();
} }

View file

@ -12,8 +12,7 @@ fn main() {
brightness: 1.0, brightness: 1.0,
..default() ..default()
}) })
.add_startup_system(setup) .add_systems((setup.on_startup(), joint_animation))
.add_system(joint_animation)
.run(); .run();
} }

View file

@ -41,8 +41,7 @@ fn main() {
.init_resource::<State>() .init_resource::<State>()
.add_asset::<CustomAsset>() .add_asset::<CustomAsset>()
.init_asset_loader::<CustomAssetLoader>() .init_asset_loader::<CustomAssetLoader>()
.add_startup_system(setup) .add_systems((setup.on_startup(), print_on_load))
.add_system(print_on_load)
.run(); .run();
} }

View file

@ -12,9 +12,7 @@ use std::time::{Duration, Instant};
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup_env) .add_startup_systems((setup_env, add_assets, spawn_tasks))
.add_startup_system(add_assets)
.add_startup_system(spawn_tasks)
.add_system(handle_tasks) .add_system(handle_tasks)
.run(); .run();
} }

View file

@ -10,10 +10,7 @@ fn main() {
App::new() App::new()
.add_event::<StreamEvent>() .add_event::<StreamEvent>()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), read_stream, spawn_text, move_text))
.add_system(read_stream)
.add_system(spawn_text)
.add_system(move_text)
.run(); .run();
} }

View file

@ -5,10 +5,7 @@ use bevy::prelude::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), update_speed, pause, volume))
.add_system(update_speed)
.add_system(pause)
.add_system(volume)
.run(); .run();
} }

View file

@ -4,8 +4,7 @@ use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), update_positions))
.add_system(update_positions)
.run(); .run();
} }

View file

@ -4,8 +4,7 @@ use bevy::prelude::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), update_positions))
.add_system(update_positions)
.run(); .run();
} }

View file

@ -11,8 +11,7 @@ fn main() {
// The "print diagnostics" plugin is optional. // The "print diagnostics" plugin is optional.
// It just visualizes our diagnostics in the console. // It just visualizes our diagnostics in the console.
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_startup_system(setup_diagnostic_system) .add_systems((setup_diagnostic_system.on_startup(), my_system))
.add_system(my_system)
.run(); .run();
} }

View file

@ -15,12 +15,14 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.init_resource::<Timers>() .init_resource::<Timers>()
.add_startup_system(setup) .add_systems((
.add_system(despawn_old_and_spawn_new_fruits.before(CustomFlush)) setup.on_startup(),
.add_system(apply_system_buffers.in_set(CustomFlush)) despawn_old_and_spawn_new_fruits.before(CustomFlush),
.add_system(count_apple.after(CustomFlush)) apply_system_buffers.in_set(CustomFlush),
.add_system(count_orange) count_apple.after(CustomFlush),
.add_system(bevy::window::close_on_esc) count_orange,
bevy::window::close_on_esc,
))
.run(); .run();
} }

View file

@ -6,10 +6,12 @@ use rand::Rng;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((
.add_system(change_component) setup.on_startup(),
.add_system(change_detection) change_component,
.add_system(tracker_monitoring) change_detection,
tracker_monitoring,
))
.run(); .run();
} }

View file

@ -18,10 +18,15 @@ use std::fmt::Debug;
fn main() { fn main() {
App::new() App::new()
.add_startup_system(spawn) .add_startup_system(spawn)
.add_system(print_components_read_only) .add_systems(
.add_system(print_components_iter_mut.after(print_components_read_only)) (
.add_system(print_components_iter.after(print_components_iter_mut)) print_components_read_only,
.add_system(print_components_tuple.after(print_components_iter)) print_components_iter_mut,
print_components_iter,
print_components_tuple,
)
.chain(),
)
.run(); .run();
} }

View file

@ -9,9 +9,7 @@ fn main() {
.add_event::<MyEvent>() .add_event::<MyEvent>()
.add_event::<PlaySound>() .add_event::<PlaySound>()
.init_resource::<EventTriggerState>() .init_resource::<EventTriggerState>()
.add_system(event_trigger) .add_systems((event_trigger, event_listener, sound_player))
.add_system(event_listener)
.add_system(sound_player)
.run(); .run();
} }

View file

@ -6,10 +6,12 @@ const FIXED_TIMESTEP: f32 = 0.5;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
// this system will run once every update (it should match your screen's refresh rate) .add_systems((
.add_system(frame_update) // this system will run once every update (it should match your screen's refresh rate)
// add our system to the fixed timestep schedule frame_update,
.add_system(fixed_update.in_schedule(CoreSchedule::FixedUpdate)) // add our system to the fixed timestep schedule
fixed_update.in_schedule(CoreSchedule::FixedUpdate),
))
// configure our fixed timestep schedule to run twice a second // configure our fixed timestep schedule to run twice a second
.insert_resource(FixedTime::new_from_secs(FIXED_TIMESTEP)) .insert_resource(FixedTime::new_from_secs(FIXED_TIMESTEP))
.run(); .run();

View file

@ -42,11 +42,11 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_state::<AppState>() .add_state::<AppState>()
.add_system(setup_system.on_startup())
.add_system(print_text_system)
.add_system(transition_to_in_game_system.in_set(OnUpdate(AppState::MainMenu)))
// add the cleanup systems
.add_systems(( .add_systems((
setup_system.on_startup(),
print_text_system,
transition_to_in_game_system.in_set(OnUpdate(AppState::MainMenu)),
// Cleanup systems.
// Pass in the types your system should operate on using the ::<T> (turbofish) syntax // Pass in the types your system should operate on using the ::<T> (turbofish) syntax
cleanup_system::<MenuClose>.in_schedule(OnExit(AppState::MainMenu)), cleanup_system::<MenuClose>.in_schedule(OnExit(AppState::MainMenu)),
cleanup_system::<LevelUnload>.in_schedule(OnExit(AppState::InGame)), cleanup_system::<LevelUnload>.in_schedule(OnExit(AppState::InGame)),

View file

@ -7,8 +7,7 @@ use bevy::prelude::*;
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((setup.on_startup(), rotate))
.add_system(rotate)
.run(); .run();
} }

View file

@ -28,24 +28,26 @@ fn main() {
}) })
.init_resource::<A>() .init_resource::<A>()
.init_resource::<B>() .init_resource::<B>()
// This pair of systems has an ambiguous order, .add_systems((
// as their data access conflicts, and there's no order between them. // This pair of systems has an ambiguous order,
.add_system(reads_a) // as their data access conflicts, and there's no order between them.
.add_system(writes_a) reads_a,
// This pair of systems has conflicting data access, writes_a,
// but it's resolved with an explicit ordering: // This pair of systems has conflicting data access,
// the .after relationship here means that we will always double after adding. // but it's resolved with an explicit ordering:
.add_system(adds_one_to_b) // the .after relationship here means that we will always double after adding.
.add_system(doubles_b.after(adds_one_to_b)) adds_one_to_b,
// This system isn't ambiguous with adds_one_to_b, doubles_b.after(adds_one_to_b),
// due to the transitive ordering created by our constraints: // This system isn't ambiguous with adds_one_to_b,
// if A is before B is before C, then A must be before C as well. // due to the transitive ordering created by our constraints:
.add_system(reads_b.after(doubles_b)) // if A is before B is before C, then A must be before C as well.
// This system will conflict with all of our writing systems reads_b.after(doubles_b),
// but we've silenced its ambiguity with adds_one_to_b. // This system will conflict with all of our writing systems
// This should only be done in the case of clear false positives: // but we've silenced its ambiguity with adds_one_to_b.
// leave a comment in your code justifying the decision! // This should only be done in the case of clear false positives:
.add_system(reads_a_and_b.ambiguous_with(adds_one_to_b)) // leave a comment in your code justifying the decision!
reads_a_and_b.ambiguous_with(adds_one_to_b),
))
// Be mindful, internal ambiguities are reported too! // Be mindful, internal ambiguities are reported too!
// If there are any ambiguities due solely to DefaultPlugins, // If there are any ambiguities due solely to DefaultPlugins,
// or between DefaultPlugins and any of your third party plugins, // or between DefaultPlugins and any of your third party plugins,

View file

@ -69,8 +69,6 @@ fn bounce_system(windows: Query<&Window>, mut sprites: Query<(&Transform, &mut V
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(spawn_system) .add_systems((spawn_system.on_startup(), move_system, bounce_system))
.add_system(move_system)
.add_system(bounce_system)
.run(); .run();
} }

View file

@ -14,9 +14,11 @@ fn main() {
// `CoreSet::Update', and the system that reacts on the removal in `CoreSet::PostUpdate`. // `CoreSet::Update', and the system that reacts on the removal in `CoreSet::PostUpdate`.
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup) .add_systems((
.add_system(remove_component) setup.on_startup(),
.add_system(react_on_removal.in_base_set(CoreSet::PostUpdate)) remove_component,
react_on_removal.in_base_set(CoreSet::PostUpdate),
))
.run(); .run();
} }

View file

@ -11,7 +11,7 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.init_resource::<InputCounter>() .init_resource::<InputCounter>()
.add_system( .add_systems((
increment_input_counter increment_input_counter
// The common_conditions module has a few useful run conditions // The common_conditions module has a few useful run conditions
// for checking resources and states. These are included in the prelude. // for checking resources and states. These are included in the prelude.
@ -21,8 +21,6 @@ fn main() {
// Both run conditions must return `true` in order for the system to run. // Both run conditions must return `true` in order for the system to run.
// Note that this second run condition will be evaluated even if the first returns `false`. // Note that this second run condition will be evaluated even if the first returns `false`.
.run_if(has_user_input), .run_if(has_user_input),
)
.add_system(
print_input_counter print_input_counter
// `.and_then()` is a run condition combinator that only evaluates the second condition // `.and_then()` is a run condition combinator that only evaluates the second condition
// if the first condition returns `true`. This behavior is known as "short-circuiting", // if the first condition returns `true`. This behavior is known as "short-circuiting",
@ -35,8 +33,6 @@ fn main() {
// All the normal rules still apply: all parameters must be read only except for local parameters. // All the normal rules still apply: all parameters must be read only except for local parameters.
|counter: Res<InputCounter>| counter.is_changed() && !counter.is_added(), |counter: Res<InputCounter>| counter.is_changed() && !counter.is_added(),
)), )),
)
.add_system(
print_time_message print_time_message
// This function returns a custom run condition, much like the common conditions module. // This function returns a custom run condition, much like the common conditions module.
// It will only return true once 2 seconds have passed. // It will only return true once 2 seconds have passed.
@ -45,7 +41,7 @@ fn main() {
// to inverse a run condition. In this case it will return true if // to inverse a run condition. In this case it will return true if
// less than 2.5 seconds have elapsed since the app started. // less than 2.5 seconds have elapsed since the app started.
.run_if(not(time_passed(2.5))), .run_if(not(time_passed(2.5))),
) ))
.run(); .run();
} }

View file

@ -18,9 +18,11 @@ fn main() {
.add_system(setup_menu.in_schedule(OnEnter(AppState::Menu))) .add_system(setup_menu.in_schedule(OnEnter(AppState::Menu)))
// By contrast, on_update systems are stored in the main schedule, during CoreSet::Update, // By contrast, on_update systems are stored in the main schedule, during CoreSet::Update,
// and simply check the value of the `State<T>` resource to see if they should run each frame. // and simply check the value of the `State<T>` resource to see if they should run each frame.
.add_system(menu.in_set(OnUpdate(AppState::Menu))) .add_systems((
.add_system(cleanup_menu.in_schedule(OnExit(AppState::Menu))) menu.in_set(OnUpdate(AppState::Menu)),
.add_system(setup_game.in_schedule(OnEnter(AppState::InGame))) cleanup_menu.in_schedule(OnExit(AppState::Menu)),
setup_game.in_schedule(OnEnter(AppState::InGame)),
))
.add_systems((movement, change_color).in_set(OnUpdate(AppState::InGame))) .add_systems((movement, change_color).in_set(OnUpdate(AppState::InGame)))
.run(); .run();
} }

View file

@ -5,8 +5,7 @@ use bevy::{ecs::system::SystemParam, prelude::*};
fn main() { fn main() {
App::new() App::new()
.insert_resource(PlayerCount(0)) .insert_resource(PlayerCount(0))
.add_startup_system(spawn) .add_systems((spawn.on_startup(), count_players))
.add_system(count_players)
.run(); .run();
} }

View file

@ -15,12 +15,14 @@ fn main() {
level: Level::TRACE, level: Level::TRACE,
filter: "".to_string(), filter: "".to_string(),
}) })
.add_system(parse_message_system.pipe(handler_system)) .add_systems((
.add_system(data_pipe_system.pipe(info)) parse_message_system.pipe(handler_system),
.add_system(parse_message_system.pipe(dbg)) data_pipe_system.pipe(info),
.add_system(warning_pipe_system.pipe(warn)) parse_message_system.pipe(dbg),
.add_system(parse_error_message_system.pipe(error)) warning_pipe_system.pipe(warn),
.add_system(parse_message_system.pipe(ignore)) parse_error_message_system.pipe(error),
parse_message_system.pipe(ignore),
))
.run(); .run();
} }

View file

@ -6,9 +6,7 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.init_resource::<Countdown>() .init_resource::<Countdown>()
.add_startup_system(setup) .add_systems((setup.on_startup(), countdown, print_when_completed))
.add_system(countdown)
.add_system(print_when_completed)
.run(); .run();
} }

View file

@ -43,8 +43,8 @@ fn main() {
display_score.in_schedule(OnEnter(GameState::GameOver)), display_score.in_schedule(OnEnter(GameState::GameOver)),
gameover_keyboard.in_set(OnUpdate(GameState::GameOver)), gameover_keyboard.in_set(OnUpdate(GameState::GameOver)),
teardown.in_schedule(OnExit(GameState::GameOver)), teardown.in_schedule(OnExit(GameState::GameOver)),
bevy::window::close_on_esc,
)) ))
.add_system(bevy::window::close_on_esc)
.run(); .run();
} }

View file

@ -11,12 +11,13 @@ use std::{
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup_contributor_selection) .add_startup_systems((setup_contributor_selection, setup))
.add_startup_system(setup) .add_systems((
.add_system(velocity_system) velocity_system,
.add_system(move_system) move_system,
.add_system(collision_system) collision_system,
.add_system(select_system) select_system,
))
.init_resource::<SelectionState>() .init_resource::<SelectionState>()
.run(); .run();
} }

View file

@ -58,15 +58,14 @@ mod splash {
impl Plugin for SplashPlugin { impl Plugin for SplashPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
// As this plugin is managing the splash screen, it will focus on the state `GameState::Splash` // As this plugin is managing the splash screen, it will focus on the state `GameState::Splash`
app app.add_systems((
// When entering the state, spawn everything needed for this screen // When entering the state, spawn everything needed for this screen
.add_system(splash_setup.in_schedule(OnEnter(GameState::Splash))) splash_setup.in_schedule(OnEnter(GameState::Splash)),
// While in this state, run the `countdown` system // While in this state, run the `countdown` system
.add_system(countdown.in_set(OnUpdate(GameState::Splash))) countdown.in_set(OnUpdate(GameState::Splash)),
// When exiting the state, despawn everything that was spawned for this screen // When exiting the state, despawn everything that was spawned for this screen
.add_system( despawn_screen::<OnSplashScreen>.in_schedule(OnExit(GameState::Splash)),
despawn_screen::<OnSplashScreen>.in_schedule(OnExit(GameState::Splash)), ));
);
} }
} }

View file

@ -10,8 +10,7 @@ use bevy::{
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_system(gamepad_events) .add_systems((gamepad_events, gamepad_ordered_events))
.add_system(gamepad_ordered_events)
.run(); .run();
} }

View file

@ -9,12 +9,14 @@ use bevy::{input::keyboard::KeyboardInput, prelude::*};
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_startup_system(setup_scene) .add_systems((
.add_system(toggle_ime) setup_scene.on_startup(),
.add_system(listen_ime_events) toggle_ime,
.add_system(listen_received_character_events) listen_ime_events,
.add_system(listen_keyboard_input_events) listen_received_character_events,
.add_system(bubbling_text) listen_keyboard_input_events,
bubbling_text,
))
.run(); .run();
} }

View file

@ -12,10 +12,8 @@ fn main() {
}), }),
..default() ..default()
})) }))
.add_startup_system(setup_scene) .add_startup_systems((setup_scene, setup_music))
.add_startup_system(setup_music) .add_systems((touch_camera, button_handler))
.add_system(touch_camera)
.add_system(button_handler)
.run(); .run();
} }

View file

@ -14,9 +14,7 @@ fn main() {
})) }))
.register_type::<ComponentA>() .register_type::<ComponentA>()
.register_type::<ComponentB>() .register_type::<ComponentB>()
.add_startup_system(save_scene_system) .add_startup_systems((save_scene_system, load_scene_system, infotext_system))
.add_startup_system(load_scene_system)
.add_startup_system(infotext_system)
.add_system(log_system) .add_system(log_system)
.run(); .run();
} }

View file

@ -11,8 +11,7 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(MaterialPlugin::<ArrayTextureMaterial>::default()) .add_plugin(MaterialPlugin::<ArrayTextureMaterial>::default())
.add_startup_system(setup) .add_systems((setup.on_startup(), create_array_texture))
.add_system(create_array_texture)
.run(); .run();
} }

View file

@ -23,8 +23,7 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(Material2dPlugin::<PostProcessingMaterial>::default()) .add_plugin(Material2dPlugin::<PostProcessingMaterial>::default())
.add_startup_system(setup) .add_systems((setup.on_startup(), main_camera_cube_rotator_system))
.add_system(main_camera_cube_rotator_system)
.run(); .run();
} }

View file

@ -85,8 +85,10 @@ impl Plugin for CustomMaterialPlugin {
.add_render_command::<Transparent3d, DrawCustom>() .add_render_command::<Transparent3d, DrawCustom>()
.init_resource::<CustomPipeline>() .init_resource::<CustomPipeline>()
.init_resource::<SpecializedMeshPipelines<CustomPipeline>>() .init_resource::<SpecializedMeshPipelines<CustomPipeline>>()
.add_system(queue_custom.in_set(RenderSet::Queue)) .add_systems((
.add_system(prepare_instance_buffers.in_set(RenderSet::Prepare)); queue_custom.in_set(RenderSet::Queue),
prepare_instance_buffers.in_set(RenderSet::Prepare),
));
} }
} }

View file

@ -10,8 +10,7 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(MaterialPlugin::<CustomMaterial>::default()) .add_plugin(MaterialPlugin::<CustomMaterial>::default())
.add_startup_system(setup) .add_systems((setup.on_startup(), rotate_camera))
.add_system(rotate_camera)
.run(); .run();
} }

View file

@ -28,9 +28,7 @@ fn main() {
prepass_enabled: false, prepass_enabled: false,
..default() ..default()
}) })
.add_startup_system(setup) .add_systems((setup.on_startup(), rotate, toggle_prepass_view))
.add_system(rotate)
.add_system(toggle_prepass_view)
.run(); .run();
} }

View file

@ -43,12 +43,14 @@ fn main() {
count: 0, count: 0,
color: Color::WHITE, color: Color::WHITE,
}) })
.add_startup_system(setup) .add_systems((
.add_system(mouse_handler) setup.on_startup(),
.add_system(movement_system) mouse_handler,
.add_system(collision_system) movement_system,
.add_system(counter_system) collision_system,
.add_system(scheduled_spawner.in_schedule(CoreSchedule::FixedUpdate)) counter_system,
scheduled_spawner.in_schedule(CoreSchedule::FixedUpdate),
))
.insert_resource(FixedTime::new_from_secs(0.2)) .insert_resource(FixedTime::new_from_secs(0.2))
.run(); .run();
} }

View file

@ -32,10 +32,12 @@ fn main() {
}), }),
..default() ..default()
})) }))
.add_startup_system(setup) .add_systems((
.add_system(animate_sprite) setup.on_startup(),
.add_system(print_sprite_count) animate_sprite,
.add_system(move_camera.after(print_sprite_count)) print_sprite_count,
move_camera.after(print_sprite_count),
))
.run(); .run();
} }

View file

@ -21,8 +21,7 @@ fn main() {
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.init_resource::<UiFont>() .init_resource::<UiFont>()
.add_startup_system(setup) .add_systems((setup.on_startup(), button_system))
.add_system(button_system)
.run(); .run();
} }

View file

@ -30,9 +30,7 @@ fn main() {
})) }))
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_startup_system(setup) .add_systems((setup.on_startup(), move_camera, print_mesh_count))
.add_system(move_camera)
.add_system(print_mesh_count)
.run(); .run();
} }

View file

@ -41,10 +41,12 @@ fn main() {
color: Color::WHITE, color: Color::WHITE,
brightness: 1.0, brightness: 1.0,
}) })
.add_startup_system(setup) .add_systems((
.add_system(setup_scene_once_loaded) setup.on_startup(),
.add_system(keyboard_animation_control) setup_scene_once_loaded,
.add_system(update_fox_rings.after(keyboard_animation_control)) keyboard_animation_control,
update_fox_rings.after(keyboard_animation_control),
))
.run(); .run();
} }

Some files were not shown because too many files have changed in this diff Show more