Avoid possible crash.
This commit is contained in:
parent
0751cf344d
commit
f16d160994
|
@ -15,6 +15,7 @@ use shadowcast::{vision_distance, Context, InputGrid};
|
|||
|
||||
use crate::{
|
||||
bevy_rapier2d::prelude::*,
|
||||
commands::RunIfExistsExt,
|
||||
core::{Angle, Coordinates, Player, PointLike},
|
||||
log::Log,
|
||||
map::{ITileType, Map, MapConfig},
|
||||
|
@ -294,9 +295,10 @@ fn update_viewshed<D: 'static + Clone + Default + Send + Sync>(
|
|||
position.position.translation.x,
|
||||
position.position.translation.y,
|
||||
);
|
||||
commands
|
||||
.entity(entity)
|
||||
.insert(LastCoordinates(coordinates.i32()));
|
||||
let coordinates_i32 = coordinates.i32();
|
||||
commands.run_if_exists(entity, move |mut entity| {
|
||||
entity.insert(LastCoordinates(coordinates_i32));
|
||||
});
|
||||
if viewers.get_mut(entity).is_ok() {
|
||||
if let Some(last_coordinates) = last_coordinates {
|
||||
if **last_coordinates != coordinates.i32() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user