diff options
author | Griffin Smith <root@gws.fyi> | 2019-07-28T21·45-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-07-28T21·45-0400 |
commit | 6c1eba67629504f10fa08ee68fb31f507c99b0d1 (patch) | |
tree | d5af8f3eb6dc32a1308a20863e5c8814a4634098 /src/display/viewport.rs | |
parent | f22bcad817ee354b355d29b6b289894e2d15cfaa (diff) |
Allow converting generated levels to entities
Add a new Wall entity, and allow converting generated levels to entity maps containing them, then finally displaying them using some of the (now expanded) box drawing machinery.
Diffstat (limited to 'src/display/viewport.rs')
-rw-r--r-- | src/display/viewport.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/display/viewport.rs b/src/display/viewport.rs index 372c0a2969d5..9ff7db07be20 100644 --- a/src/display/viewport.rs +++ b/src/display/viewport.rs @@ -1,7 +1,9 @@ use super::BoxStyle; -use super::Draw; +use super::DrawWithNeighbors; use crate::display::draw_box::draw_box; use crate::display::utils::clone_times; +use crate::entities::entity::Entity; +use crate::types::Neighbors; use crate::types::{pos, BoundingBox, Direction, Position, Positioned}; use std::fmt::{self, Debug}; use std::io::{self, Write}; @@ -77,12 +79,16 @@ impl<W> Debug for Viewport<W> { impl<W: Write> Viewport<W> { /// Draw the given entity to the viewport at its position, if visible - pub fn draw<T: Draw>(&mut self, entity: &T) -> io::Result<()> { + pub fn draw<'a, T: DrawWithNeighbors>( + &mut self, + entity: &T, + neighbors: &Neighbors<Vec<&Box<dyn Entity>>>, + ) -> io::Result<()> { if !self.visible(entity) { return Ok(()); } self.cursor_goto(entity.position())?; - entity.do_draw(self)?; + entity.do_draw_with_neighbors(self, neighbors)?; self.reset_cursor() } |