Implement a global map of entities
Implement a global map of entities, which allows referencing by either position or ID and updating the positions of existent entities, and put the character in there.
This commit is contained in:
parent
20f1ccb460
commit
5af2429ecb
14 changed files with 465 additions and 36 deletions
|
|
@ -1,2 +1,16 @@
|
|||
pub mod character;
|
||||
use crate::display::Draw;
|
||||
use crate::types::{Positioned, PositionedMut};
|
||||
pub use character::Character;
|
||||
use downcast_rs::Downcast;
|
||||
use std::io::{self, Write};
|
||||
|
||||
pub trait Entity: Positioned + PositionedMut + Draw + Downcast {}
|
||||
|
||||
impl_downcast!(Entity);
|
||||
|
||||
impl Draw for Box<dyn Entity> {
|
||||
fn do_draw(&self, out: &mut Write) -> io::Result<()> {
|
||||
(**self).do_draw(out)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue