You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
696 B

  1. use glc::vector::Vector2f;
  2. use serde::{Deserialize, Serialize};
  3. use specs::{Component, VecStorage};
  4. use crate::misc::FlaggedStorage;
  5. #[derive(Clone, Debug, Default, Serialize, Deserialize)]
  6. pub struct Position {
  7. pub pos: Vector2f,
  8. pub shape: Shape,
  9. }
  10. #[derive(Clone, Debug, Serialize, Deserialize)]
  11. pub enum Shape {
  12. Dot,
  13. Circle(f32),
  14. }
  15. impl Component for Position {
  16. type Storage = FlaggedStorage<Self, VecStorage<Self>>;
  17. }
  18. impl Shape {
  19. pub fn circle(&self) -> Option<f32> {
  20. if let Self::Circle(r) = &self {
  21. Some(*r)
  22. } else {
  23. None
  24. }
  25. }
  26. }
  27. impl Default for Shape {
  28. fn default() -> Self {
  29. Self::Dot
  30. }
  31. }