use specs::{Dispatcher as Inner, DispatcherBuilder, World, WorldExt}; use crate::{ components::Player, resources::Global, systems::{FleetOwnedUpdate, Movement, OrbitOwnedUpdate, Process, Ships}, }; pub struct Dispatcher<'a, 'b> { dispatcher: Inner<'a, 'b>, } impl<'a, 'b> Dispatcher<'a, 'b> { pub fn new(world: &mut World) -> Self { world.insert(Global::default()); world.register::(); let mut dispatcher = DispatcherBuilder::new() .with(Process::default(), "process", &[]) .with(Movement::default(), "movement", &[]) .with(Ships::new(world), "ships", &[]) .with(FleetOwnedUpdate::new(world), "fleet_owned_update", &[]) .with(OrbitOwnedUpdate::new(world), "orbit_owned_update", &[]) .build(); dispatcher.setup(world); Self { dispatcher } } pub fn process(&mut self, world: &World) { self.dispatcher.dispatch(world); } }