summaryrefslogtreecommitdiff
path: root/src/room.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-21 15:03:43 +0100
committertroido <troido@protonmail.com>2020-02-21 15:03:43 +0100
commitada1c4571a9ba43b15027f126fada55e73901a11 (patch)
tree30b49fd4a4ad7460d439aa12e805fcddf33bcad9 /src/room.rs
parentd225dc6349670926a4adea932f0ea77b7af5acbc (diff)
create World for multiroom support
Diffstat (limited to 'src/room.rs')
-rw-r--r--src/room.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/room.rs b/src/room.rs
index c826c19..c813e0c 100644
--- a/src/room.rs
+++ b/src/room.rs
@@ -102,6 +102,13 @@ impl <'a, 'b>Room<'a, 'b> {
}
}
+
+ pub fn create(id: RoomId, encyclopedia: &Encyclopedia, template: &RoomTemplate) -> Room<'a, 'b> {
+ let mut room = Self::new(id, encyclopedia.clone());
+ room.load_from_template(template);
+ room
+ }
+
pub fn view(&self) -> HashMap<PlayerId, WorldMessage> {
self.world.fetch::<Output>().output.clone()
}
@@ -111,8 +118,9 @@ impl <'a, 'b>Room<'a, 'b> {
self.world.maintain();
}
- pub fn set_input(&mut self, actions: HashMap<PlayerId, Control>){
- self.world.fetch_mut::<Input>().actions = actions;
+
+ pub fn control_player(&mut self, player: PlayerId, control: Control){
+ self.world.fetch_mut::<Input>().actions.insert(player, control);
}
pub fn add_player(&mut self, state: &PlayerState){