|
- #![allow(dead_code)]
-
- use space_crush_common::components::{Player, ShipCount};
- use specs::{Entity, ReadStorage, World};
-
- pub struct GameState {
- player_id: Entity,
- player_index: usize,
- selection: Option<Selection>,
- }
-
- pub struct Selection {
- pub fleet: Entity,
- pub count: ShipCount,
- }
-
- impl GameState {
- pub fn new(world: &mut World, player_id: Entity) -> Self {
- let player_index = world
- .system_data::<ReadStorage<Player>>()
- .get(player_id)
- .unwrap()
- .index();
-
- Self {
- player_id,
- player_index,
- selection: None,
- }
- }
-
- pub fn player_id(&self) -> Entity {
- self.player_id
- }
-
- pub fn player_index(&self) -> usize {
- self.player_index
- }
-
- pub fn selection(&self) -> &Option<Selection> {
- &self.selection
- }
-
- pub(crate) fn selection_mut(&mut self) -> &mut Option<Selection> {
- &mut self.selection
- }
- }
|