1use noisy_float::prelude::*;
2use serde::{Deserialize, Serialize};
3use std::collections::HashSet;
4
5use crate::attribute::Attribute;
6use crate::ids::*;
7use crate::requirement::Requirement;
8use crate::weapon::*;
9use crate::Race;
10
11#[derive(Debug, Serialize, Deserialize, Clone, Eq)]
13pub struct UnitType {
14 pub id: UnitTypeId,
16 pub name: String,
18 pub race: Race,
20 pub supply: R32,
22 cargo_size: Option<u32>,
24 cargo_capacity: Option<u32>,
26 max_health: u32,
28 max_shield: Option<u32>,
30 armor: u32,
32 sight: R32,
34 detection_range: Option<R32>,
36 speed: Option<R32>,
38 speed_creep_mul: Option<R32>,
40 max_energy: Option<u32>,
42 start_energy: Option<u32>,
44 weapons: Vec<Weapon>,
46 attributes: HashSet<Attribute>,
48 abilities: Vec<UnitAbilityReq>,
50 placement_size: Option<u32>,
52 #[serde(default)] radius: R32,
55 power_radius: Option<R32>,
57 accepts_addon: bool,
59 needs_power: bool,
61 needs_creep: bool,
63 needs_gayser: bool,
65 is_structure: bool,
67 is_addon: bool,
69 is_worker: bool,
71 is_townhall: bool,
73}
74impl PartialEq for UnitType {
75 fn eq(&self, other: &Self) -> bool {
76 self.id == other.id
77 }
78}
79
80#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
82pub struct UnitAbilityReq {
83 ability: AbilityId,
84 requirement: Option<Requirement>,
85}