diff options
| author | troido <troido@protonmail.com> | 2020-02-23 23:58:55 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-23 23:58:55 +0100 |
| commit | 4718cfdc7c2bf67d2389ca18ab035fe5a0887ff0 (patch) | |
| tree | 83e645b930aa7434cb045ed58a5040bf3b16be93 /src/resources/mod.rs | |
| parent | 86cdc6c567d0ca429d69bebbb2fb02f1d3754c8d (diff) | |
don't draw removed entities
Diffstat (limited to 'src/resources/mod.rs')
| -rw-r--r-- | src/resources/mod.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/resources/mod.rs b/src/resources/mod.rs index d3777e5..07669c4 100644 --- a/src/resources/mod.rs +++ b/src/resources/mod.rs @@ -12,7 +12,7 @@ use crate::{ RoomId, Result, Template, - components::Visible, + components::{Visible, Removed}, playerstate::RoomPos }; @@ -43,8 +43,14 @@ pub struct Ground { pub cells: HashMap<Pos, HashSet<Entity>> } impl Ground { - pub fn components_on<'a, C: Component>(&self, pos: Pos, component_type: &'a ReadStorage<C>) -> Vec<&'a C> { - self.cells.get(&pos).unwrap_or(&HashSet::new()).iter().filter_map(|e| component_type.get(*e)).collect() + pub fn components_on<'a, C: Component>(&self, pos: Pos, component_type: &'a ReadStorage<C>, removals: &'a ReadStorage<Removed>) -> Vec<&'a C> { + self.cells + .get(&pos) + .unwrap_or(&HashSet::new()) + .iter() + .filter(|e| !removals.contains(**e)) + .filter_map(|e| component_type.get(*e)) + .collect() } pub fn by_height(&self, pos: &Pos, visibles: &ReadStorage<Visible>, ignore: &Entity) -> Vec<Entity> { |
