diff --git a/common/src/comp/animation.rs b/common/src/comp/animation.rs index d3e89dc18c..e59a506148 100644 --- a/common/src/comp/animation.rs +++ b/common/src/comp/animation.rs @@ -16,7 +16,6 @@ pub enum Animation { pub struct AnimationInfo { pub animation: Animation, pub time: f64, - pub changed: bool, } impl Default for AnimationInfo { @@ -24,7 +23,6 @@ impl Default for AnimationInfo { Self { animation: Animation::Idle, time: 0.0, - changed: true, } } } diff --git a/common/src/sys/animation.rs b/common/src/sys/animation.rs index 7af4953117..6b251a0311 100644 --- a/common/src/sys/animation.rs +++ b/common/src/sys/animation.rs @@ -25,15 +25,12 @@ impl<'a> System<'a> for Sys { mut animation_infos, ): Self::SystemData, ) { - for (entity, a, mut animation_info) in ( + for (entity, a) in ( &entities, &action_states, - &mut animation_infos, ) .join() { - animation_info.time += dt.0 as f64; - fn impossible_animation(message: &str) -> Animation { warn!("{}", message); Animation::Idle @@ -58,14 +55,12 @@ impl<'a> System<'a> for Sys { (_, _, true, false, false) => Animation::Attack, }; - let last = animation_info.clone(); - let changed = last.animation != animation; + let new_time = animation_infos.get(entity).filter(|i| i.animation == animation).map(|i| i.time + dt.0 as f64); - *animation_info = AnimationInfo { + animation_infos.insert(entity, AnimationInfo { animation, - time: if changed { 0.0 } else { last.time }, - changed, - }; + time: new_time.unwrap_or(0.0), + }); } } }