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
use wasm_bindgen::prelude::*;

use crate::{
    objects::{RoomObject, Structure},
    prelude::*,
};

#[wasm_bindgen]
extern "C" {
    /// An object representing a [`StructureRoad`], which allows creeps to move
    /// onto this position for half of the fatigue of moving onto a plains tile,
    /// as well as through terrain walls.
    ///
    /// [Screeps documentation](https://docs.screeps.com/api/#StructureRoad)
    #[wasm_bindgen(extends = RoomObject, extends = Structure)]
    #[derive(Clone, Debug)]
    pub type StructureRoad;

    /// The number of ticks until the road will decay, losing
    /// [`ROAD_DECAY_AMOUNT`] hits.
    ///
    /// [Screeps documentation](https://docs.screeps.com/api/#StructureRoad.ticksToDecay)
    ///
    /// [`ROAD_DECAY_AMOUNT`]: crate::constants::ROAD_DECAY_AMOUNT
    #[wasm_bindgen(method, getter = ticksToDecay)]
    pub fn ticks_to_decay(this: &StructureRoad) -> u32;
}

impl CanDecay for StructureRoad {
    fn ticks_to_decay(&self) -> u32 {
        Self::ticks_to_decay(self)
    }
}