From a7b308aa11ad82ac6b3b74c0237e607f1d4ddf5b Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Wed, 31 Jan 2024 07:50:06 -0700 Subject: [PATCH] Upgrade to Bevy 0.13 --- Cargo.toml | 184 ++++++++++++------------ examples/animation.rs | 4 +- examples/basic.rs | 4 +- examples/frustum_cull_test.rs | 7 +- examples/game_of_life.rs | 5 +- examples/helpers/camera.rs | 16 +-- examples/hex_neighbors.rs | 24 ++-- examples/hex_neighbors_radius_chunks.rs | 12 +- examples/hexagon_column.rs | 2 +- examples/hexagon_generation.rs | 6 +- examples/hexagon_row.rs | 2 +- examples/mouse_to_tile.rs | 10 +- examples/move_tile.rs | 2 +- src/map/mod.rs | 4 +- src/render/chunk.rs | 8 +- src/render/draw.rs | 54 ++++--- src/render/pipeline.rs | 45 +++--- src/render/prepare.rs | 4 +- src/tiles/storage.rs | 4 +- 19 files changed, 208 insertions(+), 189 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e895314e..0377fa68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ render = [] serde = ["dep:serde"] [dependencies] -bevy = { version = "0.12", default-features = false, features = [ +bevy = { version = "0.13", default-features = false, features = [ "bevy_core_pipeline", "bevy_render", "bevy_asset", @@ -35,7 +35,7 @@ tiled = { version = "0.11.0", default-features = false } thiserror = { version = "1.0" } [dev-dependencies.bevy] -version = "0.12" +version = "0.13" default-features = false features = [ "bevy_core_pipeline", @@ -47,11 +47,11 @@ features = [ "bevy_text", "bevy_sprite", #"file_watcher", - "multi-threaded" + "multi-threaded", ] [target.'cfg(unix)'.dev-dependencies.bevy] -version = "0.12" +version = "0.13" default-features = false features = [ "bevy_core_pipeline", @@ -63,123 +63,123 @@ features = [ "x11", "bevy_text", "bevy_sprite", - "multi-threaded" + "multi-threaded", ] [[example]] -name="3d_iso" -path="examples/3d_iso.rs" -required-features=["render"] +name = "3d_iso" +path = "examples/3d_iso.rs" +required-features = ["render"] [[example]] -name="accessing_tiles" -path="examples/accessing_tiles.rs" -required-features=["render"] +name = "accessing_tiles" +path = "examples/accessing_tiles.rs" +required-features = ["render"] [[example]] -name="animation" -path="examples/animation.rs" -required-features=["render"] +name = "animation" +path = "examples/animation.rs" +required-features = ["render"] [[example]] -name="basic" -path="examples/basic.rs" -required-features=["render"] +name = "basic" +path = "examples/basic.rs" +required-features = ["render"] [[example]] -name="bench" -path="examples/bench.rs" -required-features=["render"] +name = "bench" +path = "examples/bench.rs" +required-features = ["render"] [[example]] -name="chunking" -path="examples/chunking.rs" -required-features=["render"] +name = "chunking" +path = "examples/chunking.rs" +required-features = ["render"] [[example]] -name="colors" -path="examples/colors.rs" -required-features=["render"] +name = "colors" +path = "examples/colors.rs" +required-features = ["render"] [[example]] -name="custom_shader" -path="examples/custom_shader.rs" -required-features=["render"] +name = "custom_shader" +path = "examples/custom_shader.rs" +required-features = ["render"] [[example]] -name="frustum_cull_test" -path="examples/frustum_cull_test.rs" -required-features=["render"] +name = "frustum_cull_test" +path = "examples/frustum_cull_test.rs" +required-features = ["render"] [[example]] -name="game_of_life" -path="examples/game_of_life.rs" -required-features=["render"] +name = "game_of_life" +path = "examples/game_of_life.rs" +required-features = ["render"] [[example]] -name="hex_neighbors_radius_chunks" -path="examples/hex_neighbors_radius_chunks.rs" -required-features=["render"] +name = "hex_neighbors_radius_chunks" +path = "examples/hex_neighbors_radius_chunks.rs" +required-features = ["render"] [[example]] -name="hex_neighbors" -path="examples/hex_neighbors.rs" -required-features=["render"] +name = "hex_neighbors" +path = "examples/hex_neighbors.rs" +required-features = ["render"] [[example]] -name="hexagon_column" -path="examples/hexagon_column.rs" -required-features=["render"] +name = "hexagon_column" +path = "examples/hexagon_column.rs" +required-features = ["render"] [[example]] -name="hexagon_generation" -path="examples/hexagon_generation.rs" -required-features=["render"] +name = "hexagon_generation" +path = "examples/hexagon_generation.rs" +required-features = ["render"] [[example]] -name="hexagon_row" -path="examples/hexagon_row.rs" -required-features=["render"] +name = "hexagon_row" +path = "examples/hexagon_row.rs" +required-features = ["render"] [[example]] -name="iso_diamond" -path="examples/iso_diamond.rs" -required-features=["render"] +name = "iso_diamond" +path = "examples/iso_diamond.rs" +required-features = ["render"] [[example]] -name="iso_staggered" -path="examples/iso_staggered.rs" -required-features=["render"] +name = "iso_staggered" +path = "examples/iso_staggered.rs" +required-features = ["render"] [[example]] -name="layers" -path="examples/layers.rs" -required-features=["render"] +name = "layers" +path = "examples/layers.rs" +required-features = ["render"] [[example]] -name="ldtk" -path="examples/ldtk.rs" -required-features=["render"] +name = "ldtk" +path = "examples/ldtk.rs" +required-features = ["render"] [[example]] -name="mouse_to_tile" -path="examples/mouse_to_tile.rs" -required-features=["render"] +name = "mouse_to_tile" +path = "examples/mouse_to_tile.rs" +required-features = ["render"] [[example]] -name="move_tile" -path="examples/move_tile.rs" -required-features=["render"] +name = "move_tile" +path = "examples/move_tile.rs" +required-features = ["render"] [[example]] -name="random_map" -path="examples/random_map.rs" -required-features=["render"] +name = "random_map" +path = "examples/random_map.rs" +required-features = ["render"] [[example]] -name="remove_tiles" -path="examples/remove_tiles.rs" -required-features=["render"] +name = "remove_tiles" +path = "examples/remove_tiles.rs" +required-features = ["render"] [[example]] -name="spacing" -path="examples/spacing.rs" -required-features=["render"] +name = "spacing" +path = "examples/spacing.rs" +required-features = ["render"] [[example]] -name="texture_container" -path="examples/texture_container.rs" -required-features=["render"] +name = "texture_container" +path = "examples/texture_container.rs" +required-features = ["render"] [[example]] -name="texture_vec" -path="examples/texture_vec.rs" -required-features=["render"] +name = "texture_vec" +path = "examples/texture_vec.rs" +required-features = ["render"] [[example]] -name="tiled_rotated" -path="examples/tiled_rotated.rs" -required-features=["render"] +name = "tiled_rotated" +path = "examples/tiled_rotated.rs" +required-features = ["render"] [[example]] -name="tiled" -path="examples/tiled.rs" -required-features=["render"] +name = "tiled" +path = "examples/tiled.rs" +required-features = ["render"] [[example]] -name="visibility" -path="examples/visibility.rs" -required-features=["render"] +name = "visibility" +path = "examples/visibility.rs" +required-features = ["render"] diff --git a/examples/animation.rs b/examples/animation.rs index 5f340c9d..59ff5c20 100644 --- a/examples/animation.rs +++ b/examples/animation.rs @@ -150,8 +150,8 @@ fn main() { .run(); } -fn pause_animation(mut query: Query<&mut AnimatedTile>, keys: Res>) { - if keys.just_pressed(KeyCode::P) { +fn pause_animation(mut query: Query<&mut AnimatedTile>, keys: Res>) { + if keys.just_pressed(KeyCode::KeyP) { for mut anim in &mut query { anim.speed = if anim.speed == 0.0 { 1.0 } else { 0.0 } } diff --git a/examples/basic.rs b/examples/basic.rs index 7c1c83bd..b9a2868e 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -74,7 +74,7 @@ fn startup( fn swap_texture_or_hide( asset_server: Res, - keyboard_input: Res>, + keyboard_input: Res>, mut query: Query<(&mut TilemapTexture, &mut Visibility)>, ) { if keyboard_input.just_pressed(KeyCode::Space) { @@ -88,7 +88,7 @@ fn swap_texture_or_hide( } } } - if keyboard_input.just_pressed(KeyCode::H) { + if keyboard_input.just_pressed(KeyCode::KeyH) { for (_, mut visibility) in &mut query { *visibility = match *visibility { Visibility::Inherited | Visibility::Visible => Visibility::Hidden, diff --git a/examples/frustum_cull_test.rs b/examples/frustum_cull_test.rs index 48d29f88..ee15f082 100644 --- a/examples/frustum_cull_test.rs +++ b/examples/frustum_cull_test.rs @@ -127,7 +127,7 @@ fn spawn_map_type_label( font_size: 20.0, color: Color::BLACK, }; - let text_alignment = TextAlignment::Center; + let text_justify = JustifyText::Center; for window in windows.iter() { for map_type in map_type_q.iter() { @@ -140,7 +140,7 @@ fn spawn_map_type_label( commands.spawn(( Text2dBundle { text: Text::from_section(format!("{map_type:?}"), text_style.clone()) - .with_alignment(text_alignment), + .with_justify(text_justify), transform, ..default() }, @@ -159,7 +159,7 @@ fn swap_map_type( &mut TilemapTexture, &mut TilemapTileSize, )>, - keyboard_input: Res>, + keyboard_input: Res>, mut map_type_label_q: Query<&mut Text, With>, tile_handle_square: Res, tile_handle_hex_row: Res, @@ -240,6 +240,7 @@ fn main() { level: Level::ERROR, // except for bevy_ecs_tilemap filter: "bevy_ecs_tilemap=trace".into(), + ..default() }), ) .add_plugins(TilemapPlugin) diff --git a/examples/game_of_life.rs b/examples/game_of_life.rs index 70ff515a..6b11cacc 100644 --- a/examples/game_of_life.rs +++ b/examples/game_of_life.rs @@ -67,9 +67,8 @@ fn update( .entities(tile_storage) .iter() .filter(|neighbor| { - let tile_component = - tile_query.get_component::(**neighbor).unwrap(); - tile_component.0 + let (_, _, tile_visible) = tile_query.get(**neighbor).unwrap(); + tile_visible.0 }) .count(); diff --git a/examples/helpers/camera.rs b/examples/helpers/camera.rs index a6068e4c..e6155f5c 100644 --- a/examples/helpers/camera.rs +++ b/examples/helpers/camera.rs @@ -1,36 +1,36 @@ -use bevy::{input::Input, math::Vec3, prelude::*, render::camera::Camera}; +use bevy::{input::ButtonInput, math::Vec3, prelude::*, render::camera::Camera}; // A simple camera system for moving and zooming the camera. #[allow(dead_code)] pub fn movement( time: Res