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