diff --git a/crates/bevy_app/src/app_builder.rs b/crates/bevy_app/src/app_builder.rs index 3c0b620ba46b5..fb69222b9b5ef 100644 --- a/crates/bevy_app/src/app_builder.rs +++ b/crates/bevy_app/src/app_builder.rs @@ -24,7 +24,7 @@ impl Default for AppBuilder { app_builder .add_default_stages() .add_event::() - .add_system_to_stage(stage::LAST, clear_trackers_system); + .add_system_to_stage(stage::LAST, clear_trackers_system.system()); app_builder } } @@ -125,68 +125,48 @@ impl AppBuilder { self } - pub fn add_system(&mut self, system: IntoS) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { + pub fn add_system>(&mut self, system: S) -> &mut Self { self.add_system_to_stage(stage::UPDATE, system) } - pub fn on_state_enter( + pub fn on_state_enter>( &mut self, stage: &str, state: T, - system: IntoS, - ) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { + system: S, + ) -> &mut Self { self.stage(stage, |stage: &mut StateStage| { stage.on_state_enter(state, system) }) } - pub fn on_state_update( + pub fn on_state_update>( &mut self, stage: &str, state: T, - system: IntoS, - ) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { + system: S, + ) -> &mut Self { self.stage(stage, |stage: &mut StateStage| { stage.on_state_update(state, system) }) } - pub fn on_state_exit( + pub fn on_state_exit>( &mut self, stage: &str, state: T, - system: IntoS, - ) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { + system: S, + ) -> &mut Self { self.stage(stage, |stage: &mut StateStage| { stage.on_state_exit(state, system) }) } - pub fn add_startup_system_to_stage( + pub fn add_startup_system_to_stage>( &mut self, stage_name: &'static str, - system: IntoS, - ) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { + system: S, + ) -> &mut Self { self.app .schedule .stage(stage::STARTUP, |schedule: &mut Schedule| { @@ -195,11 +175,7 @@ impl AppBuilder { self } - pub fn add_startup_system(&mut self, system: IntoS) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { + pub fn add_startup_system>(&mut self, system: S) -> &mut Self { self.add_startup_system_to_stage(startup_stage::STARTUP, system) } @@ -221,15 +197,11 @@ impl AppBuilder { .add_stage(stage::LAST, SystemStage::parallel()) } - pub fn add_system_to_stage( + pub fn add_system_to_stage>( &mut self, stage_name: &'static str, - system: IntoS, - ) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { + system: S, + ) -> &mut Self { self.app.schedule.add_system_to_stage(stage_name, system); self } @@ -239,7 +211,7 @@ impl AppBuilder { T: Send + Sync + 'static, { self.add_resource(Events::::default()) - .add_system_to_stage(stage::EVENT, Events::::update_system) + .add_system_to_stage(stage::EVENT, Events::::update_system.system()) } /// Adds a resource to the current [App] and overwrites any resource previously added of the same type. diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index 42f3a086fceed..1ae9ab5f48cae 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -2,7 +2,7 @@ use crate::{ update_asset_storage_system, Asset, AssetLoader, AssetServer, Handle, HandleId, RefChange, }; use bevy_app::{prelude::Events, AppBuilder}; -use bevy_ecs::{FromResources, ResMut}; +use bevy_ecs::{FromResources, IntoSystem, ResMut}; use bevy_reflect::RegisterTypeBuilder; use bevy_utils::HashMap; use crossbeam_channel::Sender; @@ -218,8 +218,14 @@ impl AddAsset for AppBuilder { }; self.add_resource(assets) - .add_system_to_stage(super::stage::ASSET_EVENTS, Assets::::asset_event_system) - .add_system_to_stage(crate::stage::LOAD_ASSETS, update_asset_storage_system::) + .add_system_to_stage( + super::stage::ASSET_EVENTS, + Assets::::asset_event_system.system(), + ) + .add_system_to_stage( + crate::stage::LOAD_ASSETS, + update_asset_storage_system::.system(), + ) .register_type::>() .add_event::>() } diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index ef2dc16dc872a..1e77e14443626 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -13,7 +13,7 @@ mod path; pub use asset_server::*; pub use assets::*; -use bevy_ecs::SystemStage; +use bevy_ecs::{IntoSystem, SystemStage}; use bevy_reflect::RegisterTypeBuilder; use bevy_tasks::IoTaskPool; pub use handle::*; @@ -88,13 +88,13 @@ impl Plugin for AssetPlugin { .register_type::() .add_system_to_stage( bevy_app::stage::PRE_UPDATE, - asset_server::free_unused_assets_system, + asset_server::free_unused_assets_system.system(), ); #[cfg(all( feature = "filesystem_watcher", all(not(target_arch = "wasm32"), not(target_os = "android")) ))] - app.add_system_to_stage(stage::LOAD_ASSETS, io::filesystem_watcher_system); + app.add_system_to_stage(stage::LOAD_ASSETS, io::filesystem_watcher_system.system()); } } diff --git a/crates/bevy_audio/src/lib.rs b/crates/bevy_audio/src/lib.rs index e2d6e4ef412d4..52b7a56dea06e 100644 --- a/crates/bevy_audio/src/lib.rs +++ b/crates/bevy_audio/src/lib.rs @@ -12,6 +12,7 @@ pub mod prelude { use bevy_app::prelude::*; use bevy_asset::AddAsset; +use bevy_ecs::IntoSystem; /// Adds support for audio playback to an App #[derive(Default)] @@ -23,6 +24,9 @@ impl Plugin for AudioPlugin { .add_asset::() .init_asset_loader::() .init_resource::>() - .add_system_to_stage(stage::POST_UPDATE, play_queued_audio_system::); + .add_system_to_stage( + stage::POST_UPDATE, + play_queued_audio_system::.system(), + ); } } diff --git a/crates/bevy_core/src/lib.rs b/crates/bevy_core/src/lib.rs index 198def8ee5703..468879e2363dc 100644 --- a/crates/bevy_core/src/lib.rs +++ b/crates/bevy_core/src/lib.rs @@ -6,6 +6,7 @@ mod time; use std::ops::Range; +use bevy_ecs::IntoSystem; use bevy_reflect::RegisterTypeBuilder; pub use bytes::*; pub use float_ord::*; @@ -37,7 +38,7 @@ impl Plugin for CorePlugin { .register_type::>() .register_type::>() .register_type::() - .add_system_to_stage(stage::FIRST, time_system) - .add_system_to_stage(stage::PRE_UPDATE, entity_labels_system); + .add_system_to_stage(stage::FIRST, time_system.system()) + .add_system_to_stage(stage::PRE_UPDATE, entity_labels_system.system()); } } diff --git a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs index 628a37104a9f7..9a6481b2dbd8e 100644 --- a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs @@ -1,7 +1,7 @@ use crate::{Diagnostic, DiagnosticId, Diagnostics}; use bevy_app::prelude::*; use bevy_core::Time; -use bevy_ecs::{Res, ResMut}; +use bevy_ecs::{IntoSystem, Res, ResMut}; /// Adds "frame time" diagnostic to an App, specifically "frame time", "fps" and "frame count" #[derive(Default)] @@ -13,9 +13,9 @@ pub struct FrameTimeDiagnosticsState { impl Plugin for FrameTimeDiagnosticsPlugin { fn build(&self, app: &mut bevy_app::AppBuilder) { - app.add_startup_system(Self::setup_system) + app.add_startup_system(Self::setup_system.system()) .add_resource(FrameTimeDiagnosticsState { frame_count: 0.0 }) - .add_system(Self::diagnostic_system); + .add_system(Self::diagnostic_system.system()); } } diff --git a/crates/bevy_diagnostic/src/print_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/print_diagnostics_plugin.rs index 9587b2290e446..e71f4b9066634 100644 --- a/crates/bevy_diagnostic/src/print_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/print_diagnostics_plugin.rs @@ -1,7 +1,7 @@ use super::{Diagnostic, DiagnosticId, Diagnostics}; use bevy_app::prelude::*; use bevy_core::{Time, Timer}; -use bevy_ecs::{Res, ResMut}; +use bevy_ecs::{IntoSystem, Res, ResMut}; use bevy_utils::Duration; /// An App Plugin that prints diagnostics to the console @@ -35,9 +35,12 @@ impl Plugin for PrintDiagnosticsPlugin { }); if self.debug { - app.add_system_to_stage(stage::POST_UPDATE, Self::print_diagnostics_debug_system); + app.add_system_to_stage( + stage::POST_UPDATE, + Self::print_diagnostics_debug_system.system(), + ); } else { - app.add_system_to_stage(stage::POST_UPDATE, Self::print_diagnostics_system); + app.add_system_to_stage(stage::POST_UPDATE, Self::print_diagnostics_system.system()); } } } diff --git a/crates/bevy_ecs/macros/src/lib.rs b/crates/bevy_ecs/macros/src/lib.rs index 65275cc2f8aba..f860219745d87 100644 --- a/crates/bevy_ecs/macros/src/lib.rs +++ b/crates/bevy_ecs/macros/src/lib.rs @@ -411,21 +411,27 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream { let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); let struct_name = &ast.ident; + let fetch_struct_name = Ident::new(&format!("Fetch{}", struct_name), Span::call_site()); TokenStream::from(quote! { - impl #impl_generics #path::SystemParam<()> for #struct_name#ty_generics #where_clause { + pub struct #fetch_struct_name; + impl #impl_generics #path::SystemParam for #struct_name#ty_generics #where_clause { + type Fetch = #fetch_struct_name; + } + + impl #impl_generics #path::FetchSystemParam<'a> for #fetch_struct_name { + type Item = #struct_name#ty_generics; fn init(system_state: &mut #path::SystemState, world: &#path::World, resources: &mut #path::Resources) { - #(<#field_types as SystemParam<()>>::init(system_state, world, resources);)* + #(<<#field_types as SystemParam>::Fetch as #path::FetchSystemParam>::init(system_state, world, resources);)* } unsafe fn get_param( - input: &mut Option<()>, - system_state: &mut #path::SystemState, - world: &#path::World, - resources: &#path::Resources, - ) -> Option { + system_state: &'a #path::SystemState, + world: &'a #path::World, + resources: &'a #path::Resources, + ) -> Option { Some(#struct_name { - #(#fields: <#field_types as SystemParam<()>>::get_param(input, system_state, world, resources)?,)* + #(#fields: <<#field_types as SystemParam>::Fetch as #path::FetchSystemParam>::get_param(system_state, world, resources)?,)* #(#ignored_fields: <#ignored_field_types>::default(),)* }) } diff --git a/crates/bevy_ecs/src/schedule/mod.rs b/crates/bevy_ecs/src/schedule/mod.rs index 30e2acd20df5c..9f70eda52e6e6 100644 --- a/crates/bevy_ecs/src/schedule/mod.rs +++ b/crates/bevy_ecs/src/schedule/mod.rs @@ -33,33 +33,24 @@ impl Schedule { self } - pub fn with_run_criteria(mut self, system: IntoS) -> Self - where - S: System, - IntoS: IntoSystem, - { + pub fn with_run_criteria>(mut self, system: S) -> Self { self.set_run_criteria(system); self } - pub fn with_system_in_stage( + pub fn with_system_in_stage>( mut self, stage_name: &'static str, - system: IntoS, - ) -> Self - where - S: System, - IntoS: IntoSystem, - { + system: S, + ) -> Self { self.add_system_to_stage(stage_name, system); self } - pub fn set_run_criteria(&mut self, system: IntoS) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { + pub fn set_run_criteria>( + &mut self, + system: S, + ) -> &mut Self { self.run_criteria = Some(Box::new(system.system())); self.run_criteria_initialized = false; self @@ -107,15 +98,11 @@ impl Schedule { self } - pub fn add_system_to_stage( + pub fn add_system_to_stage>( &mut self, stage_name: &'static str, - system: IntoS, - ) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { + system: S, + ) -> &mut Self { let stage = self .get_stage_mut::(stage_name) .unwrap_or_else(|| { @@ -124,7 +111,7 @@ impl Schedule { stage_name ) }); - stage.add_system(system); + stage.add_system(system.system()); self } @@ -221,7 +208,7 @@ mod tests { resource::{Res, ResMut, Resources}, schedule::{ParallelSystemStageExecutor, Schedule, SystemStage}, system::Query, - Commands, Entity, World, + Commands, Entity, IntoSystem, World, }; use bevy_tasks::{ComputeTaskPool, TaskPool}; use fixedbitset::FixedBitSet; @@ -255,10 +242,10 @@ mod tests { let mut schedule = Schedule::default(); let mut pre_archetype_change = SystemStage::parallel(); - pre_archetype_change.add_system(insert); + pre_archetype_change.add_system(insert.system()); schedule.add_stage("PreArchetypeChange", pre_archetype_change); let mut post_archetype_change = SystemStage::parallel(); - post_archetype_change.add_system(read); + post_archetype_change.add_system(read.system()); schedule.add_stage("PostArchetypeChange", post_archetype_change); schedule.initialize_and_run(&mut world, &mut resources); @@ -285,8 +272,8 @@ mod tests { } let mut update = SystemStage::parallel(); - update.add_system(insert); - update.add_system(read); + update.add_system(insert.system()); + update.add_system(read.system()); let mut schedule = Schedule::default(); schedule.add_stage("update", update); @@ -356,10 +343,10 @@ mod tests { completed_systems.insert(READ_U64_SYSTEM_NAME); } - stage_a.add_system(read_u32); - stage_a.add_system(write_float); - stage_a.add_system(read_u32_write_u64); - stage_a.add_system(read_u64); + stage_a.add_system(read_u32.system()); + stage_a.add_system(write_float.system()); + stage_a.add_system(read_u32_write_u64.system()); + stage_a.add_system(read_u64.system()); // B systems @@ -387,9 +374,9 @@ mod tests { completed_systems.insert(WRITE_F32_SYSTEM_NAME); } - stage_b.add_system(write_u64); - stage_b.add_system(thread_local_system); - stage_b.add_system(write_f32); + stage_b.add_system(write_u64.system()); + stage_b.add_system(thread_local_system.system()); + stage_b.add_system(write_f32.system()); // C systems @@ -424,10 +411,10 @@ mod tests { completed_systems.insert(WRITE_F64_RES_SYSTEM_NAME); } - stage_c.add_system(read_f64_res); - stage_c.add_system(read_isize_res); - stage_c.add_system(read_isize_write_f64_res); - stage_c.add_system(write_f64_res); + stage_c.add_system(read_f64_res.system()); + stage_c.add_system(read_isize_res.system()); + stage_c.add_system(read_isize_write_f64_res.system()); + stage_c.add_system(write_f64_res.system()); fn run_and_validate(schedule: &mut Schedule, world: &mut World, resources: &mut Resources) { schedule.initialize_and_run(world, resources); diff --git a/crates/bevy_ecs/src/schedule/stage.rs b/crates/bevy_ecs/src/schedule/stage.rs index 4917ac67f8e96..57e1eab31310b 100644 --- a/crates/bevy_ecs/src/schedule/stage.rs +++ b/crates/bevy_ecs/src/schedule/stage.rs @@ -1,8 +1,7 @@ use std::{any::TypeId, borrow::Cow}; use crate::{ - ArchetypeComponent, IntoSystem, Resources, System, SystemId, ThreadLocalExecution, TypeAccess, - World, + ArchetypeComponent, Resources, System, SystemId, ThreadLocalExecution, TypeAccess, World, }; use bevy_utils::HashSet; use downcast_rs::{impl_downcast, Downcast}; @@ -47,9 +46,7 @@ impl SystemStage { } } - pub fn single, Into: IntoSystem>( - system: Into, - ) -> Self { + pub fn single>(system: S) -> Self { Self::serial().with_system(system) } @@ -61,31 +58,19 @@ impl SystemStage { Self::new(Box::new(ParallelSystemStageExecutor::default())) } - pub fn with_system(mut self, system: IntoS) -> Self - where - S: System, - IntoS: IntoSystem, - { - self.add_system_boxed(Box::new(system.system())); + pub fn with_system>(mut self, system: S) -> Self { + self.add_system_boxed(Box::new(system)); self } - pub fn with_run_criteria(mut self, system: IntoS) -> Self - where - S: System, - IntoS: IntoSystem, - { - self.run_criteria = Some(Box::new(system.system())); + pub fn with_run_criteria>(mut self, system: S) -> Self { + self.run_criteria = Some(Box::new(system)); self.run_criteria_initialized = false; self } - pub fn add_system(&mut self, system: IntoS) -> &mut Self - where - S: System, - IntoS: IntoSystem, - { - self.add_system_boxed(Box::new(system.system())); + pub fn add_system>(&mut self, system: S) -> &mut Self { + self.add_system_boxed(Box::new(system)); self } diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index c023dc662575c..1fa6f0b2d9450 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -1,4 +1,4 @@ -use crate::{IntoSystem, Resource, Resources, Stage, System, SystemStage, World}; +use crate::{Resource, Resources, Stage, System, SystemStage, World}; use bevy_utils::HashMap; use std::{mem::Discriminant, ops::Deref}; use thiserror::Error; @@ -51,30 +51,30 @@ impl StateStage { self } - pub fn on_state_enter, IntoS: IntoSystem>( + pub fn on_state_enter>( &mut self, state: T, - system: IntoS, + system: S, ) -> &mut Self { self.enter_stage(state, |system_stage: &mut SystemStage| { system_stage.add_system(system) }) } - pub fn on_state_exit, IntoS: IntoSystem>( + pub fn on_state_exit>( &mut self, state: T, - system: IntoS, + system: S, ) -> &mut Self { self.exit_stage(state, |system_stage: &mut SystemStage| { system_stage.add_system(system) }) } - pub fn on_state_update, IntoS: IntoSystem>( + pub fn on_state_update>( &mut self, state: T, - system: IntoS, + system: S, ) -> &mut Self { self.update_stage(state, |system_stage: &mut SystemStage| { system_stage.add_system(system) diff --git a/crates/bevy_ecs/src/system/into_system.rs b/crates/bevy_ecs/src/system/into_system.rs index 364232cedbcea..53cda65efc7ca 100644 --- a/crates/bevy_ecs/src/system/into_system.rs +++ b/crates/bevy_ecs/src/system/into_system.rs @@ -1,9 +1,10 @@ +use super::system_param::FetchSystemParam; use crate::{ ArchetypeComponent, Commands, QueryAccess, Resources, System, SystemId, SystemParam, ThreadLocalExecution, TypeAccess, World, }; use parking_lot::Mutex; -use std::{any::TypeId, borrow::Cow, sync::Arc}; +use std::{any::TypeId, borrow::Cow, cell::UnsafeCell, sync::Arc}; pub struct SystemState { pub(crate) id: SystemId, @@ -14,14 +15,20 @@ pub struct SystemState { pub(crate) query_archetype_component_accesses: Vec>, pub(crate) query_accesses: Vec>, pub(crate) query_type_names: Vec<&'static str>, - pub(crate) commands: Commands, + pub(crate) commands: UnsafeCell, pub(crate) arc_commands: Option>>, - pub(crate) current_query_index: usize, + pub(crate) current_query_index: UnsafeCell, } +// SAFE: UnsafeCell and UnsafeCell only accessed from the thread they are scheduled on +unsafe impl Sync for SystemState {} + impl SystemState { pub fn reset_indices(&mut self) { - self.current_query_index = 0; + // SAFE: done with unique mutable access to Self + unsafe { + *self.current_query_index.get() = 0; + } } pub fn update(&mut self, world: &World) { @@ -72,7 +79,62 @@ impl SystemState { } } -pub struct FuncSystem { +pub struct FuncSystem { + func: + Box Option + Send + Sync + 'static>, + thread_local_func: + Box, + init_func: Box, + state: SystemState, +} + +impl System for FuncSystem { + type In = (); + type Out = Out; + + fn name(&self) -> std::borrow::Cow<'static, str> { + self.state.name.clone() + } + + fn id(&self) -> SystemId { + self.state.id + } + + fn update(&mut self, world: &World) { + self.state.update(world); + } + + fn archetype_component_access(&self) -> &TypeAccess { + &self.state.archetype_component_access + } + + fn resource_access(&self) -> &TypeAccess { + &self.state.resource_access + } + + fn thread_local_execution(&self) -> ThreadLocalExecution { + ThreadLocalExecution::NextFlush + } + + unsafe fn run_unsafe( + &mut self, + _input: Self::In, + world: &World, + resources: &Resources, + ) -> Option { + (self.func)(&mut self.state, world, resources) + } + + fn run_thread_local(&mut self, world: &mut World, resources: &mut Resources) { + (self.thread_local_func)(&mut self.state, world, resources) + } + + fn initialize(&mut self, world: &mut World, resources: &mut Resources) { + (self.init_func)(&mut self.state, world, resources); + } +} + +pub struct InputFuncSystem { func: Box< dyn FnMut(In, &mut SystemState, &World, &Resources) -> Option + Send + Sync + 'static, >, @@ -82,7 +144,7 @@ pub struct FuncSystem { state: SystemState, } -impl System for FuncSystem { +impl System for InputFuncSystem { type In = In; type Out = Out; @@ -138,16 +200,21 @@ impl IntoSystem<(), Sys> for Sys { self } } +pub struct In(pub In); macro_rules! impl_into_system { ($($param: ident),*) => { - impl),*> IntoSystem<($($param,)*), FuncSystem> for Func - where Func: FnMut($($param),*) -> Out + Send + Sync + 'static, Out: 'static, In: 'static + impl IntoSystem<($($param,)*), FuncSystem> for Func + where + Func: + FnMut($($param),*) -> Out + + FnMut($(<<$param as SystemParam>::Fetch as FetchSystemParam>::Item),*) -> Out + + Send + Sync + 'static, Out: 'static { #[allow(unused_variables)] #[allow(unused_unsafe)] #[allow(non_snake_case)] - fn system(mut self) -> FuncSystem { + fn system(mut self) -> FuncSystem { FuncSystem { state: SystemState { name: std::any::type_name::().into(), @@ -155,18 +222,18 @@ macro_rules! impl_into_system { resource_access: TypeAccess::default(), local_resource_access: TypeAccess::default(), id: SystemId::new(), - commands: Commands::default(), + commands: Default::default(), arc_commands: Default::default(), + current_query_index: Default::default(), query_archetype_component_accesses: Vec::new(), query_accesses: Vec::new(), query_type_names: Vec::new(), - current_query_index: 0, }, - func: Box::new(move |input, state, world, resources| { + func: Box::new(move |state, world, resources| { state.reset_indices(); - let mut input = Some(input); + // let mut input = Some(input); unsafe { - if let Some(($($param,)*)) = <($($param,)*)>::get_param(&mut input, state, world, resources) { + if let Some(($($param,)*)) = <<($($param,)*) as SystemParam>::Fetch as FetchSystemParam>::get_param(state, world, resources) { Some(self($($param),*)) } else { None @@ -174,14 +241,69 @@ macro_rules! impl_into_system { } }), thread_local_func: Box::new(|state, world, resources| { - state.commands.apply(world, resources); + // SAFE: this is called with unique access to SystemState + unsafe { + (&mut *state.commands.get()).apply(world, resources); + } + if let Some(ref commands) = state.arc_commands { + let mut commands = commands.lock(); + commands.apply(world, resources); + } + }), + init_func: Box::new(|state, world, resources| { + <<($($param,)*) as SystemParam>::Fetch as FetchSystemParam>::init(state, world, resources) + }), + } + } + } + impl IntoSystem<(Input, $($param,)*), InputFuncSystem> for Func + where + Func: + FnMut(In, $($param),*) -> Out + + FnMut(In, $(<<$param as SystemParam>::Fetch as FetchSystemParam>::Item),*) -> Out + + Send + Sync + 'static, Input: 'static, Out: 'static + { + #[allow(unused_variables)] + #[allow(unused_unsafe)] + #[allow(non_snake_case)] + fn system(mut self) -> InputFuncSystem { + InputFuncSystem { + state: SystemState { + name: std::any::type_name::().into(), + archetype_component_access: TypeAccess::default(), + resource_access: TypeAccess::default(), + local_resource_access: TypeAccess::default(), + id: SystemId::new(), + commands: Default::default(), + arc_commands: Default::default(), + current_query_index: Default::default(), + query_archetype_component_accesses: Vec::new(), + query_accesses: Vec::new(), + query_type_names: Vec::new(), + }, + func: Box::new(move |input, state, world, resources| { + state.reset_indices(); + // let mut input = Some(input); + unsafe { + if let Some(($($param,)*)) = <<($($param,)*) as SystemParam>::Fetch as FetchSystemParam>::get_param(state, world, resources) { + Some(self(In(input), $($param),*)) + } else { + None + } + } + }), + thread_local_func: Box::new(|state, world, resources| { + // SAFE: this is called with unique access to SystemState + unsafe { + (&mut *state.commands.get()).apply(world, resources); + } if let Some(ref commands) = state.arc_commands { let mut commands = commands.lock(); commands.apply(world, resources); } }), init_func: Box::new(|state, world, resources| { - $($param::init(state, world, resources);)* + <<($($param,)*) as SystemParam>::Fetch as FetchSystemParam>::init(state, world, resources) }), } } @@ -277,7 +399,7 @@ mod tests { world.spawn((A, C)); world.spawn((A, D)); - run_system(&mut world, &mut resources, query_system); + run_system(&mut world, &mut resources, query_system.system()); assert!(*resources.get::().unwrap(), "system ran"); } @@ -286,12 +408,14 @@ mod tests { fn or_query_set_system() { // Regression test for issue #762 use crate::{Added, Changed, Mutated, Or}; - let query_system = move |mut ran: ResMut, - set: QuerySet<( - Query<(), Or<(Changed, Changed)>>, - Query<(), Or<(Added, Added)>>, - Query<(), Or<(Mutated, Mutated)>>, - )>| { + fn query_system( + mut ran: ResMut, + set: QuerySet<( + Query<(), Or<(Changed, Changed)>>, + Query<(), Or<(Added, Added)>>, + Query<(), Or<(Mutated, Mutated)>>, + )>, + ) { let changed = set.q0().iter().count(); let added = set.q1().iter().count(); let mutated = set.q2().iter().count(); @@ -308,7 +432,7 @@ mod tests { resources.insert(false); world.spawn((A, B)); - run_system(&mut world, &mut resources, query_system); + run_system(&mut world, &mut resources, query_system.system()); assert!(*resources.get::().unwrap(), "system ran"); } @@ -328,9 +452,12 @@ mod tests { let mut schedule = Schedule::default(); let mut update = SystemStage::parallel(); - update.add_system(incr_e_on_flip); + update.add_system(incr_e_on_flip.system()); schedule.add_stage("update", update); - schedule.add_stage("clear_trackers", SystemStage::single(clear_trackers_system)); + schedule.add_stage( + "clear_trackers", + SystemStage::single(clear_trackers_system.system()), + ); schedule.initialize_and_run(&mut world, &mut resources); assert_eq!(*(world.get::(ent).unwrap()), 1); @@ -362,9 +489,12 @@ mod tests { let mut schedule = Schedule::default(); let mut update = SystemStage::parallel(); - update.add_system(incr_e_on_flip); + update.add_system(incr_e_on_flip.system()); schedule.add_stage("update", update); - schedule.add_stage("clear_trackers", SystemStage::single(clear_trackers_system)); + schedule.add_stage( + "clear_trackers", + SystemStage::single(clear_trackers_system.system()), + ); schedule.initialize_and_run(&mut world, &mut resources); assert_eq!(*(world.get::(ent).unwrap()), 1); @@ -393,7 +523,7 @@ mod tests { let mut resources = Resources::default(); world.spawn((A,)); - run_system(&mut world, &mut resources, sys); + run_system(&mut world, &mut resources, sys.system()); } #[test] @@ -405,7 +535,7 @@ mod tests { let mut resources = Resources::default(); world.spawn((A,)); - run_system(&mut world, &mut resources, sys); + run_system(&mut world, &mut resources, sys.system()); } #[test] @@ -416,7 +546,7 @@ mod tests { let mut resources = Resources::default(); world.spawn((A,)); - run_system(&mut world, &mut resources, sys); + run_system(&mut world, &mut resources, sys.system()); } #[test] @@ -428,7 +558,7 @@ mod tests { let mut resources = Resources::default(); world.spawn((A,)); - run_system(&mut world, &mut resources, sys); + run_system(&mut world, &mut resources, sys.system()); } #[test] @@ -439,17 +569,13 @@ mod tests { let mut world = World::default(); let mut resources = Resources::default(); world.spawn((A,)); - run_system(&mut world, &mut resources, sys); + run_system(&mut world, &mut resources, sys.system()); } - fn run_system< - Params, - SystemType: System, - Sys: IntoSystem, - >( + fn run_system>( world: &mut World, resources: &mut Resources, - system: Sys, + system: S, ) { let mut schedule = Schedule::default(); let mut update = SystemStage::parallel(); @@ -463,40 +589,34 @@ mod tests { _buffer: Vec, } - fn test_for_conflicting_resources< - Params, - SystemType: System, - Sys: IntoSystem, - >( - sys: Sys, - ) { + fn test_for_conflicting_resources>(sys: S) { let mut world = World::default(); let mut resources = Resources::default(); resources.insert(BufferRes::default()); resources.insert(A); resources.insert(B); - run_system(&mut world, &mut resources, sys); + run_system(&mut world, &mut resources, sys.system()); } #[test] #[should_panic] fn conflicting_system_resources() { fn sys(_: ResMut, _: Res) {} - test_for_conflicting_resources(sys) + test_for_conflicting_resources(sys.system()) } #[test] #[should_panic] fn conflicting_system_resources_reverse_order() { fn sys(_: Res, _: ResMut) {} - test_for_conflicting_resources(sys) + test_for_conflicting_resources(sys.system()) } #[test] #[should_panic] fn conflicting_system_resources_multiple_mutable() { fn sys(_: ResMut, _: ResMut) {} - test_for_conflicting_resources(sys) + test_for_conflicting_resources(sys.system()) } #[test] @@ -504,19 +624,19 @@ mod tests { fn conflicting_changed_and_mutable_resource() { // A tempting pattern, but unsound if allowed. fn sys(_: ResMut, _: ChangedRes) {} - test_for_conflicting_resources(sys) + test_for_conflicting_resources(sys.system()) } #[test] #[should_panic] fn conflicting_system_local_resources() { fn sys(_: Local, _: Local) {} - test_for_conflicting_resources(sys) + test_for_conflicting_resources(sys.system()) } #[test] fn nonconflicting_system_resources() { fn sys(_: Local, _: ResMut, _: Local, _: ResMut) {} - test_for_conflicting_resources(sys) + test_for_conflicting_resources(sys.system()) } } diff --git a/crates/bevy_ecs/src/system/system_chaining.rs b/crates/bevy_ecs/src/system/system_chaining.rs index 7822b3d85d7db..b0cfd4c055a9b 100644 --- a/crates/bevy_ecs/src/system/system_chaining.rs +++ b/crates/bevy_ecs/src/system/system_chaining.rs @@ -1,6 +1,5 @@ use crate::{ - ArchetypeComponent, IntoSystem, Resources, System, SystemId, ThreadLocalExecution, TypeAccess, - World, + ArchetypeComponent, Resources, System, SystemId, ThreadLocalExecution, TypeAccess, World, }; use std::{any::TypeId, borrow::Cow}; @@ -69,31 +68,23 @@ impl> System for ChainSystem } } -pub trait IntoChainSystem: - IntoSystem + Sized +pub trait IntoChainSystem: System + Sized where - IntoB: IntoSystem, - SystemA: System, - SystemB: System, + SystemB: System, { - fn chain(self, system: IntoB) -> ChainSystem; + fn chain(self, system: SystemB) -> ChainSystem; } -impl - IntoChainSystem for IntoA +impl IntoChainSystem for SystemA where SystemA: System, SystemB: System, - IntoA: IntoSystem, - IntoB: IntoSystem, { - fn chain(self, system: IntoB) -> ChainSystem { - let system_a = self.system(); - let system_b = system.system(); + fn chain(self, system: SystemB) -> ChainSystem { ChainSystem { - name: Cow::Owned(format!("Chain({}, {})", system_a.name(), system_b.name())), - system_a, - system_b, + name: Cow::Owned(format!("Chain({}, {})", self.name(), system.name())), + system_a: self, + system_b: system, archetype_component_access: Default::default(), resource_access: Default::default(), id: SystemId::new(), diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 2a29afc9f554f..0b29e91371e0c 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -4,50 +4,43 @@ use crate::{ SystemState, TypeAccess, World, WorldQuery, }; use parking_lot::Mutex; -use std::{any::TypeId, sync::Arc}; - -pub struct In(pub Input); - -impl SystemParam for In { - #[inline] - unsafe fn get_param( - input: &mut Option, - _system_state: &mut SystemState, - _world: &World, - _resources: &Resources, - ) -> Option { - Some(In(input.take().unwrap())) - } - - fn init(_system_state: &mut SystemState, _world: &World, _resources: &mut Resources) {} +use std::{any::TypeId, marker::PhantomData, sync::Arc}; +pub trait SystemParam: Sized { + type Fetch: for<'a> FetchSystemParam<'a>; } -pub trait SystemParam: Sized { +pub trait FetchSystemParam<'a> { + type Item; fn init(system_state: &mut SystemState, world: &World, resources: &mut Resources); /// # Safety /// This call might access any of the input parameters in an unsafe way. Make sure the data access is safe in /// the context of the system scheduler unsafe fn get_param( - input: &mut Option, - system_state: &mut SystemState, - world: &World, - resources: &Resources, - ) -> Option; + system_state: &'a SystemState, + world: &'a World, + resources: &'a Resources, + ) -> Option; +} + +pub struct FetchQuery(PhantomData<(Q, F)>); + +impl<'a, Q: WorldQuery, F: QueryFilter> SystemParam for Query<'a, Q, F> { + type Fetch = FetchQuery; } -impl<'a, Q: WorldQuery, F: QueryFilter, Input> SystemParam for Query<'a, Q, F> { +impl<'a, Q: WorldQuery, F: QueryFilter> FetchSystemParam<'a> for FetchQuery { + type Item = Query<'a, Q, F>; + #[inline] unsafe fn get_param( - _input: &mut Option, - system_state: &mut SystemState, - world: &World, - _resources: &Resources, - ) -> Option { - let query_index = system_state.current_query_index; - let world: &'a World = std::mem::transmute(world); + system_state: &'a SystemState, + world: &'a World, + _resources: &'a Resources, + ) -> Option { + let query_index = *system_state.current_query_index.get(); let archetype_component_access: &'a TypeAccess = - std::mem::transmute(&system_state.query_archetype_component_accesses[query_index]); - system_state.current_query_index += 1; + &system_state.query_archetype_component_accesses[query_index]; + *system_state.current_query_index.get() += 1; Some(Query::new(world, archetype_component_access)) } @@ -63,16 +56,23 @@ impl<'a, Q: WorldQuery, F: QueryFilter, Input> SystemParam for Query<'a, } } -impl SystemParam for QuerySet { +pub struct FetchQuerySet(PhantomData); + +impl SystemParam for QuerySet { + type Fetch = FetchQuerySet; +} + +impl<'a, T: QueryTuple> FetchSystemParam<'a> for FetchQuerySet { + type Item = QuerySet; + #[inline] unsafe fn get_param( - _input: &mut Option, - system_state: &mut SystemState, - world: &World, - _resources: &Resources, - ) -> Option { - let query_index = system_state.current_query_index; - system_state.current_query_index += 1; + system_state: &'a SystemState, + world: &'a World, + _resources: &'a Resources, + ) -> Option { + let query_index = *system_state.current_query_index.get(); + *system_state.current_query_index.get() += 1; Some(QuerySet::new( world, &system_state.query_archetype_component_accesses[query_index], @@ -90,26 +90,39 @@ impl SystemParam for QuerySet { } } -impl<'a, Input> SystemParam for &'a mut Commands { +pub struct FetchCommands; + +impl<'a> SystemParam for &'a mut Commands { + type Fetch = FetchCommands; +} +impl<'a> FetchSystemParam<'a> for FetchCommands { + type Item = &'a mut Commands; + fn init(system_state: &mut SystemState, world: &World, _resources: &mut Resources) { - system_state - .commands - .set_entity_reserver(world.get_entity_reserver()) + // SAFE: this is called with unique access to SystemState + unsafe { + (&mut *system_state.commands.get()).set_entity_reserver(world.get_entity_reserver()) + } } #[inline] unsafe fn get_param( - _input: &mut Option, - system_state: &mut SystemState, - _world: &World, - _resources: &Resources, - ) -> Option { - let commands: &'a mut Commands = std::mem::transmute(&mut system_state.commands); - Some(commands) + system_state: &'a SystemState, + _world: &'a World, + _resources: &'a Resources, + ) -> Option { + Some(&mut *system_state.commands.get()) } } -impl SystemParam for Arc> { +pub struct FetchArcCommands; +impl SystemParam for Arc> { + type Fetch = FetchArcCommands; +} + +impl<'a> FetchSystemParam<'a> for FetchArcCommands { + type Item = Arc>; + fn init(system_state: &mut SystemState, world: &World, _resources: &mut Resources) { system_state.arc_commands.get_or_insert_with(|| { let mut commands = Commands::default(); @@ -120,16 +133,23 @@ impl SystemParam for Arc> { #[inline] unsafe fn get_param( - _input: &mut Option, - system_state: &mut SystemState, + system_state: &SystemState, _world: &World, _resources: &Resources, - ) -> Option { + ) -> Option { Some(system_state.arc_commands.as_ref().unwrap().clone()) } } -impl<'a, T: Resource, Input> SystemParam for Res<'a, T> { +pub struct FetchRes(PhantomData); + +impl<'a, T: Resource> SystemParam for Res<'a, T> { + type Fetch = FetchRes; +} + +impl<'a, T: Resource> FetchSystemParam<'a> for FetchRes { + type Item = Res<'a, T>; + fn init(system_state: &mut SystemState, _world: &World, _resources: &mut Resources) { if system_state.resource_access.is_write(&TypeId::of::()) { panic!( @@ -144,18 +164,24 @@ impl<'a, T: Resource, Input> SystemParam for Res<'a, T> { #[inline] unsafe fn get_param( - _input: &mut Option, - _system_state: &mut SystemState, - _world: &World, - resources: &Resources, - ) -> Option { + _system_state: &'a SystemState, + _world: &'a World, + resources: &'a Resources, + ) -> Option { Some(Res::new( resources.get_unsafe_ref::(ResourceIndex::Global), )) } } -impl<'a, T: Resource, Input> SystemParam for ResMut<'a, T> { +pub struct FetchResMut(PhantomData); + +impl<'a, T: Resource> SystemParam for ResMut<'a, T> { + type Fetch = FetchResMut; +} +impl<'a, T: Resource> FetchSystemParam<'a> for FetchResMut { + type Item = ResMut<'a, T>; + fn init(system_state: &mut SystemState, _world: &World, _resources: &mut Resources) { // If a system already has access to the resource in another parameter, then we fail early. // e.g. `fn(Res, ResMut)` or `fn(ResMut, ResMut)` must not be allowed. @@ -175,18 +201,25 @@ impl<'a, T: Resource, Input> SystemParam for ResMut<'a, T> { #[inline] unsafe fn get_param( - _input: &mut Option, - _system_state: &mut SystemState, - _world: &World, - resources: &Resources, - ) -> Option { + _system_state: &'a SystemState, + _world: &'a World, + resources: &'a Resources, + ) -> Option { let (value, _added, mutated) = resources.get_unsafe_ref_with_added_and_mutated::(ResourceIndex::Global); Some(ResMut::new(value, mutated)) } } -impl<'a, T: Resource, Input> SystemParam for ChangedRes<'a, T> { +pub struct FetchChangedRes(PhantomData); + +impl<'a, T: Resource> SystemParam for ChangedRes<'a, T> { + type Fetch = FetchChangedRes; +} + +impl<'a, T: Resource> FetchSystemParam<'a> for FetchChangedRes { + type Item = ChangedRes<'a, T>; + fn init(system_state: &mut SystemState, _world: &World, _resources: &mut Resources) { if system_state.resource_access.is_write(&TypeId::of::()) { panic!( @@ -201,11 +234,10 @@ impl<'a, T: Resource, Input> SystemParam for ChangedRes<'a, T> { #[inline] unsafe fn get_param( - _input: &mut Option, - _system_state: &mut SystemState, - _world: &World, - resources: &Resources, - ) -> Option { + _system_state: &'a SystemState, + _world: &'a World, + resources: &'a Resources, + ) -> Option { let (value, added, mutated) = resources.get_unsafe_ref_with_added_and_mutated::(ResourceIndex::Global); if *added.as_ptr() || *mutated.as_ptr() { @@ -216,7 +248,14 @@ impl<'a, T: Resource, Input> SystemParam for ChangedRes<'a, T> { } } -impl<'a, T: Resource + FromResources, Input> SystemParam for Local<'a, T> { +pub struct FetchLocal(PhantomData); + +impl<'a, T: Resource + FromResources> SystemParam for Local<'a, T> { + type Fetch = FetchLocal; +} +impl<'a, T: Resource + FromResources> FetchSystemParam<'a> for FetchLocal { + type Item = Local<'a, T>; + fn init(system_state: &mut SystemState, _world: &World, resources: &mut Resources) { if system_state .local_resource_access @@ -244,52 +283,61 @@ impl<'a, T: Resource + FromResources, Input> SystemParam for Local<'a, T> #[inline] unsafe fn get_param( - _input: &mut Option, - system_state: &mut SystemState, - _world: &World, - resources: &Resources, - ) -> Option { + system_state: &'a SystemState, + _world: &'a World, + resources: &'a Resources, + ) -> Option { Some(Local::new(resources, system_state.id)) } } +pub struct FetchParamTuple(PhantomData); +pub struct FetchOr(PhantomData); + macro_rules! impl_system_param_tuple { ($($param: ident),*) => { + impl<$($param: SystemParam),*> SystemParam for ($($param,)*) { + type Fetch = FetchParamTuple<($($param::Fetch,)*)>; + } #[allow(unused_variables)] - impl),*> SystemParam for ($($param,)*) { + impl<'a, $($param: FetchSystemParam<'a>),*> FetchSystemParam<'a> for FetchParamTuple<($($param,)*)> { + type Item = ($($param::Item,)*); fn init(system_state: &mut SystemState, world: &World, resources: &mut Resources) { $($param::init(system_state, world, resources);)* } #[inline] unsafe fn get_param( - input: &mut Option, - system_state: &mut SystemState, - world: &World, - resources: &Resources, - ) -> Option { - Some(($($param::get_param(input, system_state, world, resources)?,)*)) + system_state: &'a SystemState, + world: &'a World, + resources: &'a Resources, + ) -> Option { + Some(($($param::get_param(system_state, world, resources)?,)*)) } } + impl<$($param: SystemParam),*> SystemParam for Or<($(Option<$param>,)*)> { + type Fetch = FetchOr<($($param::Fetch,)*)>; + } + #[allow(unused_variables)] #[allow(unused_mut)] #[allow(non_snake_case)] - impl),*> SystemParam for Or<($(Option<$param>,)*)> { + impl<'a, $($param: FetchSystemParam<'a>),*> FetchSystemParam<'a> for FetchOr<($($param,)*)> { + type Item = Or<($(Option<$param::Item>,)*)>; fn init(system_state: &mut SystemState, world: &World, resources: &mut Resources) { $($param::init(system_state, world, resources);)* } #[inline] unsafe fn get_param( - input: &mut Option, - system_state: &mut SystemState, - world: &World, - resources: &Resources, - ) -> Option { + system_state: &'a SystemState, + world: &'a World, + resources: &'a Resources, + ) -> Option { let mut has_some = false; $( - let $param = $param::get_param(input, system_state, world, resources); + let $param = $param::get_param(system_state, world, resources); if $param.is_some() { has_some = true; } diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index f07d925709f37..0149a16fd98e3 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -2,6 +2,7 @@ mod converter; mod gilrs_system; use bevy_app::{prelude::*, startup_stage::PRE_STARTUP}; +use bevy_ecs::IntoSystem; use bevy_utils::tracing::error; use gilrs::GilrsBuilder; use gilrs_system::{gilrs_event_startup_system, gilrs_event_system}; @@ -18,8 +19,8 @@ impl Plugin for GilrsPlugin { { Ok(gilrs) => { app.add_thread_local_resource(gilrs) - .add_startup_system_to_stage(PRE_STARTUP, gilrs_event_startup_system) - .add_system_to_stage(stage::PRE_EVENT, gilrs_event_system); + .add_startup_system_to_stage(PRE_STARTUP, gilrs_event_startup_system.system()) + .add_system_to_stage(stage::PRE_EVENT, gilrs_event_system.system()); } Err(err) => error!("Failed to start Gilrs. {}", err), } diff --git a/crates/bevy_input/src/lib.rs b/crates/bevy_input/src/lib.rs index 4ef0ccaeef52e..ba81fc2bab987 100644 --- a/crates/bevy_input/src/lib.rs +++ b/crates/bevy_input/src/lib.rs @@ -7,6 +7,7 @@ pub mod system; pub mod touch; pub use axis::*; +use bevy_ecs::IntoSystem; pub use input::*; pub mod prelude { @@ -43,20 +44,23 @@ impl Plugin for InputPlugin { .add_event::() .add_event::() .init_resource::>() - .add_system_to_stage(bevy_app::stage::EVENT, keyboard_input_system) + .add_system_to_stage(bevy_app::stage::EVENT, keyboard_input_system.system()) .init_resource::>() - .add_system_to_stage(bevy_app::stage::EVENT, mouse_button_input_system) + .add_system_to_stage(bevy_app::stage::EVENT, mouse_button_input_system.system()) .add_event::() .add_event::() .init_resource::() .init_resource::>() .init_resource::>() .init_resource::>() - .add_system_to_stage(bevy_app::stage::EVENT, gamepad_event_system) - .add_startup_system_to_stage(bevy_app::startup_stage::STARTUP, gamepad_event_system) + .add_system_to_stage(bevy_app::stage::EVENT, gamepad_event_system.system()) + .add_startup_system_to_stage( + bevy_app::startup_stage::STARTUP, + gamepad_event_system.system(), + ) .add_event::() .init_resource::() - .add_system_to_stage(bevy_app::stage::EVENT, touch_screen_input_system); + .add_system_to_stage(bevy_app::stage::EVENT, touch_screen_input_system.system()); } } diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index c5aa76be1261b..fc7a5b2c061ce 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -4,6 +4,7 @@ mod entity; mod light; mod material; +use bevy_ecs::IntoSystem; pub use entity::*; pub use light::*; pub use material::*; @@ -29,7 +30,7 @@ impl Plugin for PbrPlugin { .register_type::() .add_system_to_stage( stage::POST_UPDATE, - shader::asset_shader_defs_system::, + shader::asset_shader_defs_system::.system(), ) .init_resource::(); let resources = app.resources(); diff --git a/crates/bevy_render/src/draw.rs b/crates/bevy_render/src/draw.rs index 25d6be663d1ef..0da2b9e67cab0 100644 --- a/crates/bevy_render/src/draw.rs +++ b/crates/bevy_render/src/draw.rs @@ -147,9 +147,6 @@ pub struct DrawContext<'a> { pub current_pipeline: Option>, } -#[derive(Debug)] -pub struct FetchDrawContext; - impl<'a> DrawContext<'a> { pub fn get_uniform_buffer( &mut self, diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 2aa74b8909e60..c158d53824917 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -11,7 +11,7 @@ pub mod renderer; pub mod shader; pub mod texture; -use bevy_ecs::SystemStage; +use bevy_ecs::{IntoSystem, SystemStage}; use bevy_reflect::RegisterTypeBuilder; use draw::Visible; pub use once_cell; @@ -136,30 +136,48 @@ impl Plugin for RenderPlugin { .init_resource::() .init_resource::() .init_resource::() - .add_system_to_stage(bevy_app::stage::PRE_UPDATE, draw::clear_draw_system) - .add_system_to_stage(bevy_app::stage::POST_UPDATE, camera::active_cameras_system) + .add_system_to_stage( + bevy_app::stage::PRE_UPDATE, + draw::clear_draw_system.system(), + ) + .add_system_to_stage( + bevy_app::stage::POST_UPDATE, + camera::active_cameras_system.system(), + ) .add_system_to_stage( bevy_app::stage::POST_UPDATE, - camera::camera_system::, + camera::camera_system::.system(), ) .add_system_to_stage( bevy_app::stage::POST_UPDATE, - camera::camera_system::, + camera::camera_system::.system(), ) // registration order matters here. this must come after all camera_system:: systems .add_system_to_stage( bevy_app::stage::POST_UPDATE, - camera::visible_entities_system, + camera::visible_entities_system.system(), + ) + .add_system_to_stage( + stage::RENDER_RESOURCE, + shader::shader_update_system.system(), + ) + .add_system_to_stage( + stage::RENDER_RESOURCE, + mesh::mesh_resource_provider_system.system(), + ) + .add_system_to_stage( + stage::RENDER_RESOURCE, + Texture::texture_resource_system.system(), ) - .add_system_to_stage(stage::RENDER_RESOURCE, shader::shader_update_system) - .add_system_to_stage(stage::RENDER_RESOURCE, mesh::mesh_resource_provider_system) - .add_system_to_stage(stage::RENDER_RESOURCE, Texture::texture_resource_system) .add_system_to_stage( stage::RENDER_GRAPH_SYSTEMS, - render_graph::render_graph_schedule_executor_system, + render_graph::render_graph_schedule_executor_system.system(), ) - .add_system_to_stage(stage::DRAW, pipeline::draw_render_pipelines_system) - .add_system_to_stage(stage::POST_RENDER, shader::clear_shader_defs_system); + .add_system_to_stage(stage::DRAW, pipeline::draw_render_pipelines_system.system()) + .add_system_to_stage( + stage::POST_RENDER, + shader::clear_shader_defs_system.system(), + ); if app.resources().get::().is_none() { app.init_resource::(); diff --git a/crates/bevy_scene/src/lib.rs b/crates/bevy_scene/src/lib.rs index 8bf00bda2831b..349007910a808 100644 --- a/crates/bevy_scene/src/lib.rs +++ b/crates/bevy_scene/src/lib.rs @@ -5,7 +5,7 @@ mod scene_loader; mod scene_spawner; pub mod serde; -use bevy_ecs::SystemStage; +use bevy_ecs::{IntoSystem, SystemStage}; pub use command::*; pub use dynamic_scene::*; pub use scene::*; @@ -33,6 +33,6 @@ impl Plugin for ScenePlugin { .init_asset_loader::() .init_resource::() .add_stage_after(stage::EVENT, SCENE_STAGE, SystemStage::parallel()) - .add_system_to_stage(SCENE_STAGE, scene_spawner_system); + .add_system_to_stage(SCENE_STAGE, scene_spawner_system.system()); } } diff --git a/crates/bevy_sprite/src/lib.rs b/crates/bevy_sprite/src/lib.rs index 73edcc67dc1b0..bc574243a4bf5 100644 --- a/crates/bevy_sprite/src/lib.rs +++ b/crates/bevy_sprite/src/lib.rs @@ -9,6 +9,7 @@ mod sprite; mod texture_atlas; mod texture_atlas_builder; +use bevy_ecs::IntoSystem; pub use color_material::*; pub use dynamic_texture_atlas_builder::*; pub use rect::*; @@ -46,10 +47,10 @@ impl Plugin for SpritePlugin { app.add_asset::() .add_asset::() .register_type::() - .add_system_to_stage(stage::POST_UPDATE, sprite_system) + .add_system_to_stage(stage::POST_UPDATE, sprite_system.system()) .add_system_to_stage( stage::POST_UPDATE, - asset_shader_defs_system::, + asset_shader_defs_system::.system(), ); let resources = app.resources_mut(); diff --git a/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs b/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs index 7cff4d4de7145..fadd9707bca9a 100644 --- a/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs +++ b/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs @@ -71,7 +71,7 @@ pub fn parent_update_system( mod test { use super::*; use crate::{hierarchy::BuildChildren, transform_propagate_system::transform_propagate_system}; - use bevy_ecs::{Resources, Schedule, SystemStage, World}; + use bevy_ecs::{IntoSystem, Resources, Schedule, SystemStage, World}; use bevy_math::Vec3; #[test] @@ -80,8 +80,8 @@ mod test { let mut resources = Resources::default(); let mut update_stage = SystemStage::parallel(); - update_stage.add_system(parent_update_system); - update_stage.add_system(transform_propagate_system); + update_stage.add_system(parent_update_system.system()); + update_stage.add_system(transform_propagate_system.system()); let mut schedule = Schedule::default(); schedule.add_stage("update", update_stage); diff --git a/crates/bevy_transform/src/lib.rs b/crates/bevy_transform/src/lib.rs index dd7126ac39a70..97dd09ed24bd2 100644 --- a/crates/bevy_transform/src/lib.rs +++ b/crates/bevy_transform/src/lib.rs @@ -7,6 +7,7 @@ pub mod prelude { } use bevy_app::{prelude::*, startup_stage}; +use bevy_ecs::IntoSystem; use bevy_reflect::RegisterTypeBuilder; use prelude::{parent_update_system, Children, GlobalTransform, Parent, PreviousParent, Transform}; @@ -21,15 +22,15 @@ impl Plugin for TransformPlugin { .register_type::() .register_type::() // add transform systems to startup so the first update is "correct" - .add_startup_system_to_stage(startup_stage::POST_STARTUP, parent_update_system) + .add_startup_system_to_stage(startup_stage::POST_STARTUP, parent_update_system.system()) .add_startup_system_to_stage( startup_stage::POST_STARTUP, - transform_propagate_system::transform_propagate_system, + transform_propagate_system::transform_propagate_system.system(), ) - .add_system_to_stage(stage::POST_UPDATE, parent_update_system) + .add_system_to_stage(stage::POST_UPDATE, parent_update_system.system()) .add_system_to_stage( stage::POST_UPDATE, - transform_propagate_system::transform_propagate_system, + transform_propagate_system::transform_propagate_system.system(), ); } } diff --git a/crates/bevy_transform/src/transform_propagate_system.rs b/crates/bevy_transform/src/transform_propagate_system.rs index aa7c98262a8a3..6914ad31ab0c1 100644 --- a/crates/bevy_transform/src/transform_propagate_system.rs +++ b/crates/bevy_transform/src/transform_propagate_system.rs @@ -80,8 +80,8 @@ mod test { let mut resources = Resources::default(); let mut update_stage = SystemStage::parallel(); - update_stage.add_system(parent_update_system); - update_stage.add_system(transform_propagate_system); + update_stage.add_system(parent_update_system.system()); + update_stage.add_system(transform_propagate_system.system()); let mut schedule = Schedule::default(); schedule.add_stage("update", update_stage); @@ -133,8 +133,8 @@ mod test { let mut resources = Resources::default(); let mut update_stage = SystemStage::parallel(); - update_stage.add_system(parent_update_system); - update_stage.add_system(transform_propagate_system); + update_stage.add_system(parent_update_system.system()); + update_stage.add_system(transform_propagate_system.system()); let mut schedule = Schedule::default(); schedule.add_stage("update", update_stage); diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index 46ee8b661fa7b..9e62e520a9407 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -25,7 +25,7 @@ pub mod prelude { } use bevy_app::prelude::*; -use bevy_ecs::SystemStage; +use bevy_ecs::{IntoSystem, SystemStage}; use bevy_render::render_graph::RenderGraph; use update::ui_z_system; @@ -44,13 +44,13 @@ impl Plugin for UiPlugin { stage::UI, SystemStage::parallel(), ) - .add_system_to_stage(bevy_app::stage::PRE_UPDATE, ui_focus_system) + .add_system_to_stage(bevy_app::stage::PRE_UPDATE, ui_focus_system.system()) // add these stages to front because these must run before transform update systems - .add_system_to_stage(stage::UI, widget::text_system) - .add_system_to_stage(stage::UI, widget::image_node_system) - .add_system_to_stage(stage::UI, ui_z_system) - .add_system_to_stage(stage::UI, flex_node_system) - .add_system_to_stage(bevy_render::stage::DRAW, widget::draw_text_system); + .add_system_to_stage(stage::UI, widget::text_system.system()) + .add_system_to_stage(stage::UI, widget::image_node_system.system()) + .add_system_to_stage(stage::UI, ui_z_system.system()) + .add_system_to_stage(stage::UI, flex_node_system.system()) + .add_system_to_stage(bevy_render::stage::DRAW, widget::draw_text_system.system()); let resources = app.resources(); let mut render_graph = resources.get_mut::().unwrap(); diff --git a/crates/bevy_ui/src/update.rs b/crates/bevy_ui/src/update.rs index fe6bc25237a64..928bcc60b555d 100644 --- a/crates/bevy_ui/src/update.rs +++ b/crates/bevy_ui/src/update.rs @@ -48,7 +48,7 @@ fn update_hierarchy( } #[cfg(test)] mod tests { - use bevy_ecs::{Commands, Resources, Schedule, SystemStage, World}; + use bevy_ecs::{Commands, IntoSystem, Resources, Schedule, SystemStage, World}; use bevy_transform::{components::Transform, hierarchy::BuildChildren}; use crate::Node; @@ -116,7 +116,7 @@ mod tests { let mut schedule = Schedule::default(); let mut update_stage = SystemStage::parallel(); - update_stage.add_system(ui_z_system); + update_stage.add_system(ui_z_system.system()); schedule.add_stage("update", update_stage); schedule.initialize_and_run(&mut world, &mut resources); diff --git a/crates/bevy_wgpu/src/diagnostic/wgpu_resource_diagnostics_plugin.rs b/crates/bevy_wgpu/src/diagnostic/wgpu_resource_diagnostics_plugin.rs index 0af3f94fc915c..079332c93cf89 100644 --- a/crates/bevy_wgpu/src/diagnostic/wgpu_resource_diagnostics_plugin.rs +++ b/crates/bevy_wgpu/src/diagnostic/wgpu_resource_diagnostics_plugin.rs @@ -1,7 +1,7 @@ use crate::renderer::WgpuRenderResourceContext; use bevy_app::prelude::*; use bevy_diagnostic::{Diagnostic, DiagnosticId, Diagnostics}; -use bevy_ecs::{Res, ResMut}; +use bevy_ecs::{IntoSystem, Res, ResMut}; use bevy_render::renderer::RenderResourceContext; #[derive(Default)] @@ -9,8 +9,8 @@ pub struct WgpuResourceDiagnosticsPlugin; impl Plugin for WgpuResourceDiagnosticsPlugin { fn build(&self, app: &mut AppBuilder) { - app.add_startup_system(Self::setup_system) - .add_system(Self::diagnostic_system); + app.add_startup_system(Self::setup_system.system()) + .add_system(Self::diagnostic_system.system()); } } diff --git a/crates/bevy_wgpu/src/lib.rs b/crates/bevy_wgpu/src/lib.rs index f11ac6aaea49e..7537bf20e9140 100644 --- a/crates/bevy_wgpu/src/lib.rs +++ b/crates/bevy_wgpu/src/lib.rs @@ -11,7 +11,7 @@ pub use wgpu_renderer::*; pub use wgpu_resources::*; use bevy_app::prelude::*; -use bevy_ecs::{Resources, World}; +use bevy_ecs::{IntoSystem, Resources, World}; use bevy_render::renderer::{shared_buffers_update_system, RenderResourceContext, SharedBuffers}; use renderer::WgpuRenderResourceContext; @@ -21,10 +21,10 @@ pub struct WgpuPlugin; impl Plugin for WgpuPlugin { fn build(&self, app: &mut AppBuilder) { let render_system = get_wgpu_render_system(app.resources_mut()); - app.add_system_to_stage(bevy_render::stage::RENDER, render_system) + app.add_system_to_stage(bevy_render::stage::RENDER, render_system.system()) .add_system_to_stage( bevy_render::stage::POST_RENDER, - shared_buffers_update_system, + shared_buffers_update_system.system(), ); } } diff --git a/crates/bevy_window/src/lib.rs b/crates/bevy_window/src/lib.rs index c5b70009601df..0ebfe3ad576b6 100644 --- a/crates/bevy_window/src/lib.rs +++ b/crates/bevy_window/src/lib.rs @@ -3,6 +3,7 @@ mod system; mod window; mod windows; +use bevy_ecs::IntoSystem; pub use event::*; pub use system::*; pub use window::*; @@ -59,7 +60,7 @@ impl Plugin for WindowPlugin { } if self.exit_on_close { - app.add_system(exit_on_window_close_system); + app.add_system(exit_on_window_close_system.system()); } } } diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 6f80358aa6ef6..c93c227fc729b 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -10,7 +10,7 @@ pub use winit_config::*; pub use winit_windows::*; use bevy_app::{prelude::*, AppExit}; -use bevy_ecs::{Resources, World}; +use bevy_ecs::{IntoSystem, Resources, World}; use bevy_math::Vec2; use bevy_utils::tracing::{error, trace}; use bevy_window::{ @@ -29,7 +29,7 @@ impl Plugin for WinitPlugin { fn build(&self, app: &mut AppBuilder) { app.init_resource::() .set_runner(winit_runner) - .add_system(change_window); + .add_system(change_window.system()); } } diff --git a/examples/2d/contributors.rs b/examples/2d/contributors.rs index 7fe61287ff365..b1f562737219d 100644 --- a/examples/2d/contributors.rs +++ b/examples/2d/contributors.rs @@ -9,11 +9,11 @@ use std::{ fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) - .add_system(velocity_system) - .add_system(move_system) - .add_system(collision_system) - .add_system(select_system) + .add_startup_system(setup.system()) + .add_system(velocity_system.system()) + .add_system(move_system.system()) + .add_system(collision_system.system()) + .add_system(select_system.system()) .run(); } diff --git a/examples/2d/sprite.rs b/examples/2d/sprite.rs index 9cd245cbf7a1d..2d8f298c3e1da 100644 --- a/examples/2d/sprite.rs +++ b/examples/2d/sprite.rs @@ -3,7 +3,7 @@ use bevy::prelude::*; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/2d/sprite_sheet.rs b/examples/2d/sprite_sheet.rs index b2c7dc002b381..e8c92c45df346 100644 --- a/examples/2d/sprite_sheet.rs +++ b/examples/2d/sprite_sheet.rs @@ -3,8 +3,8 @@ use bevy::prelude::*; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) - .add_system(animate_sprite_system) + .add_startup_system(setup.system()) + .add_system(animate_sprite_system.system()) .run(); } diff --git a/examples/2d/texture_atlas.rs b/examples/2d/texture_atlas.rs index 3ee454a8207d7..b02c724e99332 100644 --- a/examples/2d/texture_atlas.rs +++ b/examples/2d/texture_atlas.rs @@ -7,9 +7,9 @@ fn main() { .add_plugins(DefaultPlugins) .add_resource(State::new(AppState::Setup)) .add_stage_after(stage::UPDATE, STAGE, StateStage::::default()) - .on_state_enter(STAGE, AppState::Setup, load_textures) - .on_state_update(STAGE, AppState::Setup, check_textures) - .on_state_enter(STAGE, AppState::Finshed, setup) + .on_state_enter(STAGE, AppState::Setup, load_textures.system()) + .on_state_update(STAGE, AppState::Setup, check_textures.system()) + .on_state_enter(STAGE, AppState::Finshed, setup.system()) .run(); } diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index 3ea3492f6bfb5..d9dee8b308d87 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -4,7 +4,7 @@ fn main() { App::build() .add_resource(Msaa { samples: 4 }) .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/3d/load_gltf.rs b/examples/3d/load_gltf.rs index fb64e4cadeab9..e374970f3038d 100644 --- a/examples/3d/load_gltf.rs +++ b/examples/3d/load_gltf.rs @@ -4,7 +4,7 @@ fn main() { App::build() .add_resource(Msaa { samples: 4 }) .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/3d/msaa.rs b/examples/3d/msaa.rs index d6dbea34b8e84..67bf1f45e35e7 100644 --- a/examples/3d/msaa.rs +++ b/examples/3d/msaa.rs @@ -7,7 +7,7 @@ fn main() { App::build() .add_resource(Msaa { samples: 4 }) .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/3d/parenting.rs b/examples/3d/parenting.rs index 3df2f753c1df4..556bd1b30750b 100644 --- a/examples/3d/parenting.rs +++ b/examples/3d/parenting.rs @@ -6,8 +6,8 @@ fn main() { App::build() .add_resource(Msaa { samples: 4 }) .add_plugins(DefaultPlugins) - .add_startup_system(setup) - .add_system(rotator_system) + .add_startup_system(setup.system()) + .add_system(rotator_system.system()) .run(); } diff --git a/examples/3d/spawner.rs b/examples/3d/spawner.rs index ae5f1cba768ea..c2a5c7f045619 100644 --- a/examples/3d/spawner.rs +++ b/examples/3d/spawner.rs @@ -13,8 +13,8 @@ fn main() { .add_plugins(DefaultPlugins) .add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(PrintDiagnosticsPlugin::default()) - .add_startup_system(setup) - .add_system(move_cubes) + .add_startup_system(setup.system()) + .add_system(move_cubes.system()) .run(); } diff --git a/examples/3d/texture.rs b/examples/3d/texture.rs index 119cf7ec4afe3..c2822ea891ee3 100644 --- a/examples/3d/texture.rs +++ b/examples/3d/texture.rs @@ -4,7 +4,7 @@ use bevy::prelude::*; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/3d/z_sort_debug.rs b/examples/3d/z_sort_debug.rs index 7b590579ccaf6..e1feccd9b0d07 100644 --- a/examples/3d/z_sort_debug.rs +++ b/examples/3d/z_sort_debug.rs @@ -10,9 +10,9 @@ use bevy::{ fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) - .add_system(rotator_system) - .add_system(camera_order_color_system) + .add_startup_system(setup.system()) + .add_system(rotator_system.system()) + .add_system(camera_order_color_system.system()) .run(); } diff --git a/examples/android/android.rs b/examples/android/android.rs index 0fa98018fda59..4970307a620e7 100644 --- a/examples/android/android.rs +++ b/examples/android/android.rs @@ -6,7 +6,7 @@ fn main() { App::build() .add_resource(Msaa { samples: 2 }) .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/app/custom_loop.rs b/examples/app/custom_loop.rs index 48337c8a17e82..dd67bd583a515 100644 --- a/examples/app/custom_loop.rs +++ b/examples/app/custom_loop.rs @@ -24,6 +24,6 @@ fn main() { App::build() .add_resource(Input(String::new())) .set_runner(my_runner) - .add_system(print_system) + .add_system(print_system.system()) .run(); } diff --git a/examples/app/headless.rs b/examples/app/headless.rs index 181d1b0082efa..b90de71b3c16e 100644 --- a/examples/app/headless.rs +++ b/examples/app/headless.rs @@ -13,7 +13,7 @@ fn main() { App::build() .add_resource(ScheduleRunnerSettings::run_once()) .add_plugins(MinimalPlugins) - .add_system(hello_world_system) + .add_system(hello_world_system.system()) .run(); // this app loops forever at 60 fps @@ -22,7 +22,7 @@ fn main() { 1.0 / 60.0, ))) .add_plugins(MinimalPlugins) - .add_system(counter) + .add_system(counter.system()) .run(); } diff --git a/examples/app/logs.rs b/examples/app/logs.rs index 3046a51fc2738..532e6932ebf46 100644 --- a/examples/app/logs.rs +++ b/examples/app/logs.rs @@ -9,7 +9,7 @@ fn main() { // filter: "wgpu=warn,bevy_ecs=info".to_string(), // }) .add_plugins(DefaultPlugins) - .add_system(log_system) + .add_system(log_system.system()) .run(); } diff --git a/examples/app/plugin.rs b/examples/app/plugin.rs index a220755c191f6..dee94567d5c77 100644 --- a/examples/app/plugin.rs +++ b/examples/app/plugin.rs @@ -28,7 +28,8 @@ impl Plugin for PrintMessagePlugin { message: self.message.clone(), timer: Timer::new(self.wait_duration, true), }; - app.add_resource(state).add_system(print_message_system); + app.add_resource(state) + .add_system(print_message_system.system()); } } diff --git a/examples/app/plugin_group.rs b/examples/app/plugin_group.rs index fbe533ea154e9..81cd0b2ef2201 100644 --- a/examples/app/plugin_group.rs +++ b/examples/app/plugin_group.rs @@ -29,7 +29,7 @@ pub struct PrintHelloPlugin; impl Plugin for PrintHelloPlugin { fn build(&self, app: &mut AppBuilder) { - app.add_system(print_hello_system); + app.add_system(print_hello_system.system()); } } @@ -41,7 +41,7 @@ pub struct PrintWorldPlugin; impl Plugin for PrintWorldPlugin { fn build(&self, app: &mut AppBuilder) { - app.add_system(print_world_system); + app.add_system(print_world_system.system()); } } diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 5ad62e0af404a..793f4685046e0 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -5,7 +5,7 @@ fn main() { App::build() .add_resource(Msaa { samples: 4 }) .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/asset/custom_asset.rs b/examples/asset/custom_asset.rs index e6527ad1222b9..4169b364cce67 100644 --- a/examples/asset/custom_asset.rs +++ b/examples/asset/custom_asset.rs @@ -39,8 +39,8 @@ fn main() { .init_resource::() .add_asset::() .init_asset_loader::() - .add_startup_system(setup) - .add_system(print_on_load) + .add_startup_system(setup.system()) + .add_system(print_on_load.system()) .run(); } diff --git a/examples/asset/hot_asset_reloading.rs b/examples/asset/hot_asset_reloading.rs index edcaa35dc56d1..cf542a48e9355 100644 --- a/examples/asset/hot_asset_reloading.rs +++ b/examples/asset/hot_asset_reloading.rs @@ -6,7 +6,7 @@ use bevy::prelude::*; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/audio/audio.rs b/examples/audio/audio.rs index ca72402afeea2..a8296ad95305b 100644 --- a/examples/audio/audio.rs +++ b/examples/audio/audio.rs @@ -4,7 +4,7 @@ use bevy::prelude::*; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/diagnostics/custom_diagnostic.rs b/examples/diagnostics/custom_diagnostic.rs index 58f22137fb7f1..4b2e832467a44 100644 --- a/examples/diagnostics/custom_diagnostic.rs +++ b/examples/diagnostics/custom_diagnostic.rs @@ -9,8 +9,8 @@ fn main() { .add_plugins(DefaultPlugins) // The "print diagnostics" plugin is optional. It just visualizes our diagnostics in the console .add_plugin(PrintDiagnosticsPlugin::default()) - .add_startup_system(setup_diagnostic_system) - .add_system(my_system) + .add_startup_system(setup_diagnostic_system.system()) + .add_system(my_system.system()) .run(); } diff --git a/examples/ecs/ecs_guide.rs b/examples/ecs/ecs_guide.rs index cd7c7ffb763ea..8f7159d3bd1e8 100644 --- a/examples/ecs/ecs_guide.rs +++ b/examples/ecs/ecs_guide.rs @@ -257,9 +257,9 @@ fn main() { .init_resource::() // Startup systems run exactly once BEFORE all other systems. These are generally used for // app initialization code (ex: adding entities and resources) - .add_startup_system(startup_system) + .add_startup_system(startup_system.system()) // my_system calls converts normal rust functions into ECS systems: - .add_system(print_message_system) + .add_system(print_message_system.system()) // // SYSTEM EXECUTION ORDER // @@ -278,17 +278,17 @@ fn main() { // and the next stage won't start until all systems in the current stage have finished. // add_system(system) adds systems to the UPDATE stage by default // However we can manually specify the stage if we want to. The following is equivalent to add_system(score_system) - .add_system_to_stage(stage::UPDATE, score_system) + .add_system_to_stage(stage::UPDATE, score_system.system()) // We can also create new stages. Here is what our games stage order will look like: // "before_round": new_player_system, new_round_system // "update": print_message_system, score_system // "after_round": score_check_system, game_over_system .add_stage_before(stage::UPDATE, "before_round", SystemStage::parallel()) .add_stage_after(stage::UPDATE, "after_round", SystemStage::parallel()) - .add_system_to_stage("before_round", new_round_system) - .add_system_to_stage("before_round", new_player_system) - .add_system_to_stage("after_round", score_check_system) - .add_system_to_stage("after_round", game_over_system) + .add_system_to_stage("before_round", new_round_system.system()) + .add_system_to_stage("before_round", new_player_system.system()) + .add_system_to_stage("after_round", score_check_system.system()) + .add_system_to_stage("after_round", game_over_system.system()) // score_check_system will run before game_over_system because score_check_system modifies GameState and game_over_system // reads GameState. This works, but it's a bit confusing. In practice, it would be clearer to create a new stage that runs // before "after_round" diff --git a/examples/ecs/event.rs b/examples/ecs/event.rs index 33cc3230dd513..f0e14a4c55253 100644 --- a/examples/ecs/event.rs +++ b/examples/ecs/event.rs @@ -7,8 +7,8 @@ fn main() { .add_plugins(DefaultPlugins) .add_event::() .init_resource::() - .add_system(event_trigger_system) - .add_system(event_listener_system) + .add_system(event_trigger_system.system()) + .add_system(event_listener_system.system()) .run(); } diff --git a/examples/ecs/fixed_timestep.rs b/examples/ecs/fixed_timestep.rs index 88136badd5494..cd97079d0d790 100644 --- a/examples/ecs/fixed_timestep.rs +++ b/examples/ecs/fixed_timestep.rs @@ -9,7 +9,7 @@ fn main() { App::build() .add_plugins(DefaultPlugins) // this system will run once every update (it should match your screen's refresh rate) - .add_system(update) + .add_system(update.system()) // add a new stage that runs every two seconds .add_stage_after( stage::UPDATE, @@ -20,7 +20,7 @@ fn main() { // labels are optional. they provide a way to access the current FixedTimestep state from within a system .with_label(LABEL), ) - .with_system(fixed_update), + .with_system(fixed_update.system()), ) .run(); } diff --git a/examples/ecs/hierarchy.rs b/examples/ecs/hierarchy.rs index ed7a7c5242359..5d0f49a03388a 100644 --- a/examples/ecs/hierarchy.rs +++ b/examples/ecs/hierarchy.rs @@ -3,8 +3,8 @@ use bevy::prelude::*; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) - .add_system(rotate) + .add_startup_system(setup.system()) + .add_system(rotate.system()) .run(); } diff --git a/examples/ecs/parallel_query.rs b/examples/ecs/parallel_query.rs index cbb77af206bd4..b590a2c0460a8 100644 --- a/examples/ecs/parallel_query.rs +++ b/examples/ecs/parallel_query.rs @@ -74,8 +74,8 @@ fn bounce_system( fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(spawn_system) - .add_system(move_system) - .add_system(bounce_system) + .add_startup_system(spawn_system.system()) + .add_system(move_system.system()) + .add_system(bounce_system.system()) .run(); } diff --git a/examples/ecs/startup_system.rs b/examples/ecs/startup_system.rs index 682eb7a7cfc40..395d69322b12d 100644 --- a/examples/ecs/startup_system.rs +++ b/examples/ecs/startup_system.rs @@ -2,8 +2,8 @@ use bevy::prelude::*; fn main() { App::build() - .add_startup_system(startup_system) - .add_system(normal_system) + .add_startup_system(startup_system.system()) + .add_system(normal_system.system()) .run(); } diff --git a/examples/ecs/state.rs b/examples/ecs/state.rs index 1b79193c4f5fa..5d7c31d779eb0 100644 --- a/examples/ecs/state.rs +++ b/examples/ecs/state.rs @@ -7,12 +7,12 @@ fn main() { .init_resource::() .add_resource(State::new(AppState::Menu)) .add_stage_after(stage::UPDATE, STAGE, StateStage::::default()) - .on_state_enter(STAGE, AppState::Menu, setup_menu) - .on_state_update(STAGE, AppState::Menu, menu) - .on_state_exit(STAGE, AppState::Menu, cleanup_menu) - .on_state_enter(STAGE, AppState::InGame, setup_game) - .on_state_update(STAGE, AppState::InGame, movement) - .on_state_update(STAGE, AppState::InGame, change_color) + .on_state_enter(STAGE, AppState::Menu, setup_menu.system()) + .on_state_update(STAGE, AppState::Menu, menu.system()) + .on_state_exit(STAGE, AppState::Menu, cleanup_menu.system()) + .on_state_enter(STAGE, AppState::InGame, setup_game.system()) + .on_state_update(STAGE, AppState::InGame, movement.system()) + .on_state_update(STAGE, AppState::InGame, change_color.system()) .run(); } diff --git a/examples/ecs/system_chaining.rs b/examples/ecs/system_chaining.rs index b68229e2e35b8..4a21dec20f308 100644 --- a/examples/ecs/system_chaining.rs +++ b/examples/ecs/system_chaining.rs @@ -4,7 +4,7 @@ use bevy::prelude::*; fn main() { App::build() .add_resource(Message("42".to_string())) - .add_system(parse_message_system.chain(handler_system)) + .add_system(parse_message_system.system().chain(handler_system.system())) .run(); } diff --git a/examples/ecs/timers.rs b/examples/ecs/timers.rs index 14b17e27ebf69..0a2bee125a241 100644 --- a/examples/ecs/timers.rs +++ b/examples/ecs/timers.rs @@ -4,9 +4,9 @@ fn main() { App::build() .add_plugins(DefaultPlugins) .add_resource(Countdown::default()) - .add_startup_system(setup_system) - .add_system(countdown_system) - .add_system(timer_system) + .add_startup_system(setup_system.system()) + .add_system(countdown_system.system()) + .add_system(timer_system.system()) .run(); } diff --git a/examples/game/breakout.rs b/examples/game/breakout.rs index 449c006a2a343..29e4532e3c81a 100644 --- a/examples/game/breakout.rs +++ b/examples/game/breakout.rs @@ -10,11 +10,11 @@ fn main() { .add_plugins(DefaultPlugins) .add_resource(Scoreboard { score: 0 }) .add_resource(ClearColor(Color::rgb(0.9, 0.9, 0.9))) - .add_startup_system(setup) - .add_system(paddle_movement_system) - .add_system(ball_collision_system) - .add_system(ball_movement_system) - .add_system(scoreboard_system) + .add_startup_system(setup.system()) + .add_system(paddle_movement_system.system()) + .add_system(ball_collision_system.system()) + .add_system(ball_movement_system.system()) + .add_system(scoreboard_system.system()) .run(); } diff --git a/examples/hello_world.rs b/examples/hello_world.rs index 6cdfa3e0489e8..5078ebb2e22d1 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; fn main() { - App::build().add_system(hello_world_system).run(); + App::build().add_system(hello_world_system.system()).run(); } fn hello_world_system() { diff --git a/examples/input/char_input_events.rs b/examples/input/char_input_events.rs index 73c163e17b17b..207fe1c91caee 100644 --- a/examples/input/char_input_events.rs +++ b/examples/input/char_input_events.rs @@ -3,7 +3,7 @@ use bevy::{prelude::*, window::ReceivedCharacter}; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_system(print_char_event_system) + .add_system(print_char_event_system.system()) .run(); } diff --git a/examples/input/gamepad_input.rs b/examples/input/gamepad_input.rs index dd8630c51d840..dccf64b2def26 100644 --- a/examples/input/gamepad_input.rs +++ b/examples/input/gamepad_input.rs @@ -8,8 +8,8 @@ fn main() { App::build() .add_plugins(DefaultPlugins) .init_resource::() - .add_system_to_stage(stage::PRE_UPDATE, connection_system) - .add_system(gamepad_system) + .add_system_to_stage(stage::PRE_UPDATE, connection_system.system()) + .add_system(gamepad_system.system()) .run(); } diff --git a/examples/input/gamepad_input_events.rs b/examples/input/gamepad_input_events.rs index ce6cb8012b43b..3f4db960d718f 100644 --- a/examples/input/gamepad_input_events.rs +++ b/examples/input/gamepad_input_events.rs @@ -6,7 +6,7 @@ use bevy::{ fn main() { App::build() .add_plugins(DefaultPlugins) - .add_system(gamepad_events) + .add_system(gamepad_events.system()) .run(); } diff --git a/examples/input/keyboard_input.rs b/examples/input/keyboard_input.rs index 86828ae652b4d..65a5072635624 100644 --- a/examples/input/keyboard_input.rs +++ b/examples/input/keyboard_input.rs @@ -6,7 +6,7 @@ use bevy::{ fn main() { App::build() .add_plugins(DefaultPlugins) - .add_system(keyboard_input_system) + .add_system(keyboard_input_system.system()) .run(); } diff --git a/examples/input/keyboard_input_events.rs b/examples/input/keyboard_input_events.rs index 0c8f172933490..fc0fe43c7090c 100644 --- a/examples/input/keyboard_input_events.rs +++ b/examples/input/keyboard_input_events.rs @@ -3,7 +3,7 @@ use bevy::{input::keyboard::KeyboardInput, prelude::*}; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_system(print_keyboard_event_system) + .add_system(print_keyboard_event_system.system()) .run(); } diff --git a/examples/input/mouse_input.rs b/examples/input/mouse_input.rs index 6c19d05d24307..61fcac5d75c3f 100644 --- a/examples/input/mouse_input.rs +++ b/examples/input/mouse_input.rs @@ -3,7 +3,7 @@ use bevy::prelude::*; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_system(mouse_click_system) + .add_system(mouse_click_system.system()) .run(); } diff --git a/examples/input/mouse_input_events.rs b/examples/input/mouse_input_events.rs index 5d539315c6887..f9bab2fca06f1 100644 --- a/examples/input/mouse_input_events.rs +++ b/examples/input/mouse_input_events.rs @@ -7,7 +7,7 @@ use bevy::{ fn main() { App::build() .add_plugins(DefaultPlugins) - .add_system(print_mouse_events_system) + .add_system(print_mouse_events_system.system()) .run(); } diff --git a/examples/input/touch_input.rs b/examples/input/touch_input.rs index 13dc7ea658d21..bd1a5312c99e8 100644 --- a/examples/input/touch_input.rs +++ b/examples/input/touch_input.rs @@ -3,7 +3,7 @@ use bevy::{input::touch::*, prelude::*}; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_system(touch_system) + .add_system(touch_system.system()) .run(); } diff --git a/examples/input/touch_input_events.rs b/examples/input/touch_input_events.rs index 474ef2b60209b..bb6b57b33b8cd 100644 --- a/examples/input/touch_input_events.rs +++ b/examples/input/touch_input_events.rs @@ -3,7 +3,7 @@ use bevy::{input::touch::*, prelude::*}; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_system(touch_event_system) + .add_system(touch_event_system.system()) .run(); } diff --git a/examples/ios/src/lib.rs b/examples/ios/src/lib.rs index 803752e0d6672..3801169dd9ad8 100644 --- a/examples/ios/src/lib.rs +++ b/examples/ios/src/lib.rs @@ -12,7 +12,7 @@ fn main() { }) .add_resource(Msaa { samples: 4 }) .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } /// set up a simple 3D scene diff --git a/examples/reflection/generic_reflection.rs b/examples/reflection/generic_reflection.rs index fecb60aa01600..085e89e90e90d 100644 --- a/examples/reflection/generic_reflection.rs +++ b/examples/reflection/generic_reflection.rs @@ -8,7 +8,7 @@ fn main() { App::build() .add_plugins(DefaultPlugins) .register_type::>() - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/reflection/reflection.rs b/examples/reflection/reflection.rs index dd744ae41b5c0..154dc3ec5930a 100644 --- a/examples/reflection/reflection.rs +++ b/examples/reflection/reflection.rs @@ -15,7 +15,7 @@ fn main() { .add_plugins(DefaultPlugins) .register_type::() .register_type::() - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/reflection/reflection_types.rs b/examples/reflection/reflection_types.rs index bbdfb8cba84bb..3759f3bfbf5f0 100644 --- a/examples/reflection/reflection_types.rs +++ b/examples/reflection/reflection_types.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/reflection/trait_reflection.rs b/examples/reflection/trait_reflection.rs index f7d7a1c985f7a..0171db9e76555 100644 --- a/examples/reflection/trait_reflection.rs +++ b/examples/reflection/trait_reflection.rs @@ -3,7 +3,7 @@ use bevy::{prelude::*, reflect::TypeRegistry}; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .register_type::() .run(); } diff --git a/examples/scene/scene.rs b/examples/scene/scene.rs index 66b8a0593fe2e..b44282871ad26 100644 --- a/examples/scene/scene.rs +++ b/examples/scene/scene.rs @@ -6,10 +6,10 @@ fn main() { .add_plugins(DefaultPlugins) .register_type::() .register_type::() - .add_startup_system(save_scene_system) - .add_startup_system(load_scene_system) - .add_startup_system(infotext_system) - .add_system(print_system) + .add_startup_system(save_scene_system.system()) + .add_startup_system(load_scene_system.system()) + .add_startup_system(infotext_system.system()) + .add_system(print_system.system()) .run(); } diff --git a/examples/shader/hot_shader_reloading.rs b/examples/shader/hot_shader_reloading.rs index 2c1ba667bd217..df72952603ea7 100644 --- a/examples/shader/hot_shader_reloading.rs +++ b/examples/shader/hot_shader_reloading.rs @@ -16,7 +16,7 @@ fn main() { App::build() .add_plugins(DefaultPlugins) .add_asset::() - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/shader/mesh_custom_attribute.rs b/examples/shader/mesh_custom_attribute.rs index 05020216e3ffa..e6f822b42e975 100644 --- a/examples/shader/mesh_custom_attribute.rs +++ b/examples/shader/mesh_custom_attribute.rs @@ -15,7 +15,7 @@ fn main() { App::build() .add_plugins(DefaultPlugins) .add_asset::() - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/shader/shader_custom_material.rs b/examples/shader/shader_custom_material.rs index 214c9bdb560a2..346a2c8338a80 100644 --- a/examples/shader/shader_custom_material.rs +++ b/examples/shader/shader_custom_material.rs @@ -15,7 +15,7 @@ fn main() { App::build() .add_plugins(DefaultPlugins) .add_asset::() - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/shader/shader_defs.rs b/examples/shader/shader_defs.rs index 9b2704fe0e742..e8b429c420875 100644 --- a/examples/shader/shader_defs.rs +++ b/examples/shader/shader_defs.rs @@ -16,8 +16,11 @@ fn main() { App::build() .add_plugins(DefaultPlugins) .add_asset::() - .add_startup_system(setup) - .add_system_to_stage(stage::POST_UPDATE, asset_shader_defs_system::) + .add_startup_system(setup.system()) + .add_system_to_stage( + stage::POST_UPDATE, + asset_shader_defs_system::.system(), + ) .run(); } diff --git a/examples/tools/bevymark.rs b/examples/tools/bevymark.rs index fde32c40cbacc..1a5e0a9e1a6a9 100644 --- a/examples/tools/bevymark.rs +++ b/examples/tools/bevymark.rs @@ -40,11 +40,11 @@ fn main() { .add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_resource(BevyCounter { count: 0 }) .init_resource::() - .add_startup_system(setup) - .add_system(mouse_handler) - .add_system(movement_system) - .add_system(collision_system) - .add_system(counter_system) + .add_startup_system(setup.system()) + .add_system(mouse_handler.system()) + .add_system(movement_system.system()) + .add_system(collision_system.system()) + .add_system(counter_system.system()) .run(); } diff --git a/examples/ui/button.rs b/examples/ui/button.rs index f3b6c4b9db9ca..d67762853957b 100644 --- a/examples/ui/button.rs +++ b/examples/ui/button.rs @@ -5,8 +5,8 @@ fn main() { App::build() .add_plugins(DefaultPlugins) .init_resource::() - .add_startup_system(setup) - .add_system(button_system) + .add_startup_system(setup.system()) + .add_system(button_system.system()) .run(); } diff --git a/examples/ui/font_atlas_debug.rs b/examples/ui/font_atlas_debug.rs index 2034fa00e5e96..92be9e7a7e408 100644 --- a/examples/ui/font_atlas_debug.rs +++ b/examples/ui/font_atlas_debug.rs @@ -5,9 +5,9 @@ fn main() { App::build() .init_resource::() .add_plugins(DefaultPlugins) - .add_startup_system(setup) - .add_system(text_update_system) - .add_system(atlas_render_system) + .add_startup_system(setup.system()) + .add_system(text_update_system.system()) + .add_system(atlas_render_system.system()) .run(); } diff --git a/examples/ui/text.rs b/examples/ui/text.rs index d81fe0b5db204..3a991075e5f5f 100644 --- a/examples/ui/text.rs +++ b/examples/ui/text.rs @@ -8,8 +8,8 @@ fn main() { App::build() .add_plugins(DefaultPlugins) .add_plugin(FrameTimeDiagnosticsPlugin::default()) - .add_startup_system(setup) - .add_system(text_update_system) + .add_startup_system(setup.system()) + .add_system(text_update_system.system()) .run(); } diff --git a/examples/ui/text_debug.rs b/examples/ui/text_debug.rs index 9e1672bacf069..b89c7b724a87c 100644 --- a/examples/ui/text_debug.rs +++ b/examples/ui/text_debug.rs @@ -12,8 +12,8 @@ fn main() { }) .add_plugins(DefaultPlugins) .add_plugin(FrameTimeDiagnosticsPlugin) - .add_startup_system(infotext_system) - .add_system(change_text_system) + .add_startup_system(infotext_system.system()) + .add_system(change_text_system.system()) .run(); } diff --git a/examples/ui/ui.rs b/examples/ui/ui.rs index fef5595574404..645fd25f1c619 100644 --- a/examples/ui/ui.rs +++ b/examples/ui/ui.rs @@ -4,7 +4,7 @@ use bevy::prelude::*; fn main() { App::build() .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/wasm/assets_wasm.rs b/examples/wasm/assets_wasm.rs index ec4649be80313..803f3d64ff90d 100644 --- a/examples/wasm/assets_wasm.rs +++ b/examples/wasm/assets_wasm.rs @@ -13,8 +13,8 @@ fn main() { .add_plugins(DefaultPlugins) .add_asset::() .init_asset_loader::() - .add_startup_system(load_asset) - .add_system(print_asset) + .add_startup_system(load_asset.system()) + .add_system(print_asset.system()) .run(); } diff --git a/examples/wasm/headless_wasm.rs b/examples/wasm/headless_wasm.rs index 9efbf7d3eea06..df4a381636ab6 100644 --- a/examples/wasm/headless_wasm.rs +++ b/examples/wasm/headless_wasm.rs @@ -12,8 +12,8 @@ fn main() { ))) .add_plugin(ScheduleRunnerPlugin::default()) .add_plugin(LogPlugin::default()) - .add_startup_system(hello_world_system) - .add_system(counter) + .add_startup_system(hello_world_system.system()) + .add_system(counter.system()) .run(); } diff --git a/examples/wasm/hello_wasm.rs b/examples/wasm/hello_wasm.rs index 22c6f0960bb48..c3fbef4bdaa84 100644 --- a/examples/wasm/hello_wasm.rs +++ b/examples/wasm/hello_wasm.rs @@ -3,7 +3,7 @@ use bevy::{log::LogPlugin, prelude::*}; fn main() { App::build() .add_plugin(LogPlugin::default()) - .add_system(hello_wasm_system) + .add_system(hello_wasm_system.system()) .run(); } diff --git a/examples/wasm/winit_wasm.rs b/examples/wasm/winit_wasm.rs index 14b48b1de2f29..b3913c237951c 100644 --- a/examples/wasm/winit_wasm.rs +++ b/examples/wasm/winit_wasm.rs @@ -15,12 +15,12 @@ fn main() { }) .add_plugins(DefaultPlugins) // One time greet - .add_startup_system(hello_wasm_system) + .add_startup_system(hello_wasm_system.system()) // Track ticks (sanity check, whether game loop is running) - .add_system(counter) + .add_system(counter.system()) // Track input events .init_resource::() - .add_system(track_input_events) + .add_system(track_input_events.system()) .run(); } diff --git a/examples/window/multiple_windows.rs b/examples/window/multiple_windows.rs index 5eca81b4dc405..0dc94dfe51b91 100644 --- a/examples/window/multiple_windows.rs +++ b/examples/window/multiple_windows.rs @@ -17,7 +17,7 @@ fn main() { App::build() .add_resource(Msaa { samples: 4 }) .add_plugins(DefaultPlugins) - .add_startup_system(setup) + .add_startup_system(setup.system()) .run(); } diff --git a/examples/window/window_settings.rs b/examples/window/window_settings.rs index 0dc4fbd67ecfc..a01f67181bb5d 100644 --- a/examples/window/window_settings.rs +++ b/examples/window/window_settings.rs @@ -12,8 +12,8 @@ fn main() { ..Default::default() }) .add_plugins(DefaultPlugins) - .add_system(change_title) - .add_system(toggle_cursor) + .add_system(change_title.system()) + .add_system(toggle_cursor.system()) .run(); }