Build dispatcher in systems.rs

This commit is contained in:
Alex Bethel 2022-03-27 17:05:23 -06:00
parent 763f4b7396
commit 2dc915d210
2 changed files with 11 additions and 6 deletions

View file

@ -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,

View file

@ -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()
}