1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use noisy_float::prelude::*;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use crate::attribute::Attribute;
use crate::ids::*;
use crate::requirement::Requirement;
use crate::weapon::*;
use crate::Race;
/// Unit or structure
#[derive(Debug, Serialize, Deserialize, Clone, Eq)]
pub struct UnitType {
/// Id
pub id: UnitTypeId,
/// Name
pub name: String,
/// Race
pub race: Race,
/// Supply
pub supply: R32,
/// None for untransportable
cargo_size: Option<u32>,
/// None if cannot transport units
cargo_capacity: Option<u32>,
/// Max hp
max_health: u32,
/// Max shield
max_shield: Option<u32>,
/// Armor
armor: u32,
/// Vision range
sight: R32,
/// None if not detector
detection_range: Option<R32>,
/// Speed without upgrades of buffs, None if cannot move at all
speed: Option<R32>,
/// Creep speed multiplier without upgrades of buffs
speed_creep_mul: Option<R32>,
/// Max energy
max_energy: Option<u32>,
/// Start energy
start_energy: Option<u32>,
/// List of weapons, sorted by priority
weapons: Vec<Weapon>,
/// Attributes
attributes: HashSet<Attribute>,
/// A list of abilities and their requirements
abilities: Vec<UnitAbilityReq>,
/// Building size on grid, not available for non-structures
placement_size: Option<u32>,
/// Radius approximating the size of the unit.
#[serde(default)] // TODO: remove this and require
radius: R32,
/// Produces pylon power with this radius
power_radius: Option<R32>,
/// Terran add-on can be used with this structure
accepts_addon: bool,
/// Requires a pylon power to function
needs_power: bool,
/// Requires creep for placement
needs_creep: bool,
/// Requires a vespene gayser for placement
needs_gayser: bool,
/// Structure attribute is set
is_structure: bool,
/// Can be used as an add-on
is_addon: bool,
/// Workers: Probe, Drone, SCV
is_worker: bool,
/// Flying buildings not included
is_townhall: bool,
}
impl PartialEq for UnitType {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}
/// Unit ability with a possible requirement
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct UnitAbilityReq {
ability: AbilityId,
requirement: Option<Requirement>,
}