screeps/objects/impls/nuke.rs
1use js_sys::JsString;
2use wasm_bindgen::prelude::*;
3
4use crate::{objects::RoomObject, prelude::*};
5
6#[wasm_bindgen]
7extern "C" {
8 /// A [`Nuke`] in flight, which will deal damage in an area and kill all
9 /// creeps in the room when it lands.
10 ///
11 /// [Screeps documentation](https://docs.screeps.com/api/#Nuke)
12 #[wasm_bindgen(extends = RoomObject)]
13 #[derive(Clone, Debug)]
14 pub type Nuke;
15
16 /// Object ID of the Nuke, which can be used to efficiently fetch a fresh
17 /// reference to the object on subsequent ticks.
18 ///
19 /// [Screeps documentation](https://docs.screeps.com/api/#Nuke.id)
20 #[wasm_bindgen(method, getter = id)]
21 fn id_internal(this: &Nuke) -> JsString;
22
23 /// The name of the room the nuke was fired from.
24 ///
25 /// [Screeps documentation](https://docs.screeps.com/api/#Nuke.launchRoomName)
26 #[wasm_bindgen(method, getter)]
27 pub fn launch_room_name(this: &Nuke) -> JsString;
28
29 /// Ticks until the nuke lands.
30 ///
31 /// [Screeps documentation](https://docs.screeps.com/api/#Nuke.timeToLand)
32 #[wasm_bindgen(method, getter = timeToLand)]
33 pub fn time_to_land(this: &Nuke) -> u32;
34}
35
36impl HasId for Nuke {
37 fn js_raw_id(&self) -> JsString {
38 Self::id_internal(self)
39 }
40}