yareio_sys/structure/
outpost.rs1use crate::players::PlayerID;
4use crate::structure::{Structure, StructureID};
5use crate::{prelude::*, CanFrom};
6use js_sys::Object;
7use std::convert::TryFrom;
8use wasm_bindgen::prelude::*;
9
10#[wasm_bindgen]
12extern "C" {
13 #[wasm_bindgen(extends = StructureID, typescript_type = "OutpostID")]
15 #[derive(Clone, Debug, PartialEq, Eq)]
16 pub type OutpostID;
17
18 #[wasm_bindgen(extends = Structure, typescript_type = "Outpost")]
22 #[derive(Clone, Debug, PartialEq, Eq)]
23 pub type Outpost;
24
25 #[wasm_bindgen(method, getter)]
26 pub fn id(this: &Outpost) -> OutpostID;
27
28 #[wasm_bindgen(method, getter)]
29 pub fn range(this: &Outpost) -> f64;
30
31 #[wasm_bindgen(method, getter)]
32 pub fn sight(this: &Outpost) -> OutpostSight;
33
34 #[wasm_bindgen(method, getter)]
35 pub fn control(this: &Outpost) -> PlayerID;
36}
37
38impl CanFrom<Structure> for Outpost {
39 #[inline]
40 fn can_from(value: &Structure) -> bool {
41 value.structure_type().to_str() == "outpost"
42 }
43}
44
45try_can_from!(impl TryFrom<Structure>, Error = Structure for Outpost);
46
47#[wasm_bindgen]
49extern "C" {
50 #[wasm_bindgen(extends = Object, typescript_type = "(typeof outposts)")]
51 #[derive(Clone, Debug)]
52 pub type Outposts;
53
54 #[wasm_bindgen(js_name = "outposts")]
55 static _outposts: Outposts;
56}
57
58impl TryGetByID<EntityID, Outpost> for Outposts {}
59impl TryGetByID<StructureID, Outpost> for Outposts {}
60impl GetByID<OutpostID, Outpost> for Outposts {}
61impl EnumerateByID<OutpostID, Outpost> for Outposts {}
62
63#[inline(always)]
67pub fn outposts() -> &'static Outposts {
68 &_outposts
69}
70
71#[wasm_bindgen(js_name = "outpost_mdo")]
73extern "C" {
74 #[wasm_bindgen]
75 static _outpost_mdo: Outpost;
76}
77
78#[inline(always)]
82pub fn outpost_mdo() -> &'static Outpost {
83 &_outpost_mdo
84}
85
86#[wasm_bindgen]
88extern "C" {
89 #[wasm_bindgen(js_name = "outpost")]
90 static _outpost: Outpost;
91}
92
93#[inline(always)]
97pub fn outpost() -> &'static Outpost {
98 &_outpost
99}