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