Visibility blocking takes an opacity.

This commit is contained in:
Nolan Darilek 2021-08-11 10:44:45 -05:00
parent ef9ba8530f
commit 25d0664f49

View File

@ -12,10 +12,15 @@ use crate::{
map::{ITileType, Map, MapConfig}, map::{ITileType, Map, MapConfig},
}; };
#[derive(Clone, Copy, Debug, Default, Reflect)] #[derive(Clone, Copy, Debug, Deref, DerefMut, Reflect)]
#[reflect(Component)] #[reflect(Component)]
pub struct BlocksVisibility; pub struct BlocksVisibility(pub u8);
impl Default for BlocksVisibility {
fn default() -> Self {
Self(u8::MAX)
}
}
#[derive(Clone, Copy, Debug, Default, Reflect)] #[derive(Clone, Copy, Debug, Default, Reflect)]
#[reflect(Component)] #[reflect(Component)]
pub struct DontLogWhenVisible; pub struct DontLogWhenVisible;
@ -124,17 +129,21 @@ fn update_viewshed(
InteractionGroups::all(), InteractionGroups::all(),
Some(&|v| v.entity() != *viewer_entity && blocks_visibility.get(v.entity()).is_ok()), Some(&|v| v.entity() != *viewer_entity && blocks_visibility.get(v.entity()).is_ok()),
|handle| { |handle| {
if let Ok(blocks_visibility) = blocks_visibility.get(handle.entity()) {
if let Ok(coordinates) = coordinates.get(handle.entity()) { if let Ok(coordinates) = coordinates.get(handle.entity()) {
if coordinates.i32() == (coord.x, coord.y) { if coordinates.i32() == (coord.x, coord.y) {
opacity = 255; opacity = **blocks_visibility;
false false
} else { } else {
true true
} }
} else { } else {
opacity = 255; opacity = **blocks_visibility;
false false
} }
} else {
true
}
}, },
); );
opacity opacity