use std::collections::{ HashMap };
use std::rc::Rc;
use super::{
Color,
PowerSource,
TerrainInfo,
Unit,
Upgrade,
Point2,
Point3,
Score,
UnitType,
UnitTypeData,
Effect,
Ability,
AbilityData,
UpgradeData,
Buff,
BuffData,
Visibility,
ActionTarget,
ImageData
};
#[derive(Debug, Copy, Clone)]
pub enum DebugTextTarget {
Screen(Point2),
World(Point3)
}
#[derive(Debug, Clone)]
pub enum Command {
Action {
units: Vec<Rc<Unit>>,
ability: Ability,
target: Option<ActionTarget>
},
}
#[derive(Debug, Clone)]
pub enum DebugCommand {
DebugText {
text: String,
target: Option<DebugTextTarget>,
color: Color,
},
DebugLine {
p1: Point3,
p2: Point3,
color: Color,
},
DebugBox {
min: Point3,
max: Point3,
color: Color,
},
DebugSphere {
center: Point3,
radius: f32,
color: Color,
}
}
#[derive(Debug, Clone)]
pub enum GameEvent {
UnitDestroyed(Rc<Unit>),
UnitCreated(Rc<Unit>),
UnitIdle(Rc<Unit>),
UnitDetected(Rc<Unit>),
UpgradeCompleted(Upgrade),
BuildingCompleted(Rc<Unit>),
NydusWormsDetected(u32),
NukesDetected(u32),
}
#[derive(Debug, Clone)]
pub struct GameData {
pub ability_data: HashMap<Ability, AbilityData>,
pub unit_type_data: HashMap<UnitType, UnitTypeData>,
pub upgrade_data: HashMap<Upgrade, UpgradeData>,
pub buff_data: HashMap<Buff, BuffData>,
pub terrain_info: TerrainInfo,
}
#[derive(Debug, Clone)]
pub struct MapState {
pub creep: ImageData,
pub visibility: ImageData,
}
#[derive(Debug, Clone)]
pub struct GameState {
pub player_id: u32,
pub previous_step: u32,
pub current_step: u32,
pub camera_pos: Point2,
pub units: Vec<Rc<Unit>>,
pub power_sources: Vec<PowerSource>,
pub effects: Vec<Effect>,
pub upgrades: Vec<Upgrade>,
pub minerals: u32,
pub vespene: u32,
pub food_cap: u32,
pub food_used: u32,
pub food_army: u32,
pub food_workers: u32,
pub idle_worker_count: u32,
pub army_count: u32,
pub warp_gate_count: u32,
pub larva_count: u32,
pub score: Score
}
impl GameState {
pub fn filter_units<F>(&self, filter: F) -> Vec<Rc<Unit>>
where F: Fn(&Unit) -> bool
{
let mut units = vec![ ];
for unit in &self.units {
if filter(&unit) {
units.push(Rc::clone(&unit));
}
}
units
}
pub fn has_creep(&self, _: Point2) -> bool {
unimplemented!("has creep")
}
pub fn get_visibility(&self, _: Point2) -> Visibility {
unimplemented!("get visibility")
}
pub fn is_pathable(&self, _: Point2) -> bool {
unimplemented!("is pathable")
}
pub fn is_placable(&self, _: Point2) -> bool {
unimplemented!("is placable")
}
pub fn get_terrain_height(&self, _: Point2) -> f32 {
unimplemented!("get terrain height")
}
}
#[derive(Debug, Clone)]
pub struct FrameData {
pub state: GameState,
pub data: Rc<GameData>,
pub events: Vec<GameEvent>,
pub map: Rc<MapState>
}