From 42912e59a8a11ada5d7ace2a213a1efcb2712818 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Tue, 21 Sep 2021 06:38:51 -0500 Subject: [PATCH] Refactor visibility to be collider and event-based. --- src/exploration.rs | 4 +- src/sound.rs | 25 ++-- src/visibility.rs | 300 ++++++++++++++++++++++++++++++++++----------- 3 files changed, 243 insertions(+), 86 deletions(-) diff --git a/src/exploration.rs b/src/exploration.rs index 014df57..a70e45c 100644 --- a/src/exploration.rs +++ b/src/exploration.rs @@ -95,7 +95,7 @@ where let (x, y) = **coordinates; let x = x as i32; let y = y as i32; - if viewshed.visible.contains(&(x, y)) { + if viewshed.is_point_visible(&(x, y)) { types.push(*t); } } @@ -176,7 +176,7 @@ where let (x, y) = ***coordinates; let x = x as i32; let y = y as i32; - viewshed.visible.contains(&(x, y)) + viewshed.is_point_visible(&(x, y)) }) .collect::>(); features.sort_by(|(c1, _), (c2, _)| c1.partial_cmp(c2).unwrap()); diff --git a/src/sound.rs b/src/sound.rs index 745ebc7..5cacb93 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -8,7 +8,7 @@ use rand::random; use crate::{ core::{Coordinates, CoreConfig, Player, PointLike}, exploration::ExplorationFocused, - visibility::Viewshed, + visibility::{Viewshed, VisibleEntities}, }; #[derive(Clone, Debug, Reflect)] @@ -151,14 +151,14 @@ fn sound_icon( config: Res>, state: Res>, time: Res