diff options
| author | troido <troido@protonmail.com> | 2020-02-09 18:53:27 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-09 18:53:27 +0100 |
| commit | 105c5ab0c0e969f3fda2cd43ae5195cbdb4da016 (patch) | |
| tree | 46b65b3e96d9b180bf6658cb968a149eb3cfde0f /src/room.rs | |
| parent | b1da31499de4145b1f77296cbea0c637e6f866bf (diff) | |
Revert "no templates in the world; only pre-entities"
This reverts commit b56add981c2f520789b97d1ee6f71dae41e8c900.
Diffstat (limited to 'src/room.rs')
| -rw-r--r-- | src/room.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/room.rs b/src/room.rs index 30c420a..9d3f1ed 100644 --- a/src/room.rs +++ b/src/room.rs @@ -28,20 +28,22 @@ use super::systems::{ }; use crate::encyclopedia::Encyclopedia; use crate::roomtemplate::RoomTemplate; -use crate::template::Template; pub struct Room<'a, 'b> { world: World, - dispatcher: Dispatcher<'a, 'b>, - encyclopedia: Encyclopedia + dispatcher: Dispatcher<'a, 'b> } impl <'a, 'b>Room<'a, 'b> { pub fn new(encyclopedia: Encyclopedia) -> Room<'a, 'b> { let mut world = World::new(); + world.insert(NewEntities{ + templates: Vec::new(), + encyclopedia + }); let mut dispatcher = DispatcherBuilder::new() .with(ControlInput, "controlinput", &[]) @@ -57,8 +59,7 @@ impl <'a, 'b>Room<'a, 'b> { Room { world, - dispatcher, - encyclopedia + dispatcher } } @@ -75,19 +76,11 @@ impl <'a, 'b>Room<'a, 'b> { let y = (idx as i64) / width; for template in templates { - if let Err(msg) = self.add_entity(Pos{x, y}, template) { - println!("{}", msg); - } + self.world.fetch_mut::<NewEntities>().templates.push((Pos{x, y}, template.clone())); } } } - pub fn add_entity(&mut self, pos: Pos, template: &Template) -> Result<(), &'static str>{ - let pre_entity = self.encyclopedia.construct(template)?; - self.world.fetch_mut::<NewEntities>().ents.push((pos, pre_entity)); - Ok(()) - } - pub fn view(&self) -> HashMap<String, WorldMessage> { self.world.fetch::<Output>().output.clone() } |
