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
use js_sys::JsString;
use wasm_bindgen::prelude::*;
use crate::{
objects::{RoomObject, Store, Structure},
prelude::*,
};
#[wasm_bindgen]
extern "C" {
/// A [`Ruin`], which represents a destroyed structure and can have
/// resources withdrawn from it.
///
/// [Screeps documentation](https://docs.screeps.com/api/#Ruin)
#[wasm_bindgen(extends = RoomObject)]
#[derive(Clone, Debug)]
pub type Ruin;
/// The tick that the structure was destroyed
///
/// [Screeps documentation](https://docs.screeps.com/api/#Ruin.destroyTime)
#[wasm_bindgen(method, getter = destroyTime)]
pub fn destroy_time(this: &Ruin) -> u32;
/// Object ID of the ruin, which can be used to efficiently fetch a fresh
/// reference to the object on subsequent ticks.
///
/// [Screeps documentation](https://docs.screeps.com/api/#Ruin.id)
#[wasm_bindgen(method, getter = id)]
fn id_internal(this: &Ruin) -> JsString;
/// The [`Store`] of the ruin, which contains any resources in the ruin.
///
/// [Screeps documentation](https://docs.screeps.com/api/#Ruin.store)
#[wasm_bindgen(method, getter)]
pub fn store(this: &Ruin) -> Store;
/// The destroyed [`Structure`] that this ruin represents. Note that this
/// object is not fully safe to use as a [`Structure`], missing critical
/// properties such as position; it's only safe to access basic information
/// about the structure on this object, like the structure type, owner name,
/// and id.
///
/// [Screeps documentation](https://docs.screeps.com/api/#Ruin.structure)
#[wasm_bindgen(method, getter)]
pub fn structure(this: &Ruin) -> Structure;
/// The number of ticks until this ruin disappears.
///
/// [Screeps documentation](https://docs.screeps.com/api/#Ruin.ticksToDecay)
#[wasm_bindgen(method, getter = ticksToDecay)]
pub fn ticks_to_decay(this: &Ruin) -> u32;
}
impl CanDecay for Ruin {
fn ticks_to_decay(&self) -> u32 {
Self::ticks_to_decay(self)
}
}
impl HasId for Ruin {
fn js_raw_id(&self) -> JsString {
Self::id_internal(self)
}
}
impl HasStore for Ruin {
fn store(&self) -> Store {
Self::store(self)
}
}
impl Withdrawable for Ruin {}