yareio_sys/structure/
outpost.rs

1//! Provides access to outposts.
2
3use 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// Outpost
11#[wasm_bindgen]
12extern "C" {
13    /// The ID of an [`Outpost`].
14    #[wasm_bindgen(extends = StructureID, typescript_type = "OutpostID")]
15    #[derive(Clone, Debug, PartialEq, Eq)]
16    pub type OutpostID;
17
18    /// An outpost.
19    ///
20    /// [Yare.io Documentation](https://yare.io/documentation#doc_outpost)
21    #[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// `outposts`
48#[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/// `outposts`. Use the [`GetByID`] trait to retrieve individual outposts.
64///
65/// [Yare.io Documentation](https://yare.io/documentation#doc_outpost)
66#[inline(always)]
67pub fn outposts() -> &'static Outposts {
68    &_outposts
69}
70
71// `outpost_mdo`
72#[wasm_bindgen(js_name = "outpost_mdo")]
73extern "C" {
74    #[wasm_bindgen]
75    static _outpost_mdo: Outpost;
76}
77
78/// `outpost_mdo`
79///
80/// [Yare.io Documentation](https://yare.io/documentation#doc_outpost)
81#[inline(always)]
82pub fn outpost_mdo() -> &'static Outpost {
83    &_outpost_mdo
84}
85
86// `outpost`
87#[wasm_bindgen]
88extern "C" {
89    #[wasm_bindgen(js_name = "outpost")]
90    static _outpost: Outpost;
91}
92
93/// `outpost` (the outpost).
94///
95/// [Yare.io Documentation](https://yare.io/documentation#doc_intro)
96#[inline(always)]
97pub fn outpost() -> &'static Outpost {
98    &_outpost
99}