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
use wasm_bindgen::prelude::*;
use crate::{
enums::action_error_codes::structure_rampart::*,
objects::{OwnedStructure, RoomObject, Structure},
prelude::*,
};
#[wasm_bindgen]
extern "C" {
/// An object representing a [`StructureRampart`], which is selectively
/// walkable and protects creeps and structures at the same position.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructureRampart)
#[wasm_bindgen(extends = RoomObject, extends = Structure, extends = OwnedStructure)]
#[derive(Clone, Debug)]
pub type StructureRampart;
/// Whether the [`StructureRampart`] is set to be public, allowing hostile
/// creeps to walk on it.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructureRampart.isPublic)
#[wasm_bindgen(method, getter = isPublic)]
pub fn is_public(this: &StructureRampart) -> bool;
/// The number of ticks until the rampart will decay, losing
/// [`RAMPART_DECAY_AMOUNT`] hits.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructureRampart.ticksToDecay)
///
/// [`RAMPART_DECAY_AMOUNT`]:
/// crate::constants::numbers::RAMPART_DECAY_AMOUNT
#[wasm_bindgen(method, getter = ticksToDecay)]
pub fn ticks_to_decay(this: &StructureRampart) -> u32;
#[wasm_bindgen(method, js_name = setPublic)]
fn set_public_internal(this: &StructureRampart, val: bool) -> i8;
}
impl StructureRampart {
/// Set whether [`StructureRampart`] is public, allowing hostile creeps to
/// walk on it.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructureRampart.setPublic)
pub fn set_public(&self, public: bool) -> Result<(), SetPublicErrorCode> {
SetPublicErrorCode::result_from_i8(self.set_public_internal(public))
}
}
impl CanDecay for StructureRampart {
fn ticks_to_decay(&self) -> u32 {
Self::ticks_to_decay(self)
}
}
impl Attackable for StructureRampart {}
impl Dismantleable for StructureRampart {}
impl Repairable for StructureRampart {}