diff --git a/src/main.rs b/src/main.rs index 052174b..ad683c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ use level::{DungeonLevel, LEVEL_SIZE}; use player::player_turn; use rand::thread_rng; use specs::prelude::*; -use systems::{DiscoverySystem, MobSystem, TimeSystem}; +use systems::build_dispatcher; mod components; mod io; @@ -44,11 +44,7 @@ fn main() { }) .build(); - let mut dispatcher = DispatcherBuilder::new() - .with(TimeSystem, "time", &[]) - .with(MobSystem, "mobs", &[]) - .with(DiscoverySystem, "discovery", &[]) - .build(); + let mut dispatcher = build_dispatcher(); let mut window = match init_window() { Ok(window) => window, diff --git a/src/systems.rs b/src/systems.rs index cc49eff..b9f2951 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -72,3 +72,12 @@ impl<'a> System<'a> for DiscoverySystem { } } } + +/// Creates a Dispatcher with every system set up. +pub fn build_dispatcher() -> Dispatcher<'static, 'static> { + DispatcherBuilder::new() + .with(TimeSystem, "time", &[]) + .with(MobSystem, "mobs", &[]) + .with(DiscoverySystem, "discovery", &[]) + .build() +}