From e23befaafb993b97a30fc815ea9e4808920cc087 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Sat, 10 Jul 2021 15:21:19 +0200 Subject: [PATCH 01/14] Add Migration Guide: 0.5 to 0.6 entry --- content/learn/book/migration-guides/0.5-0.6/_index.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 content/learn/book/migration-guides/0.5-0.6/_index.md diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md new file mode 100644 index 0000000000..7eb3061054 --- /dev/null +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -0,0 +1,9 @@ ++++ +title = "0.5 to 0.6" +weight = 1 +sort_by = "weight" +template = "book-section.html" +page_template = "book-section.html" +[extra] +long_title = "Migration Guide: 0.5 to 0.6" ++++ From 4200f7e33b64b15b7938d8b438b1b85d0a020468 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Sat, 10 Jul 2021 15:22:07 +0200 Subject: [PATCH 02/14] Add optional .system() to guide --- .../book/migration-guides/0.5-0.6/_index.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index 7eb3061054..5b6a79195d 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -7,3 +7,44 @@ page_template = "book-section.html" [extra] long_title = "Migration Guide: 0.5 to 0.6" +++ + +### Calling ".system()" on a system is now optional + +```rust +// 0.5 +fn main() { + App::build() + .add_system(first_system.system()) + .add_system(second_system.system()) + .run(); +} + +// 0.6 +fn main() { + App::build() + .add_system(first_system) + .add_system(second_system.system()) + .run(); +} +``` + +When adding a system to Bevy it is no longer necessary to call `.system()` beforehand. +Functions like `.label()` or `.config()` can now also be directly called on a system. + +```rust +// 0.5 +fn main() { + App::build() + .add_system(first_system.system().label("FirstSystem")) + .add_system(second_system.system().after("FirstSystem")) + .run(); +} + +// 0.6 +fn main() { + App::build() + .add_system(first_system.label("FirstSystem")) + .add_system(second_system.after("FirstSystem")) + .run(); +} +``` From a0110f609918be2fe6586b781365f821f5a9bd60 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Sat, 10 Jul 2021 15:22:50 +0200 Subject: [PATCH 03/14] Add Light/LightBundle -> PointLight/PointLightBundle renaming --- .../book/migration-guides/0.5-0.6/_index.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index 5b6a79195d..5d36ce7fd0 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -48,3 +48,38 @@ fn main() { .run(); } ``` + +### "Light" and "LightBundle" are now "PointLight" and "PointLightBundle" + +```rust +// 0.5 +commands.spawn_bundle(LightBundle { + light: Light { + color: Color::rgb(1.0, 1.0, 1.0), + depth: 0.1..50.0, + fov: f32::to_radians(60.0), + intensity: 200.0, + range: 20.0, + } + ..Default::default() +}); + +// 0.6 +commands.spawn_bundle(PointLightBundle { + light: PointLight { + color: Color::rgb(1.0, 1.0, 1.0), + intensity: 200.0, + range: 20.0, + } + ..Default::default() +}); +``` + +The {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.5.0" name="Light" no_mod=true)}} and {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.5.0" name="LightBundle" no_mod=true)}} were renamed to {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.6.0" name="PointLight" no_mod=true)}} and {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.6.0" name="PointLightBundle" no_mod=true)}} to more clearly communicate the behavior of the Light Source. +At the same time the `fov` and `depth` fields were removed from the {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.6.0" name="PointLight" no_mod=true)}} as they were unused. + + From 00fa4ba16efefd1ef40976dc63cdbde0db724c9d Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Sat, 10 Jul 2021 17:01:12 +0200 Subject: [PATCH 04/14] Add SystemState -> SystemMeta renaming and new SystemState --- .../book/migration-guides/0.5-0.6/_index.md | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index 5d36ce7fd0..7ba1ea70f3 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -29,7 +29,7 @@ fn main() { ``` When adding a system to Bevy it is no longer necessary to call `.system()` beforehand. -Functions like `.label()` or `.config()` can now also be directly called on a system. +System Configuration Functions like `.label()` or `.config()` can now also be directly called on a system. ```rust // 0.5 @@ -83,3 +83,55 @@ At the same time the `fov` and `depth` fields were removed from the {{rust_type( In addition the {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.6.0" name="DirectionalLight" no_mod=true)}} and {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.6.0" name="DirectionalLightBundle" no_mod=true)}} were introduced with `0.6`. --> + +### New SystemState and rename old SystemState to SystemMeta + +To get easier cached access to a {{rust_type(type="trait" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemParam" no_mod=true)}} outside of a system, a new {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemState" no_mod=true)}} was introduced. + + +```rust +#[derive(Eq, PartialEq, Debug)] +struct A(usize); + +#[derive(Eq, PartialEq, Debug)] +struct B(usize); + +let mut world = World::default(); +world.insert_resource(A(42)); +world.spawn().insert(B(7)); + +// we get nice lifetime elision when declaring the type on the left hand side +let mut system_state: SystemState<(Res, Query<&B>)> = SystemState::new(&mut world); +let (a, query) = system_state.get(&world); +assert_eq!(*a, A(42), "returned resource matches initial value"); +assert_eq!( + *query.single().unwrap(), + B(7), + "returned component matches initial value" +); + +// mutable system params require unique world access +let mut system_state: SystemState<(ResMut, Query<&mut B>)> = SystemState::new(&mut world); +let (a, query) = system_state.get_mut(&mut world); + +// static lifetimes are required when declaring inside of structs +struct SomeContainer { + state: SystemState<(Res<'static, A>, Res<'static, B>)> +} + +// this can be shortened using type aliases, which will be useful for complex param tuples +type MyParams<'a> = (Res<'a, A>, Res<'a, B>); +struct SomeContainer { + state: SystemState> +} + +// It is the user's responsibility to call SystemState::apply(world) for parameters that queue up work +let mut system_state: SystemState<(Commands, Query<&B>)> = SystemState::new(&mut world); +{ + let (mut commands, query) = system_state.get(&world); + commands.insert_resource(3.14); +} +system_state.apply(&mut world); +``` + +The preexisting {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.5.0" name="SystemState" no_mod=true)}} in `0.5` was renamed to {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemMeta" no_mod=true)}}. From fc4bf74c92d2e59507dcce411f7329b88564d444 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Sat, 10 Jul 2021 17:32:43 +0200 Subject: [PATCH 05/14] Reduce the SystemState Example --- .../book/migration-guides/0.5-0.6/_index.md | 40 ++++++------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index 7ba1ea70f3..a64eaa89d7 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -88,7 +88,7 @@ In addition the {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.6.0 To get easier cached access to a {{rust_type(type="trait" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemParam" no_mod=true)}} outside of a system, a new {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemState" no_mod=true)}} was introduced. - + ```rust #[derive(Eq, PartialEq, Debug)] struct A(usize); @@ -101,37 +101,23 @@ world.insert_resource(A(42)); world.spawn().insert(B(7)); // we get nice lifetime elision when declaring the type on the left hand side -let mut system_state: SystemState<(Res, Query<&B>)> = SystemState::new(&mut world); -let (a, query) = system_state.get(&world); -assert_eq!(*a, A(42), "returned resource matches initial value"); -assert_eq!( - *query.single().unwrap(), - B(7), - "returned component matches initial value" -); - -// mutable system params require unique world access -let mut system_state: SystemState<(ResMut, Query<&mut B>)> = SystemState::new(&mut world); -let (a, query) = system_state.get_mut(&mut world); - -// static lifetimes are required when declaring inside of structs -struct SomeContainer { - state: SystemState<(Res<'static, A>, Res<'static, B>)> -} +let mut system_state: SystemState<(Commands, Res, Query<&B>)> = SystemState::new(&mut world); +{ + let (mut commands, res, query) = system_state.get(&world); -// this can be shortened using type aliases, which will be useful for complex param tuples -type MyParams<'a> = (Res<'a, A>, Res<'a, B>); -struct SomeContainer { - state: SystemState> -} + assert_eq!(*res, A(42), "returned resource matches initial value"); + assert_eq!( + *query.single().unwrap(), + B(7), + "returned component matches initial value" + ); -// It is the user's responsibility to call SystemState::apply(world) for parameters that queue up work -let mut system_state: SystemState<(Commands, Query<&B>)> = SystemState::new(&mut world); -{ - let (mut commands, query) = system_state.get(&world); commands.insert_resource(3.14); } +// It is the user's responsibility to call SystemState::apply(world) for parameters that queue up work system_state.apply(&mut world); ``` +See the original [PR](https://github.com/bevyengine/bevy/pull/2283) for a larger usage example. + The preexisting {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.5.0" name="SystemState" no_mod=true)}} in `0.5` was renamed to {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemMeta" no_mod=true)}}. From b49664c605da58e53ce285552e5fbc7e6c50a696 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Sun, 18 Jul 2021 00:11:20 +0200 Subject: [PATCH 06/14] Add forgotten comma --- content/learn/book/migration-guides/0.5-0.6/_index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index a64eaa89d7..fde20b2edb 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -60,7 +60,7 @@ commands.spawn_bundle(LightBundle { fov: f32::to_radians(60.0), intensity: 200.0, range: 20.0, - } + }, ..Default::default() }); @@ -70,7 +70,7 @@ commands.spawn_bundle(PointLightBundle { color: Color::rgb(1.0, 1.0, 1.0), intensity: 200.0, range: 20.0, - } + }, ..Default::default() }); ``` From c6366ca55f1ac618fe97377b7e9f4f2515c9b8da Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Sun, 18 Jul 2021 01:51:18 +0200 Subject: [PATCH 07/14] Don't showcase the new SystemState in the migration guide. --- .../book/migration-guides/0.5-0.6/_index.md | 39 ++----------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index fde20b2edb..5cdfa30ca9 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -84,40 +84,9 @@ In addition the {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.6.0 --> -### New SystemState and rename old SystemState to SystemMeta +### "SystemState" is now "SystemMeta" -To get easier cached access to a {{rust_type(type="trait" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemParam" no_mod=true)}} outside of a system, a new {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemState" no_mod=true)}} was introduced. +The {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.5.0" name="SystemState" no_mod=true)}} struct, which stores the metadata of a System, was renamed to {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemMeta" no_mod=true)}}. - -```rust -#[derive(Eq, PartialEq, Debug)] -struct A(usize); - -#[derive(Eq, PartialEq, Debug)] -struct B(usize); - -let mut world = World::default(); -world.insert_resource(A(42)); -world.spawn().insert(B(7)); - -// we get nice lifetime elision when declaring the type on the left hand side -let mut system_state: SystemState<(Commands, Res, Query<&B>)> = SystemState::new(&mut world); -{ - let (mut commands, res, query) = system_state.get(&world); - - assert_eq!(*res, A(42), "returned resource matches initial value"); - assert_eq!( - *query.single().unwrap(), - B(7), - "returned component matches initial value" - ); - - commands.insert_resource(3.14); -} -// It is the user's responsibility to call SystemState::apply(world) for parameters that queue up work -system_state.apply(&mut world); -``` - -See the original [PR](https://github.com/bevyengine/bevy/pull/2283) for a larger usage example. - -The preexisting {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.5.0" name="SystemState" no_mod=true)}} in `0.5` was renamed to {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemMeta" no_mod=true)}}. +This was done to accomedate the new {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemState" no_mod=true)}} which allows easier cached access to {{rust_type(type="trait" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemParam" no_mod=true plural=true)}} outside of a regular System. + From 4fb7f4a8a1f2a92754e943625e0a94ed4373c584 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Tue, 14 Sep 2021 17:22:42 +0200 Subject: [PATCH 08/14] Add bevyengine/bevy#2793 to guide --- .../book/migration-guides/0.5-0.6/_index.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index 5cdfa30ca9..dd67531664 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -49,6 +49,31 @@ fn main() { } ``` +### ".single()" and ".single_mut()" are now infallible + +The functions {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="Query" no_mod=true method="single")}} and {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="Query" no_mod=true method="single_mut")}} no longer return a {{rust_type(type="enum", crate="std" mod="result", name="Result", no_mod=true)}} and Panic instead, if not exactly one Entity was found. + +If you need the old behavior you can use the fallible {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="Query" no_mod=true method="get_single")}} and {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="Query" no_mod=true method="get_single_mut")}} instead. + +```rs +// 0.5 +fn player_system(query: Query<&Transform, With>) { + let player_position = query.single().unwrap(); + // do something with player_position +} + +// 0.6 +fn player_system_infallible(query: Query<&Transform, With>) { + let player_position = query.single(); + // do something with player_position +} + +fn player_system_fallible(query: Query<&Transform, With>) { + let player_position = query.get_single().unwrap(); + // do something with player_position +} +``` + ### "Light" and "LightBundle" are now "PointLight" and "PointLightBundle" ```rust From b32b2b15b524871a54f7db8a254d7e256717b8fe Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Tue, 14 Sep 2021 18:35:15 +0200 Subject: [PATCH 09/14] Add bevyengine/bevy#2531 --- .../book/migration-guides/0.5-0.6/_index.md | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index dd67531664..b2645db72d 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -8,6 +8,41 @@ page_template = "book-section.html" long_title = "Migration Guide: 0.5 to 0.6" +++ +### "AppBuilder" was merged into "App" + +All functions of {{rust_type(type="struct" crate="bevy_app" mod="" version="0.5.0" name="AppBuilder" no_mod=true)}} were merged into {{rust_type(type="struct" crate="bevy_app" mod="" version="0.6.0" name="App" no_mod=true)}}. + +In practice this means that you start constructing an {{rust_type(type="struct" crate="bevy_app" mod="" version="0.6.0" name="App" no_mod=true)}} by calling {{rust_type(type="struct" crate="bevy_app" mod="" version="0.6.0" name="App" no_mod=true method="new")}} instead of {{rust_type(type="struct" crate="bevy_app" mod="" version="0.5.0" name="App" no_mod=true method="build")}} and {{rust_type(type="trait" crate="bevy_app" mod="" version="0.5.0" name="Plugin" no_mod=true method="build")}} takes a {{rust_type(type="struct" crate="bevy_app" mod="" version="0.6.0" name="App" no_mod=true)}} instead of a {{rust_type(type="struct" crate="bevy_app" mod="" version="0.5.0" name="AppBuilder" no_mod=true)}} + +```rs +// 0.5 +fn main() { + App::build() + .add_plugin(SomePlugin) + .run(); +} + +impl Plugin for SomePlugin { + fn build(&self, app: &mut AppBuilder) { + + } +} + +// 0.6 +fn main() { + App::new() + .add_plugin(SomePlugin) + .run(); +} + +impl Plugin for SomePlugin { + fn build(&self, app: &mut App) { + + } +} + +``` + ### Calling ".system()" on a system is now optional ```rust @@ -21,7 +56,7 @@ fn main() { // 0.6 fn main() { - App::build() + App::new() .add_system(first_system) .add_system(second_system.system()) .run(); @@ -42,7 +77,7 @@ fn main() { // 0.6 fn main() { - App::build() + App::new() .add_system(first_system.label("FirstSystem")) .add_system(second_system.after("FirstSystem")) .run(); From d37885750abf122e7239cf49b5b7b420f5042328 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Tue, 14 Sep 2021 18:40:28 +0200 Subject: [PATCH 10/14] Minor editing --- content/learn/book/migration-guides/0.5-0.6/_index.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index b2645db72d..a1cc94d806 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -45,6 +45,8 @@ impl Plugin for SomePlugin { ### Calling ".system()" on a system is now optional +When adding a system to Bevy it is no longer necessary to call `.system()` beforehand. + ```rust // 0.5 fn main() { @@ -63,8 +65,7 @@ fn main() { } ``` -When adding a system to Bevy it is no longer necessary to call `.system()` beforehand. -System Configuration Functions like `.label()` or `.config()` can now also be directly called on a system. +System configuration Functions like `.label()` or `.config()` can now also be directly called on a system. ```rust // 0.5 @@ -148,5 +149,5 @@ In addition the {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.6.0 The {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.5.0" name="SystemState" no_mod=true)}} struct, which stores the metadata of a System, was renamed to {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemMeta" no_mod=true)}}. -This was done to accomedate the new {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemState" no_mod=true)}} which allows easier cached access to {{rust_type(type="trait" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemParam" no_mod=true plural=true)}} outside of a regular System. +This was done to accommodate the new {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemState" no_mod=true)}} which allows easier cached access to {{rust_type(type="trait" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemParam" no_mod=true plural=true)}} outside of a regular System. From ec62faa11d37d9e76d06573aa44a1a7e7603d93a Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Tue, 14 Sep 2021 22:27:13 +0200 Subject: [PATCH 11/14] Add bevyengine/bevy#2605 --- .../book/migration-guides/0.5-0.6/_index.md | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index a1cc94d806..9fb8f4024c 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -145,6 +145,49 @@ In addition the {{rust_type(type="struct" crate="bevy_pbr" mod="" version="0.6.0 --> +### System Param Lifetime Split + +The Lifetime of {{rust_type(type="trait" crate="bevy_ecs" mod="system" version="0.5.0" name="SystemParam" no_mod=true)}} was split in two separate Lifetimes. + +```rust +// 0.5 +type SystemParamAlias<'a> = (Res<'a, AssetServer>, Query<'a, &'static Transform>, Local<'a, i32>); + +#[derive(SystemParam)] +struct SystemParamDerive<'a> { + res: Res<'a, AssetServer>, + query: Query<'a, &Transform>, + local: Local<'a, i32>, +} + +// 0.6 +type SystemParamAlias<'w, 's> = (Res<'w, AssetServer>, Query<'w, 's, &'static Transform>, Local<'s, i32>); + +#[derive(SystemParam)] +struct SystemParamDerive<'w, 's> { + res: Res<'w, AssetServer>, + query: Query<'w, 's, &'static Transform>, + local: Local<'s, i32>, +} +``` + +### QuerySet declare "QueryState" instead of "Query" + + +Due to the [System Param Lifetime Split](#system-param-lifetime-split), {{rust_type(type="struct" crate="bevy_ecs" mod="system" name="QuerySet" version="0.6.0" no_mod=true plural=true)}} now need to specify their Queries with {{rust_type(type="struct" crate="bevy_ecs" mod="query" version="0.6.0" name="QuerySet" no_mod=true)}} instead of {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="Query" no_mod=true)}}. + +```rust +// 0.5 +fn query_set(mut queries: QuerySet<(Query<&mut Transform>, Query<&Transform>)>) { + +} + +// 0.6 +fn query_set(mut queries: QuerySet<(QueryState<&mut Transform>, QueryState<&Transform>)>) { + +} +``` + ### "SystemState" is now "SystemMeta" The {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.5.0" name="SystemState" no_mod=true)}} struct, which stores the metadata of a System, was renamed to {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemMeta" no_mod=true)}}. From 7c1166286b5fe98a5601b7cef5cfeef7c489a4a8 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Mon, 6 Dec 2021 00:35:32 +0100 Subject: [PATCH 12/14] Add bevyengine/bevy#2254 --- .../book/migration-guides/0.5-0.6/_index.md | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index 9fb8f4024c..36f87f0ffa 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -40,7 +40,46 @@ impl Plugin for SomePlugin { } } +``` + +### The "Component" Trait does now need to be derived + +Bevy no longer has a blanket implementation for the {{rust_type(type="trait" crate="bevy_ecs" mod="component" version="0.6.0" name="Component" no_mod=true)}} trait. +Instead you need to derive (or manualy implement) the trait for every Type that needs it. + +```rust +// 0.5 +struct MyComponent; + +// 0.6 +#[derive(Component)] +struct MyComponent; +``` + +In order to use foreign types as components, wrap them using the newtype pattern. +```rust +#[derive(Component)] +struct Cooldown(std::time::Duration); +``` + +### Setting the Component Storage is now done in "Component" Trait + +The change to deriving {{rust_type(type="trait" crate="bevy_ecs" mod="component" version="0.6.0" name="Component" no_mod=true)}}, enabled setting the Component Storage at compiletime instead of runtime. + +```rust +// 0.5 +appbuilder + .world + .register_component(ComponentDescriptor::new::( + StorageType::SparseSet, + )) + .unwrap(); + +// 0.6 +#[derive(Component)] +#[component(storage = "SparseSet")] +struct MyComponent; ``` ### Calling ".system()" on a system is now optional From 9512623420103a4f8d0c76e027e08e92ae5b2ec9 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Mon, 6 Dec 2021 00:44:45 +0100 Subject: [PATCH 13/14] Add bevyengine/bevy#1781 --- content/learn/book/migration-guides/0.5-0.6/_index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index 36f87f0ffa..4ff795e09d 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -227,6 +227,10 @@ fn query_set(mut queries: QuerySet<(QueryState<&mut Transform>, QueryState<&Tran } ``` +### "Input\.update()" is renamed to "Input\.clear()" + +The {{rust_type(type="struct" crate="bevy_input" mod="" version="0.5.0" name="Input" no_mod=true method="update")}} function was renamed to {{rust_type(type="struct" crate="bevy_input" mod="" version="0.6.0" name="Input" no_mod=true method="clear")}}. + ### "SystemState" is now "SystemMeta" The {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.5.0" name="SystemState" no_mod=true)}} struct, which stores the metadata of a System, was renamed to {{rust_type(type="struct" crate="bevy_ecs" mod="system" version="0.6.0" name="SystemMeta" no_mod=true)}}. From 72949e7a99e76e35a6bc748c08805285f3081676 Mon Sep 17 00:00:00 2001 From: MinerSebas <66798382+MinerSebas@users.noreply.github.com> Date: Tue, 7 Dec 2021 00:32:28 +0100 Subject: [PATCH 14/14] Adjust heading Co-authored-by: Alice Cecile --- content/learn/book/migration-guides/0.5-0.6/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/learn/book/migration-guides/0.5-0.6/_index.md b/content/learn/book/migration-guides/0.5-0.6/_index.md index 4ff795e09d..88e7bafd1e 100644 --- a/content/learn/book/migration-guides/0.5-0.6/_index.md +++ b/content/learn/book/migration-guides/0.5-0.6/_index.md @@ -42,7 +42,7 @@ impl Plugin for SomePlugin { } ``` -### The "Component" Trait does now need to be derived +### The "Component" trait now needs to be derived Bevy no longer has a blanket implementation for the {{rust_type(type="trait" crate="bevy_ecs" mod="component" version="0.6.0" name="Component" no_mod=true)}} trait. Instead you need to derive (or manualy implement) the trait for every Type that needs it.