From 4cddfd9afc8eec4e86974c1074908e0fc86ddf79 Mon Sep 17 00:00:00 2001 From: eickern Date: Wed, 15 Feb 2023 21:13:18 +0100 Subject: [PATCH 01/11] Remove loopless integration and stageless features Update States enums --- .github/workflows/ci.yml | 32 +- CHANGELOG.md | 2 + README.md | 52 +- bevy_asset_loader/Cargo.toml | 55 +- bevy_asset_loader/examples/README.md | 16 - bevy_asset_loader/examples/atlas_from_grid.rs | 5 +- .../examples/custom_dynamic_assets.rs | 5 +- bevy_asset_loader/examples/dynamic_asset.rs | 5 +- bevy_asset_loader/examples/failure_state.rs | 5 +- bevy_asset_loader/examples/full_collection.rs | 5 +- .../examples/full_dynamic_collection.rs | 5 +- bevy_asset_loader/examples/init_resource.rs | 5 +- .../examples/manual_dynamic_asset.rs | 5 +- .../examples/progress_tracking.rs | 2 +- bevy_asset_loader/examples/stageless.rs | 95 ---- .../examples/stageless_dynamic_asset.rs | 95 ---- .../examples/stageless_failure_state.rs | 54 -- .../examples/stageless_full_collection.rs | 143 ----- .../stageless_full_dynamic_collection.rs | 154 ------ .../stageless_manual_dynamic_asset.rs | 269 ---------- .../examples/stageless_progress.rs | 133 ----- .../examples/standard_material.rs | 5 +- bevy_asset_loader/examples/two_collections.rs | 5 +- bevy_asset_loader/src/lib.rs | 30 +- bevy_asset_loader/src/loading_state.rs | 499 +----------------- .../stageless/dynamic_asset_systems.rs | 105 ---- .../src/loading_state/stageless/mod.rs | 2 - .../src/loading_state/stageless/systems.rs | 190 ------- .../tests/can_run_without_next_state.rs | 8 +- .../tests/continues_to_failure_state.rs | 8 +- .../tests/continues_without_collection.rs | 8 +- bevy_asset_loader/tests/init_resource.rs | 8 +- .../tests/multiple_asset_collections.rs | 8 +- .../tests/multiple_loading_states.rs | 8 +- bevy_asset_loader/tests/stageless.rs | 14 - .../stageless/can_run_without_next_state.rs | 71 --- .../stageless/continues_to_failure_state.rs | 51 -- .../stageless/continues_without_collection.rs | 50 -- .../tests/stageless/init_resource.rs | 74 --- .../stageless/multiple_asset_collections.rs | 61 --- .../stageless/multiple_loading_states.rs | 88 --- 41 files changed, 92 insertions(+), 2343 deletions(-) delete mode 100644 bevy_asset_loader/examples/stageless.rs delete mode 100644 bevy_asset_loader/examples/stageless_dynamic_asset.rs delete mode 100644 bevy_asset_loader/examples/stageless_failure_state.rs delete mode 100644 bevy_asset_loader/examples/stageless_full_collection.rs delete mode 100644 bevy_asset_loader/examples/stageless_full_dynamic_collection.rs delete mode 100644 bevy_asset_loader/examples/stageless_manual_dynamic_asset.rs delete mode 100644 bevy_asset_loader/examples/stageless_progress.rs delete mode 100644 bevy_asset_loader/src/loading_state/stageless/dynamic_asset_systems.rs delete mode 100644 bevy_asset_loader/src/loading_state/stageless/mod.rs delete mode 100644 bevy_asset_loader/src/loading_state/stageless/systems.rs delete mode 100644 bevy_asset_loader/tests/stageless.rs delete mode 100644 bevy_asset_loader/tests/stageless/can_run_without_next_state.rs delete mode 100644 bevy_asset_loader/tests/stageless/continues_to_failure_state.rs delete mode 100644 bevy_asset_loader/tests/stageless/continues_without_collection.rs delete mode 100644 bevy_asset_loader/tests/stageless/init_resource.rs delete mode 100644 bevy_asset_loader/tests/stageless/multiple_asset_collections.rs delete mode 100644 bevy_asset_loader/tests/stageless/multiple_loading_states.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e0900a..b01765f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,37 +32,9 @@ jobs: run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev if: runner.os == 'linux' - name: Build & run tests for feature combinations - run: cargo hack test --keep-going --feature-powerset --group-features "2d","3d","standard_dynamic_assets" --exclude-features "progress_tracking","stageless","progress_tracking_stageless" -p bevy_asset_loader + run: cargo hack test --keep-going --feature-powerset --group-features "2d","3d","standard_dynamic_assets" --exclude-features "progress_tracking" -p bevy_asset_loader - name: Build & run tests for derive package run: cargo hack test --keep-going --feature-powerset --group-features "2d","3d" -p bevy_asset_loader_derive - stageless-tests: - strategy: - matrix: - os: [windows-latest, ubuntu-latest, macos-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-build-stable-stageless-${{ hashFiles('**/Cargo.toml') }} - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - uses: taiki-e/install-action@v1 - with: - tool: cargo-hack - - name: Install alsa and udev - run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - if: runner.os == 'linux' - - name: Build & run tests for feature combinations - run: cargo hack test --keep-going --feature-powerset --group-features "2d","3d","standard_dynamic_assets" --features "stageless","progress_tracking","progress_tracking_stageless" -p bevy_asset_loader progress-tracking-test: strategy: matrix: @@ -90,7 +62,7 @@ jobs: run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev if: runner.os == 'linux' - name: Build & run tests for feature combinations - run: cargo hack test --keep-going --feature-powerset --group-features "2d","3d","standard_dynamic_assets" --exclude-features "stageless","progress_tracking_stageless" --features "progress_tracking" -p bevy_asset_loader + run: cargo hack test --keep-going --feature-powerset --group-features "2d","3d","standard_dynamic_assets" --features "progress_tracking" -p bevy_asset_loader lint: runs-on: ubuntu-latest steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 22379d0..33e70c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ - Option to load folders as maps of path to handle (resolves [#32](https://github.com/NiklasEi/bevy_asset_loader/issues/32)) - Changed the default file ending for standard dynamic asset files from `.assets` to `.assets.ron` - Fix: multiple calls of `with_dynamic_collections` (resolves [#99](https://github.com/NiklasEi/bevy_asset_loader/issues/99)) +- Update to Bevy `0.10` + - Removed features `stageless` and `progress_tracking_stageless` ## v0.14.1 - Make sure that the `RonAssetPlugin` for `StandardDynamicAssetCollection` is only added once diff --git a/README.md b/README.md index 10bf0a6..59596df 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ This [Bevy][bevy] plugin reduces boilerplate for handling game assets. The crate In most cases you will want to load your asset collections during loading states (think loading screens). During such a state, all assets are loaded and their loading process is observed. Only when asset collections can be build with fully loaded asset handles, the collections are inserted as resources. If you do not want to use a loading state, asset collections can still result in cleaner code and improved maintainability (see the ["usage without a loading state"](#usage-without-a-loading-state) section). -_`bevy_asset_loader` supports `iyes_loopless` states with the [`stageless`](#stageless-support) feature._ - _The `main` branch and the latest release support Bevy version `0.9` (see [version table](#compatible-bevy-versions))_ ## Loading states @@ -47,7 +45,7 @@ fn main() { .continue_to_state(GameState::Next) .with_collection::() ) - .add_state(GameState::AssetLoading) + .add_state::() .add_plugins(DefaultPlugins) .add_system_set(SystemSet::on_enter(GameState::Next).with_system(use_my_assets)) .run(); @@ -65,8 +63,9 @@ fn use_my_assets(_my_assets: Res) { // do something using the asset handles from the resource } -#[derive(Clone, Eq, PartialEq, Debug, Hash)] +#[derive(Clone, Eq, PartialEq, Debug, Hash, Default, States)] enum GameState { + #[default] AssetLoading, Next, } @@ -364,8 +363,6 @@ With the feature `progress_tracking`, you can integrate with [`iyes_progress`][i See [`progress_tracking`](/bevy_asset_loader/examples/progress_tracking.rs) for a complete example. -When using `stageless` feature, you need to add `progress_tracking_stageless` feature in addition to `progress_tracking`. - ### A note on system ordering The loading state runs in a single exclusive system `at_start`. This means that any parallel system in the loading state will always run after all asset handles have been checked for their status. You can thus read the current progress in each frame in a parallel system without worrying about frame lag. @@ -401,49 +398,6 @@ struct MyAssets { } ``` -## Stageless support - -`bevy_asset_loader` can integrate with `iyes_loopless`, which implements ideas from Bevy's [Stageless RFC](https://github.com/bevyengine/rfcs/pull/45). The integration can be enabled with the `stageless` feature. - -Currently, you must initialize the `iyes_loopless` state before you initialize your `AssetLoader`. This is a limitation due to the way `iyes_loopless` works. The following is a minimal example of integrating `bevy_asset_loader` with `iyes_loopless`: - -```rust no_run -use bevy::prelude::*; -use bevy_asset_loader::prelude::*; -use iyes_loopless::prelude::*; - -fn main() { - App::new() - .add_loopless_state(MyStates::AssetLoading) - .add_loading_state( - LoadingState::new(MyStates::AssetLoading) - .continue_to_state(MyStates::Next) - .with_collection::() - ) - .add_plugins(DefaultPlugins) - .add_enter_system(MyStates::Next, use_my_assets) - .run(); -} - -#[derive(AssetCollection, Resource)] -struct AudioAssets { - #[asset(path = "audio/background.ogg")] - background: Handle, -} - -fn use_my_assets(_audio_assets: Res) { - // do something using the asset handles from the resources -} - -#[derive(Clone, Eq, PartialEq, Debug, Hash)] -enum MyStates { - AssetLoading, - Next, -} -``` - -When using stageless with the `progress_tracking` feature, remember to also enable the `progress_tracking_stageless` feature. See [the stageless examples](/bevy_asset_loader/examples/README.md#examples-for-stageless) for different use cases with `iyes_loopless` integration. - ## Compatible Bevy versions The main branch is compatible with the latest Bevy release, while the branch `bevy_main` tries to track the `main` branch of Bevy (PRs updating the tracked commit are welcome). diff --git a/bevy_asset_loader/Cargo.toml b/bevy_asset_loader/Cargo.toml index f66a383..e082eb3 100644 --- a/bevy_asset_loader/Cargo.toml +++ b/bevy_asset_loader/Cargo.toml @@ -18,25 +18,21 @@ readme = "README.md" 3d = ["bevy/bevy_pbr", "bevy/bevy_render", "bevy_asset_loader_derive/3d"] standard_dynamic_assets = ["bevy_common_assets", "serde"] progress_tracking = ["iyes_progress"] -progress_tracking_stageless = ["iyes_progress/iyes_loopless"] -stageless = ["iyes_loopless"] [dependencies] -bevy = { version = "0.9", default-features = false, features = ["bevy_asset"] } +bevy = { git = "https://github.com/bevyengine/bevy", default-features = false, features = ["bevy_asset"] } bevy_asset_loader_derive = { version = "=0.14.0", path = "../bevy_asset_loader_derive" } anyhow = "1" -bevy_common_assets = { version = "0.4", features = ["ron"], optional = true } +bevy_common_assets = { git = "https://github.com/NiklasEi/bevy_common_assets", ref = "bevy_main", features = ["ron"], optional = true } serde = { version = "1", optional = true } -iyes_progress = { version = "0.7", optional = true } -iyes_loopless = { version = "0.9", optional = true } +iyes_progress = { git = "https://github.com/NiklasEi/iyes_progress", ref = "bevy_main", optional = true } [dev-dependencies] -bevy = { version = "0.9", features = ["vorbis"] } +bevy = { git = "https://github.com/bevyengine/bevy", features = ["vorbis"] } anyhow = "1" -iyes_progress = { version = "0.7" } -iyes_loopless = { version = "0.9" } -bevy_common_assets = { version = "0.4", features = ["ron"] } +iyes_progress = { git = "https://github.com/NiklasEi/iyes_progress", ref = "bevy_main" } +bevy_common_assets = { git = "https://github.com/NiklasEi/bevy_common_assets", ref = "bevy_main", features = ["ron"] } serde = { version = "1" } trybuild = { version = "1.0" } @@ -85,45 +81,6 @@ required-features = ["progress_tracking", "2d"] name = "failure_state" path = "examples/failure_state.rs" -[[example]] -name = "stageless" -path = "examples/stageless.rs" -required-features = ["stageless"] - -[[example]] -name = "stageless_full_collection" -path = "examples/stageless_full_collection.rs" -required-features = ["stageless", "2d", "3d"] - -[[example]] -name = "stageless_full_dynamic_collection" -path = "examples/stageless_full_dynamic_collection.rs" -required-features = ["stageless", "2d", "3d", "standard_dynamic_assets"] - -[[example]] -name = "stageless_manual_dynamic_asset" -path = "examples/stageless_manual_dynamic_asset.rs" -required-features = ["stageless", "standard_dynamic_assets"] - -[[example]] -name = "stageless_progress" -path = "examples/stageless_progress.rs" -required-features = [ - "progress_tracking_stageless", - "stageless", - "progress_tracking", "2d" -] - -[[example]] -name = "stageless_failure_state" -path = "examples/stageless_failure_state.rs" -required-features = ["stageless"] - -[[example]] -name = "stageless_dynamic_asset" -path = "examples/stageless_dynamic_asset.rs" -required-features = ["2d", "standard_dynamic_assets", "stageless"] - [[example]] name = "full_collection" path = "examples/full_collection.rs" diff --git a/bevy_asset_loader/examples/README.md b/bevy_asset_loader/examples/README.md index aac8231..f121b59 100644 --- a/bevy_asset_loader/examples/README.md +++ b/bevy_asset_loader/examples/README.md @@ -18,22 +18,6 @@ with `cargo run --example `. | [`progress_tracking.rs`](progress_tracking.rs) | How to set up progress tracking using `iyes_progress` | | [`failure_state.rs`](failure_state.rs) | Sets up a failure state | -## Examples for stageless - -The following examples use `iyes_loopless`, which implements ideas from -Bevy's [Stageless RFC](https://github.com/bevyengine/rfcs/pull/45). All examples require the `stageless` feature. -Note that progress tracking needs `progress_tracking_stageless` feature together with `progress_tracking`. - -| Example | Description | -|--------------------------------------------------------------------------------|--------------------------------------------------------------------------| -| [`stageless.rs`](stageless.rs) | Basic example | -| [`stageless_manual_dynamic_asset.rs`](stageless_manual_dynamic_asset.rs) | Load an image asset from a path resolved runtime | -| [`stageless_full_collection.rs`](stageless_full_collection.rs) | A complete asset collection with all supported non-dynamic field types | -| [`stageless_full_dynamic_collection.rs`](stageless_full_dynamic_collection.rs) | A complete asset collection with all supported dynamic asset field types | -| [`stageless_progress.rs`](stageless_progress.rs) | Stageless with progress tracking | -| [`stageless_dynamic_asset.rs`](stageless_dynamic_asset.rs) | Stageless with ron loading | -| [`stageless_failure_state.rs`](stageless_failure_state.rs) | Sets up a failure state | - ## Credits The examples include third party assets: diff --git a/bevy_asset_loader/examples/atlas_from_grid.rs b/bevy_asset_loader/examples/atlas_from_grid.rs index c6f2af8..3013e53 100644 --- a/bevy_asset_loader/examples/atlas_from_grid.rs +++ b/bevy_asset_loader/examples/atlas_from_grid.rs @@ -11,7 +11,7 @@ fn main() { .continue_to_state(MyStates::Next) .with_collection::(), ) - .add_state(MyStates::AssetLoading) + .add_state::() .insert_resource(Msaa { samples: 1 }) .add_plugins(DefaultPlugins) .add_system_set(SystemSet::on_enter(MyStates::Next).with_system(draw_atlas)) @@ -75,8 +75,9 @@ fn animate_sprite_system( } } -#[derive(Clone, Eq, PartialEq, Debug, Hash)] +#[derive(Clone, Eq, PartialEq, Debug, Hash, Default, States)] enum MyStates { + #[default] AssetLoading, Next, } diff --git a/bevy_asset_loader/examples/custom_dynamic_assets.rs b/bevy_asset_loader/examples/custom_dynamic_assets.rs index 3eece7e..28d5a84 100644 --- a/bevy_asset_loader/examples/custom_dynamic_assets.rs +++ b/bevy_asset_loader/examples/custom_dynamic_assets.rs @@ -20,7 +20,7 @@ fn main() { ]) .with_collection::(), ) - .add_state(MyStates::AssetLoading) + .add_state::() .add_system_set(SystemSet::on_enter(MyStates::Next).with_system(render_stuff)) .run(); } @@ -204,8 +204,9 @@ impl DynamicAssetCollection for CustomDynamicAssetCollection { } } -#[derive(Clone, Eq, PartialEq, Debug, Hash)] +#[derive(Clone, Eq, PartialEq, Debug, Hash, Default, States)] enum MyStates { + #[default] AssetLoading, Next, } diff --git a/bevy_asset_loader/examples/dynamic_asset.rs b/bevy_asset_loader/examples/dynamic_asset.rs index f3a41f4..041673e 100644 --- a/bevy_asset_loader/examples/dynamic_asset.rs +++ b/bevy_asset_loader/examples/dynamic_asset.rs @@ -16,7 +16,7 @@ fn main() { .with_collection::() .with_collection::(), ) - .add_state(MyStates::AssetLoading) + .add_state::() .insert_resource(Msaa { samples: 1 }) .add_system_set( SystemSet::on_enter(MyStates::Next) @@ -72,8 +72,9 @@ fn play_background_audio(audio_assets: Res, audio: Res