From 5e3ed1177e41c27b81dcc23ba1c6405ad7488c45 Mon Sep 17 00:00:00 2001 From: Jerome Humbert <djeedai@gmail.com> Date: Sat, 29 Jan 2022 12:44:37 +0000 Subject: [PATCH] Fix missing pub export on systems Export publicly the asset and component system to allow an app to manually add them. --- CHANGELOG | 6 ++++++ README.md | 6 +++--- src/lib.rs | 2 +- src/plugin.rs | 34 +++++++++++++++++++++++++++++++++- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c7cac56..828678e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,12 @@ 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] + +### Fixed + +- Fix missing public export of `component_animator_system()` and `asset_animator_system()` preventing the animation of all but the built-in items. + ## [0.3.0] - 2022-01-28 ### Added diff --git a/README.md b/README.md index 309cfa2..1af4077 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Tweening animation plugin for the Bevy game engine. ## Features -- [x] Versatile customizable lens system to animate any field of any component or asset. -- [x] Sequence of tweening animations chained together, running one after the other, to create complex animations. -- [x] Multiple tweening animations per component, running in parallel, to animate different fields with different parameters. +- [x] Animate any field of any component or asset, including custom ones. +- [x] Run multiple tweens (animations) per component/asset in parallel. +- [x] Chain multiple tweens (animations) one after the other for complex animations. ## Usage diff --git a/src/lib.rs b/src/lib.rs index 730b3d1..ae6c401 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,7 +119,7 @@ pub use lens::{ ColorMaterialColorLens, Lens, SpriteColorLens, TextColorLens, TransformPositionLens, TransformRotationLens, TransformScaleLens, UiPositionLens, }; -pub use plugin::TweeningPlugin; +pub use plugin::{asset_animator_system, component_animator_system, TweeningPlugin}; /// How should this easing loop repeat #[derive(Clone, Copy)] diff --git a/src/plugin.rs b/src/plugin.rs index 3204862..985af7f 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -2,7 +2,32 @@ use bevy::{asset::Asset, ecs::component::Component, prelude::*}; use crate::{Animator, AnimatorState, AssetAnimator}; -/// Plugin to add systems related to tweening +/// Plugin to add systems related to tweening of common components and assets. +/// +/// This plugin adds systems for a predefined set of components and assets, to allow their +/// respective animators to be updated each frame: +/// - [`Transform`] +/// - [`Text`] +/// - [`Style`] +/// - [`Sprite`] +/// - [`ColorMaterial`] +/// +/// This ensures that all predefined lenses work as intended, as well as any custom lens +/// animating the same component or asset type. +/// +/// For other components and assets, including custom ones, the relevant system needs to be +/// added manually by the application: +/// - For components, add [`component_animator_system::<T>`] where `T: Component` +/// - For assets, add [`asset_animator_system::<T>`] where `T: Asset` +/// +/// This plugin is entirely optional. If you want more control, you can instead add manually +/// the relevant systems for the exact set of components and assets actually animated. +/// +/// [`Transform`]: https://docs.rs/bevy/0.6.0/bevy/transform/components/struct.Transform.html +/// [`Text`]: https://docs.rs/bevy/0.6.0/bevy/text/struct.Text.html +/// [`Style`]: https://docs.rs/bevy/0.6.0/bevy/ui/struct.Style.html +/// [`Sprite`]: https://docs.rs/bevy/0.6.0/bevy/sprite/struct.Sprite.html +/// [`ColorMaterial`]: https://docs.rs/bevy/0.6.0/bevy/sprite/struct.ColorMaterial.html #[derive(Debug, Clone, Copy)] pub struct TweeningPlugin; @@ -16,6 +41,10 @@ impl Plugin for TweeningPlugin { } } +/// Animator system for components. +/// +/// This system extracts all components of type `T` with an `Animator<T>` attached to the same entity, +/// and tick the animator to animate the component. pub fn component_animator_system<T: Component>( time: Res<Time>, mut query: Query<(&mut T, &mut Animator<T>)>, @@ -31,6 +60,9 @@ pub fn component_animator_system<T: Component>( } } +/// Animator system for assets. +/// +/// This system ticks all `AssetAnimator<T>` components to animate their associated asset. pub fn asset_animator_system<T: Asset>( time: Res<Time>, mut assets: ResMut<Assets<T>>, -- GitLab