From ade155fcb4ea548a2fe004fd8835e4f9d16555ac Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 4 Aug 2021 15:51:18 -0500 Subject: [PATCH] Simplify. --- src/map.rs | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/map.rs b/src/map.rs index 91bc63b..5e9a189 100644 --- a/src/map.rs +++ b/src/map.rs @@ -437,11 +437,9 @@ fn spawn_portal_colliders( fn area_description( mut events: EventReader, - areas: Query<&Area>, + areas: Query<(&AABB, Option<&Name>), With>, players: Query<&Player>, - names: Query<&Name>, config: Res, - shapes: Query<&ColliderShape>, mut log: Query<&mut Log>, ) { for event in events.iter() { @@ -452,23 +450,20 @@ fn area_description( { if players.get(other).is_ok() { if let Ok(mut log) = log.single_mut() { - let name = if let Ok(name) = names.get(area) { - Some(name.to_string()) - } else if config.describe_undescribed_areas { - if let Ok(shape) = shapes.get(area) { - let aabb = shape.compute_local_aabb(); + if let Ok((aabb, area_name)) = areas.get(area) { + let name = if let Some(name) = area_name { + Some(name.to_string()) + } else if config.describe_undescribed_areas { Some(format!("{}-by-{} area", aabb.extents().x, aabb.extents().y)) } else { None - } - } else { - None - }; - if let Some(name) = name { - if event.intersecting { - log.push(format!("Entering {}.", name)); - } else { - log.push(format!("Leaving {}.", name)); + }; + if let Some(name) = name { + if event.intersecting { + log.push(format!("Entering {}.", name)); + } else { + log.push(format!("Leaving {}.", name)); + } } } }