Simplify.

This commit is contained in:
Nolan Darilek 2021-08-04 15:51:18 -05:00
parent 6fdbf4a667
commit ade155fcb4

View File

@ -437,11 +437,9 @@ fn spawn_portal_colliders(
fn area_description( fn area_description(
mut events: EventReader<IntersectionEvent>, mut events: EventReader<IntersectionEvent>,
areas: Query<&Area>, areas: Query<(&AABB, Option<&Name>), With<Area>>,
players: Query<&Player>, players: Query<&Player>,
names: Query<&Name>,
config: Res<MapConfig>, config: Res<MapConfig>,
shapes: Query<&ColliderShape>,
mut log: Query<&mut Log>, mut log: Query<&mut Log>,
) { ) {
for event in events.iter() { for event in events.iter() {
@ -452,17 +450,13 @@ fn area_description(
{ {
if players.get(other).is_ok() { if players.get(other).is_ok() {
if let Ok(mut log) = log.single_mut() { if let Ok(mut log) = log.single_mut() {
let name = if let Ok(name) = names.get(area) { if let Ok((aabb, area_name)) = areas.get(area) {
let name = if let Some(name) = area_name {
Some(name.to_string()) Some(name.to_string())
} else if config.describe_undescribed_areas { } else if config.describe_undescribed_areas {
if let Ok(shape) = shapes.get(area) {
let aabb = shape.compute_local_aabb();
Some(format!("{}-by-{} area", aabb.extents().x, aabb.extents().y)) Some(format!("{}-by-{} area", aabb.extents().x, aabb.extents().y))
} else { } else {
None None
}
} else {
None
}; };
if let Some(name) = name { if let Some(name) = name {
if event.intersecting { if event.intersecting {
@ -476,6 +470,7 @@ fn area_description(
} }
} }
} }
}
pub struct MapPlugin; pub struct MapPlugin;