diff --git a/src/visibility.rs b/src/visibility.rs index ae933fb..be38898 100644 --- a/src/visibility.rs +++ b/src/visibility.rs @@ -102,6 +102,7 @@ fn update_viewshed( collider_query: &QueryPipelineColliderComponentsQuery, map: &Map, blocks_visibility: &Query<&BlocksVisibility>, + coordinates: &Query<&Coordinates>, ) { let mut context: Context = Context::default(); let vision_distance = vision_distance::Circle::new(viewshed.range); @@ -122,9 +123,18 @@ fn update_viewshed( &shape, InteractionGroups::all(), Some(&|v| v.entity() != *viewer_entity && blocks_visibility.get(v.entity()).is_ok()), - |_| { - opacity = 255; - false + |handle| { + if let Ok(coordinates) = coordinates.get(handle.entity()) { + if coordinates.i32() == (coord.x, coord.y) { + opacity = 255; + false + } else { + true + } + } else { + opacity = 255; + false + } }, ); opacity @@ -148,6 +158,7 @@ fn update_viewshed_for_coordinates( query_pipeline: Res, collider_query: QueryPipelineColliderComponentsQuery, blocks_visibility: Query<&BlocksVisibility>, + coordinates_query: Query<&Coordinates>, ) { for (coordinates, _) in visible.iter() { for (viewer_entity, mut viewshed, start) in viewers.iter_mut() { @@ -163,6 +174,7 @@ fn update_viewshed_for_coordinates( &collider_query, map, &blocks_visibility, + &coordinates_query, ); } } @@ -175,6 +187,7 @@ fn update_viewshed_for_start( query_pipeline: Res, collider_query: QueryPipelineColliderComponentsQuery, blocks_visibility: Query<&BlocksVisibility>, + coordinates_query: Query<&Coordinates>, ) { for (viewer_entity, mut viewshed, start) in viewers.iter_mut() { if let Ok(map) = map.single() { @@ -186,6 +199,7 @@ fn update_viewshed_for_start( &collider_query, map, &blocks_visibility, + &coordinates_query, ); } } @@ -198,6 +212,7 @@ fn remove_blocks_visibility( query_pipeline: Res, collider_query: QueryPipelineColliderComponentsQuery, blocks_visibility: Query<&BlocksVisibility>, + coordinates_query: Query<&Coordinates>, ) { for _ in removed.iter() { for (viewer_entity, mut viewshed, start) in viewers.iter_mut() { @@ -210,6 +225,7 @@ fn remove_blocks_visibility( &collider_query, map, &blocks_visibility, + &coordinates_query, ); } }