#How to use World, Commands, and Query in the same system

2 messages · Page 1 of 1 (latest)

quick shard
#

It seems like this should work

fn check_timers(world: &mut World) {
    let mut query = world
        .query::<(Entity, &Timed<dyn FnOnce(&mut World) + Sync + Send + 'static>)>();

    for (entity, timed) in query.iter(world) {
        if timed.timer.finished() {
            timed.on_completion.call_once((world,));
            world.despawn(entity);
        }
    }
}

However not sure how to replicate

commands.entity(entity).despawn_recursive();
``` (the recursive aspect) using World