Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare release for Bevy 0.14rc2 #43

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "leafwing_manifest"
version = "0.1.0"
version = "0.2.0-rc.2"
authors = ["Leafwing Studios"]
homepage = "https://leafwing-studios.com/"
repository = "https://github.com/leafwing-studios/leafwing_manifest"
Expand All @@ -15,8 +15,11 @@ exclude = ["assets/**/*", "tools/**/*", ".github/**/*"]
members = ["./", "tools/ci"]

[dependencies]
bevy = { version = "0.13", default-features = false, features = ["bevy_asset"] }
bevy_common_assets = { version = "0.10.0", default-features = false }
bevy = { version = "0.14.0-rc.2", default-features = false, features = [
"bevy_asset",
"bevy_state",
] }
bevy_common_assets = { version = "0.11.0-rc.2.1", default-features = false }
serde = "1.0.195"
thiserror = "1.0.58"

Expand Down Expand Up @@ -59,7 +62,7 @@ ron = "0.8"
# Enables non-default features for examples and tests.
leafwing_manifest = { path = ".", features = ["ron"] }
# Give us access to the full Bevy default features for examples.
bevy = { version = "0.13" }
bevy = { version = "0.14.0-rc.2" }

[workspace.lints.rust]
unsafe_code = "forbid"
Expand Down
5 changes: 5 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 0.2

- Updated to Bevy 0.14
- now requires the `state` feature of Bevy, as states were moved out of `bevy_ecs`
- `AssetLoadingState` now requires `FreelyMutableState` instead of just `States`
9 changes: 4 additions & 5 deletions examples/custom_asset_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ fn manage_manifests(
// We're still waiting for the asset to load
LoadState::NotLoaded | LoadState::Loading => (),
// Something went wrong: panic!
LoadState::Failed => {
panic!("Failed to load manifest");
LoadState::Failed(err) => {
panic!("Failed to load manifest: {}", err);
}
}
}
Expand All @@ -208,9 +208,8 @@ fn manage_manifests(

// We're deferring the actual work with commands to avoid blocking the whole world
// every time this system runs.
commands.add(|mut world: &mut World| {
let item_manifest =
ItemManifest::from_raw_manifest(raw_manifest, &mut world).unwrap();
commands.add(|world: &mut World| {
let item_manifest = ItemManifest::from_raw_manifest(raw_manifest, world).unwrap();

world.insert_resource(item_manifest);
});
Expand Down
2 changes: 1 addition & 1 deletion examples/entities_from_manifests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Manifest for TileManifest {
// driven by hand-tuned parameters in the manifest.
// In a real game, you might use a more complex system to generate the assets,
// but the general pattern is very effective for creating cohesive but varied content.
let color_material = color_materials.add(Color::rgb_from_array(raw_tile.color));
let color_material = color_materials.add(Color::srgb_from_array(raw_tile.color));

manifest.tiles.insert(
Id::from_name(&raw_tile.name),
Expand Down
4 changes: 2 additions & 2 deletions src/asset_state.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use bevy::ecs::schedule::States;
use bevy::{prelude::States, state::state::FreelyMutableState};

/// A trait that translates your custom [`States`] enum into the states required for asset loading.
///
/// Note that you are not required to use this trait.
/// Instead, you can add or emulate the required systems from [`ManifestPlugin`](crate::plugin::ManifestPlugin) manually to match your app logic.
pub trait AssetLoadingState: States {
pub trait AssetLoadingState: FreelyMutableState {
/// Assets are currently being loaded.
const LOADING: Self;
/// Assets have been loaded successfully,
Expand Down
13 changes: 8 additions & 5 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use bevy::asset::{AssetApp, AssetLoadFailedEvent, AssetServer, Assets, LoadState
use bevy::ecs::prelude::*;
use bevy::ecs::system::SystemState;
use bevy::log::{error, error_once, info};
use bevy::state::app::AppExtStates;
use bevy::state::condition::in_state;
use bevy::state::state::NextState;
use bevy::utils::HashMap;

use crate::asset_state::AssetLoadingState;
Expand Down Expand Up @@ -155,7 +158,7 @@ impl RegisterManifest for App {
crate::manifest::ManifestFormat::Custom => (), // Users must register their own asset loader for custom formats.
}

self.world
self.world_mut()
.resource_scope(|world, mut asset_server: Mut<AssetServer>| {
let mut manifest_tracker = world.resource_mut::<RawManifestTracker>();
manifest_tracker.register::<M>(path, asset_server.as_mut());
Expand Down Expand Up @@ -233,8 +236,8 @@ impl RawManifestTracker {
pub fn update_load_states(&mut self, asset_server: &AssetServer) {
for status in self.raw_manifests.values_mut() {
status.load_state = asset_server
.get_load_state(status.handle.clone_weak())
.unwrap_or(LoadState::Failed);
.get_load_state(&status.handle)
.expect("Handle did not correspond to an asset queued for loading.");
}
}

Expand All @@ -253,7 +256,7 @@ impl RawManifestTracker {

self.raw_manifests
.values()
.any(|status| status.load_state == LoadState::Failed)
.any(|status| matches!(status.load_state, LoadState::Failed(..)))
}

/// Returns the [`ProcessingStatus`] of the raw manifests.
Expand Down Expand Up @@ -336,7 +339,7 @@ pub fn process_manifest<M: Manifest>(
return;
};
let typed_handle = status.handle.clone_weak().typed::<M::RawManifest>();
let maybe_raw_manifest = assets.remove(typed_handle);
let maybe_raw_manifest = assets.remove(&typed_handle);

let raw_manifest = match maybe_raw_manifest {
Some(raw_manifest) => raw_manifest,
Expand Down