Simplify.
This commit is contained in:
parent
6fdbf4a667
commit
ade155fcb4
29
src/map.rs
29
src/map.rs
|
@ -437,11 +437,9 @@ fn spawn_portal_colliders(
|
|||
|
||||
fn area_description(
|
||||
mut events: EventReader<IntersectionEvent>,
|
||||
areas: Query<&Area>,
|
||||
areas: Query<(&AABB, Option<&Name>), With<Area>>,
|
||||
players: Query<&Player>,
|
||||
names: Query<&Name>,
|
||||
config: Res<MapConfig>,
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user