Bring collision monitoring in line with visibility blocking.

This commit is contained in:
Nolan Darilek 2021-06-01 12:35:14 -05:00
parent e28f21c351
commit 6eabdf52ab
2 changed files with 15 additions and 21 deletions

View File

@ -372,17 +372,17 @@ fn remove_monitors_collisions(
) {
for entity in removed.iter() {
for (map, mut collisions_monitored) in map.iter_mut() {
let prev = prev_index.get(&entity).cloned();
prev_index.remove(&entity);
if let Some(prev) = prev {
set_monitors_collisions(
&map,
prev,
&monitors_collisions,
&mut collisions_monitored,
);
}
if let Ok(coordinates) = coordinates.get_component::<Coordinates>(entity) {
let prev = prev_index.get(&entity).cloned();
prev_index.remove(&entity);
if let Some(prev) = prev {
set_monitors_collisions(
&map,
prev,
&monitors_collisions,
&mut collisions_monitored,
);
}
let idx = coordinates.to_index(map.width());
set_monitors_collisions(&map, idx, &monitors_collisions, &mut collisions_monitored);
}

View File

@ -143,20 +143,14 @@ fn remove_blocks_visibility(
) {
for entity in removed.iter() {
for (map, mut visibility_blocked) in map.iter_mut() {
let prev = prev_index.get(&entity).cloned();
if let Some(prev) = prev {
prev_index.remove(&entity);
set_visibility_blocked(&map, prev, &blocks_visibility, &mut visibility_blocked);
}
if let Ok(coordinates) = coordinates.get_component::<Coordinates>(entity) {
let prev = prev_index.get(&entity).cloned();
if let Some(prev) = prev {
prev_index.remove(&entity);
set_visibility_blocked(
&map,
prev,
&blocks_visibility,
&mut visibility_blocked,
);
};
let idx = coordinates.to_index(map.width());
set_visibility_blocked(&map, idx, &blocks_visibility, &mut visibility_blocked);
prev_index.insert(entity, idx);
}
}
}