Skip to content
Snippets Groups Projects
Commit 5e3ed117 authored by Jerome Humbert's avatar Jerome Humbert
Browse files

Fix missing pub export on systems

Export publicly the asset and component system to allow an app to
manually add them.
parent 2d7285c9
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
......@@ -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)]
......
......@@ -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>>,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment