Fix condition for visibility self-hit.

This commit is contained in:
Nolan Darilek 2024-12-10 14:26:59 -06:00
parent 330d915267
commit 34613bfe07

View File

@ -58,7 +58,7 @@ impl Viewshed {
(start.x.abs() + self.range as f32 * 2.) as u32,
(start.y.abs() + self.range as f32 * 2.) as u32,
);
let visibility_grid = VisibilityGrid(size, *viewer_entity, opacity_map.clone());
let visibility_grid = VisibilityGrid(*viewer_entity, opacity_map.clone());
let mut new_visible = HashSet::new();
let mut new_visible_entities = HashSet::new();
// println!("Start: {viewer_entity}");
@ -281,7 +281,7 @@ fn viewshed_removed(
}
}
pub struct VisibilityGrid(pub (u32, u32), pub Entity, pub OpacityMap);
struct VisibilityGrid(Entity, OpacityMap);
impl InputGrid for VisibilityGrid {
type Grid = (u32, u32);
@ -294,8 +294,8 @@ impl InputGrid for VisibilityGrid {
fn get_opacity(&self, _grid: &Self::Grid, coord: Coord) -> Self::Opacity {
// println!("Checking {coord:?}");
if let Some((opacity, entities)) = self.2.get(&IVec2::new(coord.x, coord.y)) {
if entities.len() == 1 && entities.contains(&self.1) {
if let Some((opacity, entities)) = self.1.get(&IVec2::new(coord.x, coord.y)) {
if entities.contains(&self.0) {
// println!("Hit viewer, 0");
0
} else {