refactor code to be smaller and clearer

This commit is contained in:
KyoZM
2019-10-10 20:52:52 -03:00
parent e8d8179899
commit dbca8e3b09

View File

@ -96,8 +96,9 @@ impl Asset for StructuresSpec {
} }
} }
fn convert(specifications: &StructuresSpec) -> Vec<Arc<Structure>> { fn load_structures(specifier: &str) -> Vec<Arc<Structure>> {
return specifications let spec = assets::load::<StructuresSpec>(&["world.manifests.", specifier].concat());
return spec.unwrap()
.0 .0
.iter() .iter()
.map(|sp| { .map(|sp| {
@ -109,12 +110,6 @@ fn convert(specifications: &StructuresSpec) -> Vec<Arc<Structure>> {
.collect(); .collect();
} }
fn load_structures(specifier: &str) -> Vec<Arc<Structure>> {
dbg!(specifier);
let spec = assets::load::<StructuresSpec>(&["world.manifests.", specifier].concat());
return convert(&spec.unwrap());
}
lazy_static! { lazy_static! {
pub static ref OAKS: Vec<Arc<Structure>> = load_structures("oaks"); pub static ref OAKS: Vec<Arc<Structure>> = load_structures("oaks");