diff --git a/src/game_object.rs b/src/game_object.rs index e7b0a18..c392e8f 100644 --- a/src/game_object.rs +++ b/src/game_object.rs @@ -129,17 +129,18 @@ pub fn book(entity_props: &HashMap<&String, &String>, ref_id: &str, mesh_name: & pub fn cell(entity_props: &HashMap<&String, &String>, ref_id: &str) -> Cell { let mut flags = CellFlags::default() | CellFlags::IS_INTERIOR; - if let Ok(_) = get_prop("FakeExterior", entity_props).parse::() { - flags |= CellFlags::BEHAVES_LIKE_EXTERIOR; - } - - if let Ok(_) = get_prop("HasWater", entity_props).parse::() { - flags |= CellFlags::HAS_WATER; - }; - - if let Ok(_) = get_prop("RestIsIllegal", entity_props).parse::() { - flags |= CellFlags::RESTING_IS_ILLEGAL; - }; + flags |= [ + ("FakeExterior", CellFlags::BEHAVES_LIKE_EXTERIOR), + ("RestIsIllegal", CellFlags::RESTING_IS_ILLEGAL), + ("HasWater", CellFlags::HAS_WATER), + ] + .iter() + .fold(CellFlags::empty(), |acc, &(prop, flag)| { + acc | match get_prop(prop, entity_props).parse::() { + Ok(1) => flag, + _ => CellFlags::empty(), + } + }); Cell { flags: ObjectFlags::default(),