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
use js_sys::JsString;
use wasm_bindgen::prelude::*;
use crate::{
objects::{Owner, RoomObject, Store},
prelude::*,
};
#[wasm_bindgen]
extern "C" {
/// An object representing a [`Reactor`], which process [`Thorium`] to gain
/// season score.
///
/// [Screeps documentation](https://docs-season.screeps.com/api/#Reactor)
///
/// [`Thorium`]: crate::constants::ResourceType::Thorium
#[wasm_bindgen(extends = RoomObject)]
#[derive(Clone, Debug)]
pub type Reactor;
#[wasm_bindgen(method, getter = id)]
fn id_internal(this: &Reactor) -> JsString;
/// Ticks of continuous work this reactor has done.
///
/// [Screeps documentation](https://docs-season.screeps.com/api/#Reactor.continuousWork)
#[wasm_bindgen(method, getter = continuousWork)]
pub fn continuous_work(this: &Reactor) -> u32;
/// The [`Store`] of the reactor, which contains information about what
/// [`Thorium`] it is it holding.
///
/// [Screeps documentation](https://docs-season.screeps.com/api/#Reactor.store)
///
/// [`Thorium`]: crate::constants::ResourceType::Thorium
#[wasm_bindgen(method, getter)]
pub fn store(this: &Reactor) -> Store;
// owner and my are on OwnedStructure and we'd usually inherit them, but since
// it inherits Structure, and Reactor is not a Structure, implementing these
// directly.
/// Whether this reactor is owned by the player.
///
/// [Screeps documentation](https://docs-season.screeps.com/api/#Reactor.my)
#[wasm_bindgen(method, getter)]
pub fn my(this: &Reactor) -> bool;
/// The [`Owner`] of this reactor that contains the owner's username, or
/// `None` if it's currently not under a player's
/// control.
///
/// [Screeps documentation](https://docs-season.screeps.com/api/#Reactor.owner)
#[wasm_bindgen(method, getter)]
pub fn owner(this: &Reactor) -> Option<Owner>;
}
impl HasNativeId for Reactor {
fn native_id(&self) -> JsString {
Self::id_internal(self)
}
}
impl HasStore for Reactor {
fn store(&self) -> Store {
Self::store(self)
}
}