From 64f7460e325e0b58435176edb78a14bfd3781297 Mon Sep 17 00:00:00 2001
From: Alex Saveau <saveau.alexandre@gmail.com>
Date: Tue, 17 May 2022 13:26:14 -0700
Subject: [PATCH] Add animation system label (#23)

This lets you not have to run after every single system and instead just pass in the label.
---
 CHANGELOG.md  |  1 +
 src/lib.rs    |  4 +++-
 src/plugin.rs | 22 ++++++++++++++++------
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3604dc7..a421d5d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Add `is_forward()` and `is_backward()` convenience helpers to `TweeningDirection`.
 - Add `Tween::set_direction()` and `Tween::with_direction()` which allow configuring the playback direction of a tween, allowing to play it backward from end to start.
 - Support dynamically changing an animation's speed with `Animator::set_speed`
+- Add `AnimationSystem` label to tweening tick systems
 
 ## [0.4.0] - 2022-04-16
 
diff --git a/src/lib.rs b/src/lib.rs
index 587e67b..51f0f86 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -158,7 +158,9 @@ mod plugin;
 mod tweenable;
 
 pub use lens::Lens;
-pub use plugin::{asset_animator_system, component_animator_system, TweeningPlugin};
+pub use plugin::{
+    asset_animator_system, component_animator_system, AnimationSystem, TweeningPlugin,
+};
 pub use tweenable::{Delay, Sequence, Tracks, Tween, TweenCompleted, TweenState, Tweenable};
 
 /// Type of looping for a tween animation.
diff --git a/src/plugin.rs b/src/plugin.rs
index ff98803..10f0c07 100644
--- a/src/plugin.rs
+++ b/src/plugin.rs
@@ -33,19 +33,29 @@ pub struct TweeningPlugin;
 
 impl Plugin for TweeningPlugin {
     fn build(&self, app: &mut App) {
-        app.add_event::<TweenCompleted>()
-            .add_system(component_animator_system::<Transform>);
+        app.add_event::<TweenCompleted>().add_system(
+            component_animator_system::<Transform>.label(AnimationSystem::AnimationUpdate),
+        );
 
         #[cfg(feature = "bevy_ui")]
-        app.add_system(component_animator_system::<Text>)
-            .add_system(component_animator_system::<Style>);
+        app.add_system(component_animator_system::<Text>.label(AnimationSystem::AnimationUpdate))
+            .add_system(component_animator_system::<Style>.label(AnimationSystem::AnimationUpdate));
 
         #[cfg(feature = "bevy_sprite")]
-        app.add_system(component_animator_system::<Sprite>)
-            .add_system(asset_animator_system::<ColorMaterial>);
+        app.add_system(component_animator_system::<Sprite>.label(AnimationSystem::AnimationUpdate))
+            .add_system(
+                asset_animator_system::<ColorMaterial>.label(AnimationSystem::AnimationUpdate),
+            );
     }
 }
 
+/// Label enum for the systems relating to animations
+#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, SystemLabel)]
+pub enum AnimationSystem {
+    /// Ticks animations
+    AnimationUpdate,
+}
+
 /// Animator system for components.
 ///
 /// This system extracts all components of type `T` with an `Animator<T>` attached to the same entity,
-- 
GitLab