use glc::vector::Vector2f; use serde::{Deserialize, Serialize}; use specs::{Component, VecStorage}; #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct Position { pub pos: Vector2f, pub shape: Shape, } #[derive(Clone, Debug, Serialize, Deserialize)] pub enum Shape { Dot, Circle(f32), } impl Component for Position { type Storage = VecStorage; } impl Shape { pub fn radius(&self) -> Option { match self { Self::Dot => Some(0.0), Self::Circle(r) => Some(*r), } } pub fn circle(&self) -> Option { if let Self::Circle(r) = &self { Some(*r) } else { None } } } impl Default for Shape { fn default() -> Self { Self::Dot } }