Build dispatcher in systems.rs
This commit is contained in:
parent
763f4b7396
commit
2dc915d210
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue