diff options
| author | troido <troido@protonmail.com> | 2020-02-08 18:50:58 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-08 18:50:58 +0100 |
| commit | 3ebe9e6f792a0457c6f3b37b6e9d92c83f8694e2 (patch) | |
| tree | aaa81d23a4816ebecacc64593419d3d811b7283b /src/componentwrapper.rs | |
| parent | 7dfc7956a7c2df9a1df3ea0b32e0c3d2036fa3ce (diff) | |
don't rebuild the ground each step
Diffstat (limited to 'src/componentwrapper.rs')
| -rw-r--r-- | src/componentwrapper.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs index 8bf8552..e821b8b 100644 --- a/src/componentwrapper.rs +++ b/src/componentwrapper.rs @@ -1,9 +1,8 @@ use std::collections::HashMap; -use specs::{Builder, EntityBuilder}; +use specs::{Builder, world::LazyBuilder}; use crate::components::{Visible, Blocking, Player, Floor}; -use crate::hashmap; use crate::parameter::{Parameter, ParameterType}; @@ -20,7 +19,7 @@ macro_rules! components { impl ComponentWrapper { - pub fn build<'a>(&self, builder: EntityBuilder<'a>) -> EntityBuilder<'a> { + pub fn build<'a>(&self, builder: LazyBuilder<'a>) -> LazyBuilder<'a> { match self.clone() { $( Self::$comp(c) => builder.with(c), @@ -28,11 +27,12 @@ macro_rules! components { } } - pub fn load_component(comptype: ComponentType, mut parameters_: HashMap<&str, Parameter>) -> Option<Self> { + pub fn load_component(comptype: ComponentType, parameters_: HashMap<&str, Parameter>) -> Option<Self> { match comptype { $( ComponentType::$comp => Some(Self::$comp({ + #[allow(unused_mut)] let mut $paramlist = parameters_; $creation })), @@ -63,6 +63,7 @@ macro_rules! components { match self { $( Self::$comp => { + #[allow(unused_mut)] let mut h = HashMap::new(); $( h.insert(stringify!($paramname), ParameterType::$paramtype); @@ -82,8 +83,8 @@ components!( height: parameters.remove("height")?.as_f64()? } }; - Blocking [] p {Blocking}; - Floor [] p {Floor}; + Blocking [] _p {Blocking}; + Floor [] _p {Floor}; Player [name: String] parameters {Player::new(parameters.remove("name")?.as_string()?)} ); |
