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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
use crate::spirit::LivingSpirit;
use crate::structure::{Structure, StructureID};
use crate::{
prelude::*, CanFrom, Destructible, DestructibleID, LivingDestructible, LivingDestructibleID,
};
use js_sys::{Object, Reflect};
use std::convert::TryFrom;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = StructureID, extends = LivingDestructibleID, typescript_type = "BaseID")]
#[derive(Clone, Debug, PartialEq, Eq)]
pub type BaseID;
#[wasm_bindgen(extends = Structure, extends = LivingDestructible, typescript_type = "Base")]
#[derive(Clone, Debug, PartialEq, Eq)]
pub type Base;
#[wasm_bindgen(method, getter)]
pub fn id(this: &Base) -> BaseID;
#[wasm_bindgen(method, getter)]
pub fn current_spirit_cost(this: &Base) -> i32;
}
impl CanFrom<Structure> for Base {
#[inline]
fn can_from(value: &Structure) -> bool {
value.structure_type().to_str() == "base"
}
}
try_can_from!(impl TryFrom<Structure>, Error = Structure for Base);
impl CanFrom<Destructible> for Base {
#[inline]
fn can_from(value: &Destructible) -> bool {
Reflect::has(value, &"current_spirit_cost".into()).unwrap()
}
}
try_can_from!(impl TryFrom<Destructible>, Error = Spirit for Base);
impl CanFrom<LivingDestructible> for Base {
#[inline]
fn can_from(value: &LivingDestructible) -> bool {
<Base as CanFrom<Destructible>>::can_from(value)
}
}
try_can_from!(impl TryFrom<LivingDestructible>, Error = LivingSpirit for Base);
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = Object, typescript_type = "(typeof bases)")]
#[derive(Clone, Debug)]
pub type Bases;
#[wasm_bindgen(js_name = "bases")]
static _bases: Bases;
}
impl TryGetByID<EntityID, Base> for Bases {}
impl TryGetByID<DestructibleID, Base> for Bases {}
impl TryGetByID<LivingDestructibleID, Base> for Bases {}
impl TryGetByID<StructureID, Base> for Bases {}
impl GetByID<BaseID, Base> for Bases {}
impl EnumerateByID<BaseID, Base> for Bases {}
#[inline(always)]
pub fn bases() -> &'static Bases {
&_bases
}
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_name = "base")]
static _base: Base;
}
#[inline(always)]
pub fn base() -> &'static Base {
&_base
}
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_name = "enemy_base")]
static _enemy_base: Base;
}
#[inline(always)]
pub fn enemy_base() -> &'static Base {
&_enemy_base
}