use crate::ecs::world::{World, events::Message};

pub fn process_events_system(
    world: &mut World,
    mut handle_event: impl FnMut(&mut World, &Message),
) {
    let event_count = world.resources.event_bus.messages.len();
    let _span = tracing::info_span!("events", count = event_count).entered();
    while let Some(message) = world.resources.event_bus.messages.pop_front() {
        handle_event(world, &message);
    }
}
