use ::serde::{Deserialize, Serialize}; /// The type of location for a specific square of a [`Map`](crate::map::Map) #[derive(PartialEq, Eq, Hash, Copy, Clone, Serialize, Deserialize)] pub enum TileType { Wall, Floor, DownStairs, Road, Grass, ShallowWater, DeepWater, WoodFloor, Bridge, Gravel, UpStairs, Stalactite, Stalagmite, } /// Can you go through this type of map tile? pub fn tile_walkable(tt: TileType) -> bool { matches!( tt, TileType::Floor | TileType::DownStairs | TileType::Road | TileType::Grass | TileType::ShallowWater | TileType::WoodFloor | TileType::Bridge | TileType::Gravel | TileType::UpStairs ) } /// Is it impossible to see through this type of map tile? pub fn tile_opaque(tt: TileType) -> bool { matches!( tt, TileType::Wall | TileType::Stalactite | TileType::Stalagmite ) } /// How difficult is it to cross this type of map tile? pub fn tile_cost(tt: TileType) -> f32 { match tt { TileType::Road => 0.8, TileType::Grass => 1.1, TileType::ShallowWater => 1.2, _ => 1.0, } }