use galactica_content::{Content, ContentIndex, SystemObject}; use rapier2d::geometry::ColliderHandle; use std::sync::Arc; /// What the player has selected #[derive(Debug, Clone)] pub enum PlayerSelection { /// We have nothing selected None, /// We have a system body selected OrbitingBody(Arc), /// We have a ship selected Ship(ColliderHandle), } impl PlayerSelection { pub fn get_planet(&self) -> Option<&Arc> { match self { Self::OrbitingBody(h) => Some(h), _ => None, } } } #[derive(Debug)] pub struct PlayerAgent { /// Which ship this player is controlling pub ship: Option, /// What the player has selected pub selection: PlayerSelection, } impl PlayerAgent { pub fn new(ct: &Content, ship: ColliderHandle) -> Self { Self { ship: Some(ship), selection: PlayerSelection::OrbitingBody( ct.systems .values() .next() .unwrap() .objects .get(&ContentIndex::new("earth")) .unwrap() .clone(), ), } } }