planck_game_features/systems/remove_outdated_effector.rs
1use crate::*;
2
3/// Removes effectors where their time to live is expired.
4/// Note: Run after ApplyEffectorsSystem.
5pub fn remove_outdated_effector_system<E>(
6 time: &Time,
7 effectors: &mut Components<EffectorSet<E>>,
8) -> SystemResult {
9 for eff in effectors.iter_mut() {
10 eff.effectors.retain(|e| {
11 if let Some(mut d) = e.disable_in {
12 d -= time.delta_time().as_secs_f64();
13 d > 0.0
14 } else {
15 true
16 }
17 });
18 }
19 Ok(())
20}