diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d979841986d015830270815a9bc24dc005c7fe3..6fd89c71263964b89855d839ec8c449969d0c5fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.6.0-rc.1] + +### Changed + +- Required bevy version is now 0.11 +- Optional bevy_ecs_tilemap version is now git revision 55c15bfa43c7a9e2adef6b70007e92d699377454 + +## [0.5.0-beta.1] ### Changed diff --git a/Cargo.toml b/Cargo.toml index 3b76ff1c5e0baac16368a82410371c5c556143fd..ac4cbb8524ab2118b2c74b03f89bf320ae5940d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "micro_banimate" -version = "0.5.0-beta.2" +version = "0.6.0-rc.1" edition = "2021" license = "Apache-2.0" description = "Easily manage complex Bevy 2D sprite animations" @@ -21,7 +21,7 @@ ecs_tilemap = ["dep:bevy_ecs_tilemap"] anyhow = "^1.0.65" serde = { version = "^1.0.145", optional = true } serde_json = { version = "^1.0.85", optional = true } -toml = { version = "^0.5.9", optional = true } -bevy = { version = "^0.10.0", default-features = false, features = ["bevy_asset", "bevy_sprite"] } +toml = { version = "0.7.4", optional = true } +bevy = { version = "^0.11.0", default-features = false, features = ["bevy_asset", "bevy_sprite"] } -bevy_ecs_tilemap = { version = "0.10.0", optional = true } +bevy_ecs_tilemap = { git = "https://github.com/StarArawn/bevy_ecs_tilemap.git", rev = "55c15bfa43c7a9e2adef6b70007e92d699377454", optional = true } diff --git a/README.md b/README.md index d6881a558a14dec49221516ae55cd94c11441854..62fe981359d98b685f1b0d8ea603ff36eefce9a7 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,10 @@ frame_time = 100 ## Compatibility -| banimate version | bevy version | tilemap version | -|---------------------|--------------|-----------------| -| 0.5.x | 0.10 | 0.10 | -| 0.2.x, 0.3.x, 0.4.x | 0.9 | 0.9 | -| 0.1.x | 0.8 | 0.8 | +| banimate version | bevy version | tilemap version | +|---------------------|--------------|------------------------------------------| +| 0.6.0-rc.1 | 0.11 | 55c15bfa43c7a9e2adef6b70007e92d699377454 | +| 0.5.x | 0.10 | 0.10 | +| 0.5.x | 0.10 | 0.10 | +| 0.2.x, 0.3.x, 0.4.x | 0.9 | 0.9 | +| 0.1.x | 0.8 | 0.8 | diff --git a/rustfmt.toml b/rustfmt.toml index d62aed71624f22a7ec26ece40fb3e1db30dffa50..2b6f66e87d12dad0d933b81de57925300dd3a3fe 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,3 @@ hard_tabs = true -#group_imports = "StdExternalCrate" use_field_init_shorthand = true use_try_shorthand = true \ No newline at end of file diff --git a/src/definitions.rs b/src/definitions.rs index 54bba6ad7487a1d6129e24d8499c328bbcec3e79..42b8a95ecd235bf27b4d96b32b966644557771df 100644 --- a/src/definitions.rs +++ b/src/definitions.rs @@ -1,13 +1,12 @@ use std::collections::HashMap; use std::ops::{Deref, DerefMut}; -use bevy::asset::Handle; -use bevy::prelude::{Bundle, Component}; +use bevy::prelude::*; use bevy::reflect::TypeUuid; use crate::directionality::Directionality; -#[derive(Clone, PartialOrd, PartialEq, Debug, Default)] +#[derive(Clone, PartialOrd, PartialEq, Debug, Default, Reflect)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AnimationFrames { pub frames: Vec<usize>, @@ -20,7 +19,7 @@ impl AnimationFrames { } } -#[derive(Clone, Debug, TypeUuid, PartialEq, Default)] +#[derive(Clone, Debug, TypeUuid, PartialEq, Default, Reflect)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[uuid = "a2823f96-0f63-434e-9030-d8f762898a18"] pub struct AnimationSet(pub HashMap<String, AnimationFrames>); diff --git a/src/loader.rs b/src/loader.rs index b2cd52b32222b11292994022b4ffcc5f56c3a8e1..52164642a1d9a63acb695b241c40b90033d8a6a6 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -39,7 +39,8 @@ mod toml { load_context: &'a mut LoadContext, ) -> BoxedFuture<'a, anyhow::Result<(), Error>> { Box::pin(async move { - let value: AnimationSet = toml::from_slice(bytes)?; + let contents = String::from_utf8(bytes.to_vec())?; + let value: AnimationSet = toml::from_str(contents.as_str())?; load_context.set_default_asset(LoadedAsset::new(value)); Ok(()) }) diff --git a/src/query.rs b/src/query.rs index dbfd5d39d9c7ab691f8cf09299ba8cfab8187b6f..af6fdf7fa0112a92487cf20b40e568b78338d049 100644 --- a/src/query.rs +++ b/src/query.rs @@ -13,26 +13,31 @@ use crate::definitions::{ use crate::directionality::{Directionality, Horizontal, Vertical}; use crate::systems::AnimationCompleted; +#[allow(clippy::type_complexity)] +pub type AnimationQueryType<'w, 's> = Query< + 'w, + 's, + ( + Entity, + &'static Handle<AnimationSet>, + &'static mut AnimationMode, + &'static mut AnimationStatus, + ), + ( + Or<(With<HasAnimations>, With<HasDirectionalityAnimation>)>, + Without<HasSimpleAnimations>, + Without<SyncAnimationsToParent>, + ), +>; + /// Manage animated entities #[derive(SystemParam)] pub struct AnimationQuery<'w, 's> { commands: Commands<'w, 's>, animations: Res<'w, Assets<AnimationSet>>, - inner: Query< - 'w, - 's, - ( - Entity, - &'static Handle<AnimationSet>, - &'static mut AnimationMode, - &'static mut AnimationStatus, - ), - ( - Or<(With<HasAnimations>, With<HasDirectionalityAnimation>)>, - Without<HasSimpleAnimations>, - Without<SyncAnimationsToParent>, - ), - >, + #[allow(clippy::type_complexity)] + inner: AnimationQueryType<'w, 's>, + #[allow(clippy::type_complexity)] inner_child: Query< 'w, 's, @@ -57,22 +62,7 @@ pub struct AnimationQuery<'w, 's> { } impl<'w, 's> Deref for AnimationQuery<'w, 's> { - type Target = Query< - 'w, - 's, - ( - Entity, - &'static Handle<AnimationSet>, - &'static mut AnimationMode, - &'static mut AnimationStatus, - ), - ( - Or<(With<HasAnimations>, With<HasDirectionalityAnimation>)>, - Without<HasSimpleAnimations>, - Without<SyncAnimationsToParent>, - ), - >; - + type Target = AnimationQueryType<'w, 's>; fn deref(&self) -> &Self::Target { &self.inner } diff --git a/src/systems.rs b/src/systems.rs index dc361896277af277bc7914466de34d0c85082fea..58aef2cc6079233ac5fa8e6daaf65a05f8281c74 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -4,13 +4,12 @@ use crate::definitions::*; use crate::query::AnimationQuery; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)] -#[system_set(base)] pub enum AnimationSystems { TickAnimations, SyncAnimations, } -#[derive(Copy, Clone, Debug, Component, PartialEq, Eq, Ord, PartialOrd)] +#[derive(Copy, Clone, Debug, Component, PartialEq, Eq, Ord, PartialOrd, Event)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AnimationCompleted { pub entity: Entity, @@ -84,23 +83,27 @@ pub struct AnimationSystemsPlugin; impl Plugin for AnimationSystemsPlugin { fn build(&self, app: &mut App) { - app.configure_sets(( - AnimationSystems::TickAnimations, - AnimationSystems::SyncAnimations, - CoreSet::PostUpdate, - )); + app.configure_sets( + PostUpdate, + (AnimationSystems::TickAnimations.before(AnimationSystems::SyncAnimations),), + ); app.add_event::<AnimationCompleted>() .add_systems( + PostUpdate, (tick_animations, tick_simple_sprite_animations) - .in_base_set(AnimationSystems::TickAnimations), + .in_set(AnimationSystems::SyncAnimations), ) - .add_system(sync_parent_animations.in_base_set(AnimationSystems::SyncAnimations)); + .add_systems( + PostUpdate, + sync_parent_animations.in_set(AnimationSystems::SyncAnimations), + ); #[cfg(feature = "ecs_tilemap")] { - app.add_system( - tick_simple_tilemap_animation.in_base_set(AnimationSystems::TickAnimations), + app.add_systems( + PostUpdate, + tick_simple_tilemap_animation.in_set(AnimationSystems::TickAnimations), ); } }