Hi,
I'd like to create a generic system for my dying animation component.
Something like
pub fn add_death_animation_helper<T: ReadOnlyWorldQuery>(
commands: &mut Commands,
dying_query: Query<Entity, (Added<Dying>, T)>,
animation_time_millis: f32,
) {
for entity in dying_query.iter() {
if let Some(mut entity) = commands.get_entity(entity) {
entity.insert(Animation { timer: Timer::new(
Duration::from_millis(animation_time_millis as u64),
TimerMode::Once
) });
}
}
}
My plan was then to use it like:
app.add_system(add_death_animation_helper<With<Player>>);
app.add_system(add_death_animation_helper<With<Food>>);
But as you can see there is an extra argument ( animation_time_millis) that is blocking me. Any ideas on how I could still use a generic system pattern?