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},
};
#[derive(Clone, Copy, Debug, Default, Reflect)]
#[derive(Clone, Copy, Debug, Deref, DerefMut, Reflect)]
#[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)]
#[reflect(Component)]
pub struct DontLogWhenVisible;
@ -124,17 +129,21 @@ fn update_viewshed(
InteractionGroups::all(),
Some(&|v| v.entity() != *viewer_entity && blocks_visibility.get(v.entity()).is_ok()),
|handle| {
if let Ok(blocks_visibility) = blocks_visibility.get(handle.entity()) {
if let Ok(coordinates) = coordinates.get(handle.entity()) {
if coordinates.i32() == (coord.x, coord.y) {
opacity = 255;
opacity = **blocks_visibility;
false
} else {
true
}
} else {
opacity = 255;
opacity = **blocks_visibility;
false
}
} else {
true
}
},
);
opacity