Remove calls to \.single.

This commit is contained in:
Nolan Darilek 2022-02-01 08:41:27 -06:00
parent 7b1aaf69a2
commit 3cfb638b48
3 changed files with 34 additions and 31 deletions

View File

@ -265,30 +265,31 @@ fn exploration_focus<S, A: 'static>(
config.action_explore_right.clone(),
) {
for map in map.iter() {
let (entity, coordinates, exploring) = explorers.single();
let coordinates = **coordinates;
let mut exploring = if let Some(exploring) = exploring {
**exploring
} else {
coordinates.floor()
};
let orig = exploring;
if input.just_active(explore_forward.clone()) {
exploring.1 += 1.;
} else if input.just_active(explore_backward.clone()) {
exploring.1 -= 1.;
} else if input.just_active(explore_left.clone()) {
exploring.0 -= 1.;
} else if input.just_active(explore_right.clone()) {
exploring.0 += 1.;
}
if orig != exploring
&& exploring.0 >= 0.
&& exploring.0 < map.width as f32
&& exploring.1 >= 0.
&& exploring.1 < map.height as f32
{
commands.entity(entity).insert(Exploring(exploring));
if let Ok((entity, coordinates, exploring)) = explorers.get_single() {
let coordinates = **coordinates;
let mut exploring = if let Some(exploring) = exploring {
**exploring
} else {
coordinates.floor()
};
let orig = exploring;
if input.just_active(explore_forward.clone()) {
exploring.1 += 1.;
} else if input.just_active(explore_backward.clone()) {
exploring.1 -= 1.;
} else if input.just_active(explore_left.clone()) {
exploring.0 -= 1.;
} else if input.just_active(explore_right.clone()) {
exploring.0 += 1.;
}
if orig != exploring
&& exploring.0 >= 0.
&& exploring.0 < map.width as f32
&& exploring.1 >= 0.
&& exploring.1 < map.height as f32
{
commands.entity(entity).insert(Exploring(exploring));
}
}
}
}

View File

@ -454,7 +454,6 @@ fn area_description(
})
{
if players.get(other).is_ok() {
let mut log = log.single_mut();
if let Ok((aabb, area_name)) = areas.get(area) {
let name = if let Some(name) = area_name {
Some(name.to_string())
@ -464,10 +463,12 @@ fn area_description(
None
};
if let Some(name) = name {
if event.intersecting {
log.push(format!("Entering {name}."));
} else {
log.push(format!("Leaving {name}."));
if let Ok(mut log) = log.get_single_mut() {
if event.intersecting {
log.push(format!("Entering {name}."));
} else {
log.push(format!("Leaving {name}."));
}
}
}
}

View File

@ -379,7 +379,6 @@ fn log_visible(
continue;
}
if let Ok((name, body_position, collider_position)) = visible.get(*viewed) {
let mut log = log.single_mut();
let viewed_coordinates = if let Some(p) = body_position {
(p.position.translation.x, p.position.translation.y)
} else if let Some(p) = collider_position {
@ -391,7 +390,9 @@ fn log_visible(
let yaw = Angle::Radians(forward.y.atan2(forward.x));
let location =
viewer_coordinates.direction_and_distance(&viewed_coordinates, Some(yaw));
log.push(format!("{}: {location}", **name));
if let Ok(mut log) = log.get_single_mut() {
log.push(format!("{}: {location}", **name));
}
}
} else if let VisibilityChanged::Lost { viewed, .. } = event {
recently_lost.insert(*viewed, Timer::from_seconds(2., false));