diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e2a32b58a38b98fd5780129b6708040f25830a7..8336f4e7eda527b93f2f96bed40fa7c6b18f9769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,29 @@ # Changelog + 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). +## [0.9.2] + +### Fixed + +- Directional override animations were being skipped by the override animation filters +- Relational sync was being scheduled in the same set as animation ticks, potentially causing 1-frame desync based on + Bevy scheduling + +## [0.9.0] + +### Changed + +- Required Bevy version is now 0.14 + ## [0.8.0] ### Changed -- Required Bevy version is not 0.13 +- Required Bevy version is now 0.13 ## [0.7.0] @@ -23,10 +38,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed -- `AnimationQuery` has been removed; instead, the ergonomics of controlling animations by manipulating components -directly is much more ergonomic +- `AnimationQuery` has been removed; instead, the ergonomics of controlling animations by manipulating components + directly is much more ergonomic - Support for `bevy_ecs_tilemap` has been dropped -- +- ## [0.6.0] @@ -45,19 +60,23 @@ directly is much more ergonomic ## [0.3.1] ### Fixed + - Child animations would not play correct animation when parent has an override ## [0.2.1] ### Fixed + - Action animation frames overflow ## [0.2.0] ### Added + - Constructor functions for `AnimationOverride` ### Changed + - `bevy` version `0.9` - `bevy_ecs_tilemap` version `0.9` - `AnimationOverride` now contains its own state @@ -69,4 +88,5 @@ directly is much more ergonomic ## [0.1.1] ### Fixed + - "play once and then" animations could overflow frame array bounds \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 737343df35d57687d3d1de1cc86dc443cc8bc9cc..0873e26ea6a6067e1408c58ac54f5689c1b2699b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "micro_banimate" -version = "0.9.1" +version = "0.9.2" edition = "2021" license = "Apache-2.0" description = "Easily manage complex Bevy 2D sprite animations" authors = [ - "Louis Capitanchik <louis@microhacks.co.uk>" + "Louis Capitanchik <louis@microhacks.co.uk>" ] repository = "https://lab.lcr.gr/microhacks/micro-banimate" diff --git a/src/query.rs b/src/query.rs index 3898590359b774a0ddbc23a2f55ec51323a1e66b..aca0e35664f9027acaa421fd76f47af7a5c76b6a 100644 --- a/src/query.rs +++ b/src/query.rs @@ -37,6 +37,16 @@ pub struct OverrideAnimationComponents { atlas: &'static mut TextureAtlas, } +#[derive(QueryData)] +#[query_data(mutable)] +pub struct DirectionalOverrideAnimationComponents { + handle: &'static Handle<AnimationSet>, + direction: &'static Directionality, + data: Option<&'static OverrideData>, + status: &'static mut AnimationOverride, + atlas: &'static mut TextureAtlas, +} + #[derive(QueryData)] #[query_data(mutable)] pub struct SimpleAnimationComponents { @@ -193,6 +203,51 @@ pub fn play_override_animation( } } +pub fn play_directional_override_animation( + time: Res<Time>, + mut commands: Commands, + mut anim_query: Query< + (Entity, DirectionalOverrideAnimationComponents), + OnlyDirectionalOverrideAnimations, + >, + animations: Res<Assets<AnimationSet>>, + mut events: EventWriter<AnimationCompleted>, +) { + let delta = time.delta(); + for ( + entity, + DirectionalOverrideAnimationComponentsItem { + mut status, + direction, + handle, + mut atlas, + data, + }, + ) in &mut anim_query + { + let anim = get_current_anim!( + animations, + handle, + format!("{}_{}", status.active_name, direction), + status.active_name + ); + + let looped = tick_animation!(delta, anim, status, atlas); + if looped { + commands + .entity(entity) + .remove::<(AnimationOverride, OverrideData)>(); + + if let Some(data) = data { + events.send(AnimationCompleted { + entity, + user_data: **data, + }); + } + } + } +} + pub fn play_simple_animation( time: Res<Time>, mut anim_query: Query<SimpleAnimationComponents, Without<AnimationPaused>>, diff --git a/src/systems.rs b/src/systems.rs index f9fbe1bece82e1c89eb914da52db18e22eb41caa..a5cffa3534a545ad1ff3109a6dc6ed3dbb7ee8f8 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -1,6 +1,6 @@ use crate::query::{ - play_animations, play_directional_animations, play_override_animation, play_simple_animation, - sync_child_animation, + play_animations, play_directional_animations, play_directional_override_animation, + play_override_animation, play_simple_animation, sync_child_animation, }; use bevy::prelude::*; @@ -34,9 +34,10 @@ impl Plugin for AnimationSystemsPlugin { play_animations, play_override_animation, play_directional_animations, + play_directional_override_animation, play_simple_animation, ) - .in_set(AnimationSystems::SyncAnimations), + .in_set(AnimationSystems::TickAnimations), ) .add_systems( PostUpdate,