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
use wasm_bindgen::prelude::*;
use crate::{
enums::action_error_codes::structure_nuker::*,
objects::{OwnedStructure, RoomObject, RoomPosition, Store, Structure},
prelude::*,
};
#[wasm_bindgen]
extern "C" {
/// An object representing a [`StructureNuker`], which consumes energy and
/// ghodium to fire [`Nuke`]s.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructureNuker)
///
/// [`Nuke`]: crate::objects::Nuke
#[wasm_bindgen(extends = RoomObject, extends = Structure, extends = OwnedStructure)]
#[derive(Clone, Debug)]
pub type StructureNuker;
/// The number of ticks until the [`StructureNuker`] can use
/// [`StructureNuker::launch_nuke`] again.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructureNuker.cooldown)
#[wasm_bindgen(method, getter)]
pub fn cooldown(this: &StructureNuker) -> u32;
/// The [`Store`] of the nuker, which can have energy and ghodium
/// transferred in (but not withdrawn).
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructureNuker.store)
#[wasm_bindgen(method, getter)]
pub fn store(this: &StructureNuker) -> Store;
#[wasm_bindgen(method, js_name = launchNuke)]
fn launch_nuke_internal(this: &StructureNuker, target: &RoomPosition) -> i8;
}
impl StructureNuker {
/// Launch a nuke at a target [`RoomPosition`].
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructureNuker.launchNuke)
pub fn launch_nuke(&self, target: &RoomPosition) -> Result<(), LaunchNukeErrorCode> {
LaunchNukeErrorCode::result_from_i8(self.launch_nuke_internal(target))
}
}
impl HasCooldown for StructureNuker {
fn cooldown(&self) -> u32 {
Self::cooldown(self)
}
}
impl HasStore for StructureNuker {
fn store(&self) -> Store {
Self::store(self)
}
}
impl Attackable for StructureNuker {}
impl Dismantleable for StructureNuker {}
impl Repairable for StructureNuker {}
impl Transferable for StructureNuker {}