diff --git a/.cargo/config_fast_builds b/.cargo/config_fast_builds index b92e77e95884a..4d1ff9c1e3b38 100644 --- a/.cargo/config_fast_builds +++ b/.cargo/config_fast_builds @@ -10,10 +10,10 @@ rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"] # NOTE: you must manually install https://github.com/michaeleisel/zld on mac. you can easily do this with the "brew" package manager: # `brew install michaeleisel/zld/zld` [target.x86_64-apple-darwin] -rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld", "-Zshare-generics=y"] +rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/bin/zld", "-Zshare-generics=y"] [target.aarch64-apple-darwin] -rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld", "-Zshare-generics=y"] +rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/bin/zld", "-Zshare-generics=y"] [target.x86_64-pc-windows-msvc] linker = "rust-lld.exe" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b7e1949a5bc2..c49157a7fd824 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: toolchain: nightly runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/cache@v2 with: path: | @@ -49,7 +49,7 @@ jobs: ci: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/cache@v2 with: path: | @@ -74,7 +74,7 @@ jobs: runs-on: ubuntu-latest needs: ci steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/cache@v2 with: path: | @@ -100,7 +100,7 @@ jobs: os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/cache@v2 with: path: | @@ -124,7 +124,7 @@ jobs: build-android: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -151,7 +151,7 @@ jobs: needs: check-missing-examples-in-docs if: always() steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 @@ -169,7 +169,7 @@ jobs: needs: markdownlint if: always() steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: check dead links continue-on-error: true id: run1 @@ -227,7 +227,7 @@ jobs: sudo add-apt-repository ppa:oibaf/graphics-drivers -y sudo apt-get update sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/cache@v2 with: path: | @@ -253,7 +253,7 @@ jobs: done zip traces.zip trace*.json - name: save traces - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 with: name: example-traces.zip path: traces.zip @@ -263,7 +263,7 @@ jobs: needs: check-markdown-links if: always() steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -281,7 +281,7 @@ jobs: check-missing-examples-in-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Check that examples are present in both README and Cargo uses: Weibye/action-internal-link-consistency@1.0.0 with: @@ -294,7 +294,7 @@ jobs: check-unused-dependencies: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/cache@v2 with: path: | diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 619d2115a10a9..9ef408201a54a 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -22,7 +22,7 @@ jobs: check-advisories: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -35,7 +35,7 @@ jobs: check-bans: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -48,7 +48,7 @@ jobs: check-licenses: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -61,7 +61,7 @@ jobs: check-sources: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: toolchain: stable diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 4c24217d5e57d..f3db038aaa191 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -11,7 +11,7 @@ jobs: build: runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 24f2c637e16c3..fd16a55d86efe 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/labeler@v3 + - uses: actions/labeler@v4 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: .github/label-config.yml diff --git a/Cargo.toml b/Cargo.toml index 76130b0a1a8f7..5efa16115826e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ tga = ["bevy_internal/tga"] jpeg = ["bevy_internal/jpeg"] bmp = ["bevy_internal/bmp"] -# Audio format support (MP3 is enabled by default) +# Audio format support (vorbis is enabled by default) flac = ["bevy_internal/flac"] mp3 = ["bevy_internal/mp3"] vorbis = ["bevy_internal/vorbis"] @@ -98,7 +98,9 @@ bevy_dylib = { path = "crates/bevy_dylib", version = "0.6.0", default-features = bevy_internal = { path = "crates/bevy_internal", version = "0.6.0", default-features = false } [target.'cfg(target_arch = "wasm32")'.dependencies] -bevy_internal = { path = "crates/bevy_internal", version = "0.6.0", default-features = false, features = ["webgl"] } +bevy_internal = { path = "crates/bevy_internal", version = "0.6.0", default-features = false, features = [ + "webgl", +] } [dev-dependencies] anyhow = "1.0.4" @@ -128,7 +130,7 @@ name = "move_sprite" path = "examples/2d/move_sprite.rs" [[example]] -name = "2d_rotation" +name = "rotation" path = "examples/2d/rotation.rs" [[example]] @@ -304,6 +306,10 @@ path = "examples/async_tasks/external_source_external_thread.rs" name = "audio" path = "examples/audio/audio.rs" +[[example]] +name = "audio_control" +path = "examples/audio/audio_control.rs" + # Diagnostics [[example]] name = "log_diagnostics" @@ -424,6 +430,10 @@ path = "examples/input/mouse_input.rs" name = "mouse_input_events" path = "examples/input/mouse_input_events.rs" +[[example]] +name = "mouse_grab" +path = "examples/input/mouse_grab.rs" + [[example]] name = "touch_input" path = "examples/input/touch_input.rs" @@ -467,6 +477,10 @@ path = "examples/shader/shader_defs.rs" name = "shader_material" path = "examples/shader/shader_material.rs" +[[example]] +name = "shader_material_screenspace_texture" +path = "examples/shader/shader_material_screenspace_texture.rs" + [[example]] name = "shader_material_glsl" path = "examples/shader/shader_material_glsl.rs" @@ -514,6 +528,10 @@ path = "examples/ui/ui.rs" name = "clear_color" path = "examples/window/clear_color.rs" +[[example]] +name = "low_power" +path = "examples/window/low_power.rs" + [[example]] name = "multiple_windows" path = "examples/window/multiple_windows.rs" diff --git a/assets/branding/banner-text.png b/assets/branding/banner-text.png deleted file mode 100644 index 2f8b2198b4ddb..0000000000000 Binary files a/assets/branding/banner-text.png and /dev/null differ diff --git a/assets/branding/banner.png b/assets/branding/banner.png index 1d5fad437bdc3..3c5db79ac20f8 100644 Binary files a/assets/branding/banner.png and b/assets/branding/banner.png differ diff --git a/assets/branding/bevy_bird_simpleicons.svg b/assets/branding/bevy_bird_simpleicons.svg index 25597d418ac69..dc9c07bb9db74 100644 --- a/assets/branding/bevy_bird_simpleicons.svg +++ b/assets/branding/bevy_bird_simpleicons.svg @@ -1 +1 @@ -Bevy Engine +Bevy Engine \ No newline at end of file diff --git a/assets/branding/bevy_logo_dark.png b/assets/branding/bevy_logo_dark.png index b7fcdd7ba40d6..3e2cbdf519829 100644 Binary files a/assets/branding/bevy_logo_dark.png and b/assets/branding/bevy_logo_dark.png differ diff --git a/assets/branding/bevy_logo_dark.svg b/assets/branding/bevy_logo_dark.svg index ab9bf8a71919d..241509d32d06b 100644 --- a/assets/branding/bevy_logo_dark.svg +++ b/assets/branding/bevy_logo_dark.svg @@ -1,19 +1,18 @@ + width="146.71918mm" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#"> + id="base" + inkscape:pagecheckerboard="0" /> - image/svg+xml - - - + rdf:about="" /> + d="m 2191.1465,2276.7832 c -5.9729,-0.035 -12.0979,2.348 -17.3613,7.459 -6.9129,6.7127 -9.0602,12.7555 -7.8477,20.2949 l 0.332,2.0684 -2.0664,-0.336 c -15.1877,-2.4609 -33.9847,-1.2178 -55.3711,7.4336 6.2868,2.6948 17.8259,7.1926 30.6309,13.3418 l 4.0605,1.9512 -4.414,0.8945 c -16.9087,3.4274 -36.9729,13.3275 -55.2989,34.9336 8.1981,-0.6372 24.9531,-2.6089 42.4278,-2.582 9.7138,0.015 19.2869,0.687 27.0859,2.709 7.7991,2.022 14.8874,6.6498 15.8861,10.0406 0.9987,3.3908 0.432,5.1761 -0.5519,7.8285 -0.9839,2.6524 -4.0098,6.6817 -8.1953,9.3418 -4.1855,2.6601 -9.4961,4.9849 -15.0137,6.9609 -11.0352,3.9521 -22.7798,6.4773 -27.9648,6.959 -1.1021,0.1024 -1.5421,0.4983 -1.9668,1.2696 -0.4247,0.7712 -0.659,1.9824 -0.6934,3.25 -0.046,1.6926 0.217,2.576 0.6949,3.246 0.4779,0.67 1.2243,0.9381 1.9934,0.9902 32.5822,2.2052 56.9441,-5.9907 74.6379,-13.0116 20.3508,-9.3311 33.2134,-27.7577 36.0058,-44.3477 1.7499,-10.395 1.3746,-15.4894 -0.3124,-19.8281 -1.6873,-4.3387 -4.9223,-8.1914 -9.0254,-15.5488 -2.6368,-4.7281 -4.1077,-9.367 -5.0196,-13.6875 l -0.1933,-0.9102 0.7265,-0.582 c 7.5403,-6.0446 13.6809,-12.6444 15.9102,-17.4492 -4.5742,-4.8648 -12.4787,-5.893 -21.3223,-4.9473 l -0.7265,0.076 -0.5118,-0.5215 c -4.7125,-4.8006 -10.5615,-7.2614 -16.5351,-7.2969 z m 2.6484,11.2324 c 2.593,-0.041 4.8808,1.7566 5.502,4.3223 0.7307,3.0216 -1.0812,6.0525 -4.0469,6.7695 -2.9656,0.7176 -5.9625,-1.1502 -6.6934,-4.1719 -0.7307,-3.0216 1.0812,-6.0525 4.0469,-6.7695 0.3902,-0.094 0.7897,-0.1445 1.1914,-0.1504 z" + transform="translate(5.0092774e-5,-757.87625)" + sodipodi:nodetypes="cccccccccccczzzcscczscccsccccccccccccccc" /> + viewBox="0 0 148.52753 37.72488" + height="37.72488mm" + width="148.52753mm" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#"> + id="defs2315" /> + inkscape:window-x="0" + inkscape:window-height="1440" + inkscape:window-width="3440" + showgrid="false" + inkscape:document-rotation="0" + inkscape:current-layer="layer1" + inkscape:document-units="mm" + inkscape:cy="91.696428" + inkscape:cx="126.96429" + inkscape:zoom="5.6" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + borderopacity="1.0" + bordercolor="#666666" + pagecolor="#ffffff" + id="base" + inkscape:pagecheckerboard="0" /> + id="metadata2318"> - image/svg+xml - - - + rdf:about="" /> + inkscape:groupmode="layer" + inkscape:label="Layer 1"> + style="opacity:1;fill:#c3c3c3;fill-opacity:1;stroke:#dadada;stroke-width:1.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"> + transform="matrix(-0.55180403,-0.23802315,-0.23802315,0.55180403,1946.7322,-620.612)" /> + style="opacity:1;fill:#282828;fill-opacity:1;stroke:#dadada;stroke-width:4.15748;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"> + sodipodi:nodetypes="cccccccccccczzzcscczscccsccccccccccccccc" /> + id="g1121-7-7-2-3-3-7-4-5-8-2-5-9-5" + style="fill:#757575;fill-opacity:1;stroke:#dadada;stroke-width:2.1586;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"> + style="opacity:1;fill:#757575;fill-opacity:1;stroke:#dadada;stroke-width:4.15748;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"> + transform="translate(1.2499985e-4,-757.87627)" /> @@ -130,31 +128,31 @@ diff --git a/assets/branding/bevy_logo_light_dark_and_dimmed.svg b/assets/branding/bevy_logo_light_dark_and_dimmed.svg index c6a952e7ad214..9d1e1e1ea5db1 100644 --- a/assets/branding/bevy_logo_light_dark_and_dimmed.svg +++ b/assets/branding/bevy_logo_light_dark_and_dimmed.svg @@ -1,178 +1,183 @@ - - - - - - - + viewBox="0 0 148.52753 37.72488" + height="37.72488mm" + width="148.52753mm" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#"> + + id="base" + inkscape:pagecheckerboard="0" /> + id="metadata2318"> - image/svg+xml - - - + rdf:about="" /> + + + + + inkscape:export-ydpi="81.422768" + style="opacity:1;fill:#c3c3c3;fill-opacity:1;stroke:#ffffff;stroke-width:1.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"> + inkscape:export-xdpi="81.422768" + inkscape:export-ydpi="81.422768"> + transform="matrix(-0.55180403,-0.23802315,-0.23802315,0.55180403,1946.7322,-620.612)" /> + inkscape:export-ydpi="81.422768"> - - - + style="opacity:1;fill:#282828;fill-opacity:1;stroke:#ffffff;stroke-width:4.15748;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"> + + inkscape:export-ydpi="81.422768"> + style="fill:#757575;fill-opacity:1;stroke:#ffffff;stroke-width:2.1586;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill" + id="g1129-5-9-8-0-7-2-7-3-8-61-1-6-8" + transform="translate(-20.244579,-6.1209206)"> + style="fill:#757575;fill-opacity:1;stroke:#ffffff;stroke-width:2.1586;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill" + id="g1344-1-3-9-3-8-8-8-3-5-4-8" + transform="translate(61.54776,-5.6726683)"> + id="g1121-7-7-2-3-3-7-4-5-8-2-5-9-5" + style="fill:#757575;fill-opacity:1;stroke:#ffffff;stroke-width:2.1586;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"> + style="opacity:1;fill:#757575;fill-opacity:1;stroke:#ffffff;stroke-width:4.15748;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"> + transform="translate(1.2499985e-4,-757.87627)" /> - - - - - - - - - - - - - + inkscape:export-ydpi="81.422768"> + + + + diff --git a/assets/branding/bevy_logo_light_small.svg b/assets/branding/bevy_logo_light_small.svg deleted file mode 100644 index 4dfbd89630830..0000000000000 --- a/assets/branding/bevy_logo_light_small.svg +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/assets/branding/icon.png b/assets/branding/icon.png index 5e72defd21325..8c9640bf2793c 100644 Binary files a/assets/branding/icon.png and b/assets/branding/icon.png differ diff --git a/assets/branding/icon.svg b/assets/branding/icon.svg new file mode 100644 index 0000000000000..c7c0381928635 --- /dev/null +++ b/assets/branding/icon.svg @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/shaders/custom_material_screenspace_texture.wgsl b/assets/shaders/custom_material_screenspace_texture.wgsl new file mode 100644 index 0000000000000..a1fa6998f20d2 --- /dev/null +++ b/assets/shaders/custom_material_screenspace_texture.wgsl @@ -0,0 +1,13 @@ +#import bevy_pbr::mesh_view_bind_group + +[[group(1), binding(0)]] +var texture: texture_2d; +[[group(1), binding(1)]] +var texture_sampler: sampler; + +[[stage(fragment)]] +fn fragment([[builtin(position)]] position: vec4) -> [[location(0)]] vec4 { + let uv = position.xy / vec2(view.width, view.height); + let color = textureSample(texture, texture_sampler, uv); + return color; +} diff --git a/benches/Cargo.toml b/benches/Cargo.toml index bb3aab4c1c3e3..1eac8d1d19794 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -8,7 +8,8 @@ license = "MIT OR Apache-2.0" [dev-dependencies] criterion = "0.3" -bevy = { path = ".." } +bevy_ecs = { path = "../crates/bevy_ecs" } +bevy_tasks = { path = "../crates/bevy_tasks" } [[bench]] name = "system_stage" diff --git a/benches/benches/bevy_ecs/commands.rs b/benches/benches/bevy_ecs/commands.rs index 3d78a16decdf2..e5993d98c23f7 100644 --- a/benches/benches/bevy_ecs/commands.rs +++ b/benches/benches/bevy_ecs/commands.rs @@ -1,4 +1,4 @@ -use bevy::ecs::{ +use bevy_ecs::{ component::Component, entity::Entity, system::{Command, CommandQueue, Commands}, diff --git a/benches/benches/bevy_ecs/stages.rs b/benches/benches/bevy_ecs/stages.rs index 8e572acff131c..0a843eb47305e 100644 --- a/benches/benches/bevy_ecs/stages.rs +++ b/benches/benches/bevy_ecs/stages.rs @@ -1,4 +1,4 @@ -use bevy::ecs::{ +use bevy_ecs::{ component::Component, schedule::{Stage, SystemStage}, system::Query, diff --git a/benches/benches/bevy_ecs/world_get.rs b/benches/benches/bevy_ecs/world_get.rs index 7c43789e3716f..ce36dfd703b7d 100644 --- a/benches/benches/bevy_ecs/world_get.rs +++ b/benches/benches/bevy_ecs/world_get.rs @@ -1,4 +1,4 @@ -use bevy::ecs::{component::Component, entity::Entity, world::World}; +use bevy_ecs::{component::Component, entity::Entity, world::World}; use criterion::{black_box, criterion_group, criterion_main, Criterion}; criterion_group!( diff --git a/benches/benches/bevy_tasks/iter.rs b/benches/benches/bevy_tasks/iter.rs index 5f267dbc4b4e0..74b043f9a234e 100644 --- a/benches/benches/bevy_tasks/iter.rs +++ b/benches/benches/bevy_tasks/iter.rs @@ -1,4 +1,4 @@ -use bevy::tasks::{ParallelIterator, TaskPoolBuilder}; +use bevy_tasks::{ParallelIterator, TaskPoolBuilder}; use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; struct ParChunks<'a, T>(std::slice::Chunks<'a, T>); diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index 5bbb9b5676abd..bc26b97419100 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1,8 +1,7 @@ -use crate::{ - CoreStage, Events, Plugin, PluginGroup, PluginGroupBuilder, StartupSchedule, StartupStage, -}; +use crate::{CoreStage, Plugin, PluginGroup, PluginGroupBuilder, StartupSchedule, StartupStage}; pub use bevy_derive::AppLabel; use bevy_ecs::{ + event::Events, prelude::{FromWorld, IntoExclusiveSystem}, schedule::{ IntoSystemDescriptor, RunOnce, Schedule, Stage, StageLabel, State, StateData, SystemSet, @@ -839,10 +838,7 @@ impl App { #[cfg(feature = "bevy_reflect")] pub fn register_type(&mut self) -> &mut Self { { - let registry = self - .world - .get_resource_mut::() - .unwrap(); + let registry = self.world.resource_mut::(); registry.write().register::(); } self diff --git a/crates/bevy_app/src/ci_testing.rs b/crates/bevy_app/src/ci_testing.rs index a61ee728dddf7..f837a601ccd93 100644 --- a/crates/bevy_app/src/ci_testing.rs +++ b/crates/bevy_app/src/ci_testing.rs @@ -12,7 +12,7 @@ pub struct CiTestingConfig { fn ci_testing_exit_after( mut current_frame: bevy_ecs::prelude::Local, ci_testing_config: bevy_ecs::prelude::Res, - mut app_exit_events: crate::EventWriter, + mut app_exit_events: bevy_ecs::event::EventWriter, ) { if let Some(exit_after) = ci_testing_config.exit_after { if *current_frame > exit_after { diff --git a/crates/bevy_app/src/lib.rs b/crates/bevy_app/src/lib.rs index 2a8eb88c94bae..6a6d3e8b4bae1 100644 --- a/crates/bevy_app/src/lib.rs +++ b/crates/bevy_app/src/lib.rs @@ -12,7 +12,6 @@ mod ci_testing; pub use app::*; pub use bevy_derive::DynamicPlugin; -pub use bevy_ecs::event::*; pub use plugin::*; pub use plugin_group::*; pub use schedule_runner::*; diff --git a/crates/bevy_app/src/schedule_runner.rs b/crates/bevy_app/src/schedule_runner.rs index 3227826f70d06..eb66c395a104f 100644 --- a/crates/bevy_app/src/schedule_runner.rs +++ b/crates/bevy_app/src/schedule_runner.rs @@ -1,9 +1,8 @@ use crate::{ app::{App, AppExit}, plugin::Plugin, - ManualEventReader, }; -use bevy_ecs::event::Events; +use bevy_ecs::event::{Events, ManualEventReader}; use bevy_utils::{Duration, Instant}; #[cfg(target_arch = "wasm32")] diff --git a/crates/bevy_asset/src/asset_server.rs b/crates/bevy_asset/src/asset_server.rs index c1656368b5818..c7159f146d402 100644 --- a/crates/bevy_asset/src/asset_server.rs +++ b/crates/bevy_asset/src/asset_server.rs @@ -794,24 +794,18 @@ mod test { app.add_system(update_asset_storage_system::.after(FreeUnusedAssets)); fn load_asset(path: AssetPath, world: &World) -> HandleUntyped { - let asset_server = world.get_resource::().unwrap(); + let asset_server = world.resource::(); let id = futures_lite::future::block_on(asset_server.load_async(path.clone(), true)) .unwrap(); asset_server.get_handle_untyped(id) } fn get_asset(id: impl Into, world: &World) -> Option<&PngAsset> { - world - .get_resource::>() - .unwrap() - .get(id.into()) + world.resource::>().get(id.into()) } fn get_load_state(id: impl Into, world: &World) -> LoadState { - world - .get_resource::() - .unwrap() - .get_load_state(id.into()) + world.resource::().get_load_state(id.into()) } // --- diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index a848132363a2d..a90afe5f20803 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -2,8 +2,12 @@ use crate::{ update_asset_storage_system, Asset, AssetLoader, AssetServer, AssetStage, Handle, HandleId, RefChange, }; -use bevy_app::{App, EventWriter, Events}; -use bevy_ecs::{system::ResMut, world::FromWorld}; +use bevy_app::App; +use bevy_ecs::{ + event::{EventWriter, Events}, + system::ResMut, + world::FromWorld, +}; use bevy_utils::HashMap; use crossbeam_channel::Sender; use std::fmt::Debug; @@ -182,12 +186,12 @@ impl Assets { /// Get a mutable iterator over all assets in the collection. pub fn iter_mut(&mut self) -> impl Iterator { - for id in self.assets.keys() { + self.assets.iter_mut().map(|(k, v)| { self.events.send(AssetEvent::Modified { - handle: Handle::weak(*id), + handle: Handle::weak(*k), }); - } - self.assets.iter_mut().map(|(k, v)| (*k, v)) + (*k, v) + }) } /// Get an iterator over all [`HandleId`]'s in the collection. @@ -287,7 +291,7 @@ impl AddAsset for App { return self; } let assets = { - let asset_server = self.world.get_resource::().unwrap(); + let asset_server = self.world.resource::(); asset_server.register_asset_type::() }; @@ -307,8 +311,7 @@ impl AddAsset for App { self.add_system(crate::debug_asset_server::sync_debug_assets::); let mut app = self .world - .get_non_send_resource_mut::() - .unwrap(); + .non_send_resource_mut::(); app.add_asset::() .init_resource::>(); } @@ -331,8 +334,7 @@ impl AddAsset for App { { let mut app = self .world - .get_non_send_resource_mut::() - .unwrap(); + .non_send_resource_mut::(); app.init_asset_loader::(); } self @@ -342,10 +344,7 @@ impl AddAsset for App { where T: AssetLoader, { - self.world - .get_resource_mut::() - .expect("AssetServer does not exist. Consider adding it as a resource.") - .add_loader(loader); + self.world.resource_mut::().add_loader(loader); self } } @@ -357,8 +356,7 @@ macro_rules! load_internal_asset { { let mut debug_app = $app .world - .get_non_send_resource_mut::() - .unwrap(); + .non_send_resource_mut::(); bevy_asset::debug_asset_server::register_handle_with_loader( $loader, &mut debug_app, @@ -367,10 +365,7 @@ macro_rules! load_internal_asset { $path_str, ); } - let mut assets = $app - .world - .get_resource_mut::>() - .unwrap(); + let mut assets = $app.world.resource_mut::>(); assets.set_untracked($handle, ($loader)(include_str!($path_str))); }}; } @@ -379,10 +374,7 @@ macro_rules! load_internal_asset { #[macro_export] macro_rules! load_internal_asset { ($app: ident, $handle: ident, $path_str: expr, $loader: expr) => {{ - let mut assets = $app - .world - .get_resource_mut::>() - .unwrap(); + let mut assets = $app.world.resource_mut::>(); assets.set_untracked($handle, ($loader)(include_str!($path_str))); }}; } @@ -402,10 +394,10 @@ mod tests { app.add_plugin(bevy_core::CorePlugin) .add_plugin(crate::AssetPlugin); app.add_asset::(); - let mut assets_before = app.world.get_resource_mut::>().unwrap(); + let mut assets_before = app.world.resource_mut::>(); let handle = assets_before.add(MyAsset); app.add_asset::(); // Ensure this doesn't overwrite the Asset - let assets_after = app.world.get_resource_mut::>().unwrap(); + let assets_after = app.world.resource_mut::>(); assert!(assets_after.get(handle).is_some()); } } diff --git a/crates/bevy_asset/src/debug_asset_server.rs b/crates/bevy_asset/src/debug_asset_server.rs index c7907644daeb3..d4970dabcc071 100644 --- a/crates/bevy_asset/src/debug_asset_server.rs +++ b/crates/bevy_asset/src/debug_asset_server.rs @@ -1,5 +1,6 @@ -use bevy_app::{App, Events, Plugin}; +use bevy_app::{App, Plugin}; use bevy_ecs::{ + event::Events, schedule::SystemLabel, system::{NonSendMut, Res, ResMut, SystemState}, }; diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 6e31a62ea6546..870f100d10306 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -81,13 +81,8 @@ pub fn create_platform_default_asset_io(app: &mut App) -> Box { impl Plugin for AssetPlugin { fn build(&self, app: &mut App) { - if app.world.get_resource::().is_none() { - let task_pool = app - .world - .get_resource::() - .expect("`IoTaskPool` resource not found.") - .0 - .clone(); + if !app.world.contains_resource::() { + let task_pool = app.world.resource::().0.clone(); let source = create_platform_default_asset_io(app); diff --git a/crates/bevy_audio/src/audio.rs b/crates/bevy_audio/src/audio.rs index 1a8ae32b88d9c..43841757051e4 100644 --- a/crates/bevy_audio/src/audio.rs +++ b/crates/bevy_audio/src/audio.rs @@ -1,5 +1,5 @@ -use crate::{AudioSource, Decodable}; -use bevy_asset::{Asset, Handle}; +use crate::{AudioSink, AudioSource, Decodable}; +use bevy_asset::{Asset, Handle, HandleId}; use parking_lot::RwLock; use std::{collections::VecDeque, fmt}; @@ -18,7 +18,7 @@ where Source: Asset + Decodable, { /// Queue for playing audio from asset handles - pub queue: RwLock>>, + pub(crate) queue: RwLock>>, } impl fmt::Debug for Audio @@ -55,7 +55,71 @@ where /// audio.play(asset_server.load("my_sound.ogg")); /// } /// ``` - pub fn play(&self, audio_source: Handle) { - self.queue.write().push_front(audio_source); + /// + /// Returns a weak [`Handle`] to the [`AudioSink`]. If this handle isn't changed to a + /// strong one, the sink will be detached and the sound will continue playing. Changing it + /// to a strong handle allows for control on the playback through the [`AudioSink`] asset. + /// + /// ``` + /// # use bevy_ecs::system::Res; + /// # use bevy_asset::{AssetServer, Assets}; + /// # use bevy_audio::{Audio, AudioSink}; + /// fn play_audio_system( + /// asset_server: Res, + /// audio: Res