46 lines
809 B
Rust
46 lines
809 B
Rust
use std::fmt;
|
|
|
|
|
|
pub type EntityId = (EntityType, u32);
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
|
pub enum EntityType {
|
|
Creature,
|
|
Site,
|
|
Item,
|
|
}
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
|
pub struct Location {
|
|
pub x: i32,
|
|
pub y: i32,
|
|
}
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
|
pub struct Entity {
|
|
pub id: EntityId,
|
|
}
|
|
|
|
impl Entity {
|
|
pub fn new_creature() -> Entity {
|
|
Entity { id: (EntityType::Creature, 0) }
|
|
}
|
|
|
|
pub fn new_site() -> Entity {
|
|
Entity { id: (EntityType::Site, 0) }
|
|
}
|
|
|
|
pub fn new_item() -> Entity {
|
|
Entity { id: (EntityType::Item, 0) }
|
|
}
|
|
}
|
|
|
|
|
|
impl fmt::Display for Location {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(f, "({}, {})", self.x, self.y)
|
|
}
|
|
}
|