summaryrefslogtreecommitdiff
path: root/src/systems
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-09 18:53:27 +0100
committertroido <troido@protonmail.com>2020-02-09 18:53:27 +0100
commit105c5ab0c0e969f3fda2cd43ae5195cbdb4da016 (patch)
tree46b65b3e96d9b180bf6658cb968a149eb3cfde0f /src/systems
parentb1da31499de4145b1f77296cbea0c637e6f866bf (diff)
Revert "no templates in the world; only pre-entities"
This reverts commit b56add981c2f520789b97d1ee6f71dae41e8c900.
Diffstat (limited to 'src/systems')
-rw-r--r--src/systems/controlinput.rs8
-rw-r--r--src/systems/create.rs15
2 files changed, 16 insertions, 7 deletions
diff --git a/src/systems/controlinput.rs b/src/systems/controlinput.rs
index 712c98b..0771b1e 100644
--- a/src/systems/controlinput.rs
+++ b/src/systems/controlinput.rs
@@ -14,7 +14,11 @@ use specs::{
use crate::components::{Controller, Player, Removed};
use crate::controls::{Control, Action};
use crate::resources::{Input, NewEntities, Spawn};
+use crate::hashmap;
+use crate::template::Template;
+use crate::parameter::Parameter;
+// use crate::assemblages::Player;
pub struct ControlInput;
@@ -44,9 +48,9 @@ impl <'a> System<'a> for ControlInput {
for action in &input.actions {
match action {
Action::Join(name) => {
- new.ents.push((
+ new.templates.push((
spawn.pos,
- crate::player::make_player(name)
+ Template::new("player", hashmap!("name".to_string() => Parameter::String(name.to_string())))
));
}
Action::Leave(name) => {leaving.insert(name);}
diff --git a/src/systems/create.rs b/src/systems/create.rs
index 054dc1f..35ef747 100644
--- a/src/systems/create.rs
+++ b/src/systems/create.rs
@@ -34,13 +34,18 @@ impl <'a> System<'a> for Create {
new.remove(ent);
}
}
- for (pos, comps) in &new_entities.ents {
+ for (pos, template) in &new_entities.templates {
let mut builder = updater.create_entity(&entities);
- for comp in comps {
- builder = comp.build(builder);
+ match new_entities.encyclopedia.construct(template) {
+ Ok(comps) => {
+ for comp in comps {
+ builder = comp.build(builder);
+ }
+ builder.with(Position::new(*pos)).with(New).build();
+ },
+ Err(msg) => {println!("{}", msg);}
}
- builder.with(Position::new(*pos)).with(New).build();
}
- new_entities.ents.clear();
+ new_entities.templates.clear();
}
}