From 25d0664f49eec5c9dadf33fe091500d61cf505e2 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 11 Aug 2021 10:44:45 -0500 Subject: [PATCH] Visibility blocking takes an opacity. --- src/visibility.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/visibility.rs b/src/visibility.rs index 1af14f0..a0f36e5 100644 --- a/src/visibility.rs +++ b/src/visibility.rs @@ -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,16 +129,20 @@ fn update_viewshed( InteractionGroups::all(), Some(&|v| v.entity() != *viewer_entity && blocks_visibility.get(v.entity()).is_ok()), |handle| { - if let Ok(coordinates) = coordinates.get(handle.entity()) { - if coordinates.i32() == (coord.x, coord.y) { - opacity = 255; - false + 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 = **blocks_visibility; + false + } else { + true + } } else { - true + opacity = **blocks_visibility; + false } } else { - opacity = 255; - false + true } }, );