From 88f275bc427033b7981e0dc2fc5cb4b711fd5fb1 Mon Sep 17 00:00:00 2001 From: troido Date: Wed, 29 Jan 2020 00:13:03 +0100 Subject: refactored control --- src/room.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/room.rs') diff --git a/src/room.rs b/src/room.rs index 8190d63..c19af37 100644 --- a/src/room.rs +++ b/src/room.rs @@ -13,7 +13,7 @@ use super::controls::Control; use super::components::{Position, Visible, Controller}; use super::assemblages::Assemblage; use super::resources::{Size, TopView}; -use super::systems::{Draw, Move}; +use super::systems::{Draw, Move, ClearControllers}; @@ -36,8 +36,9 @@ impl <'a, 'b>Room<'a, 'b> { world.insert(TopView{width: width, height: height, cells: HashMap::new()}); let dispatcher = DispatcherBuilder::new() - .with(Draw, "draw", &[]) - .with(Move, "move", &["draw"]) + .with(Move, "move", &[]) + .with(Draw, "draw", &["move"]) + .with(ClearControllers, "clearcontrollers", &["move"]) .build(); Room { @@ -108,7 +109,7 @@ impl <'a, 'b>Room<'a, 'b> { pub fn control(&mut self, name: String, control: Control){ if let Some(ent) = self.players.get(&name){ - self.world.write_component::().get_mut(*ent).unwrap().0 = Some(control);//.insert(*ent, Controller(control)); + let _ = self.world.write_component::().insert(*ent, Controller(control)); } } } -- cgit