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_powerspawn::*,
objects::{OwnedStructure, RoomObject, Store, Structure},
prelude::*,
};
#[wasm_bindgen]
extern "C" {
/// An object representing a [`StructurePowerSpawn`], which can process
/// power to contribute to your GPL as well as renewing power creeps.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructurePowerSpawn)
#[wasm_bindgen(extends = RoomObject, extends = Structure, extends = OwnedStructure)]
#[derive(Clone, Debug)]
pub type StructurePowerSpawn;
/// The [`Store`] of the power spawn, which can contain power and energy.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructurePowerSpawn.store)
#[wasm_bindgen(method, getter)]
pub fn store(this: &StructurePowerSpawn) -> Store;
/// Process power, consuming 1 power and [`POWER_SPAWN_ENERGY_RATIO`] energy
/// and increasing your GPL by one point.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructurePowerSpawn.processPower)
///
/// [`POWER_SPAWN_ENERGY_RATIO`]:
/// crate::constants::numbers::POWER_SPAWN_ENERGY_RATIO
#[wasm_bindgen(method, js_name = processPower)]
fn process_power_internal(this: &StructurePowerSpawn) -> i8;
}
impl StructurePowerSpawn {
/// Process power, consuming 1 power and [`POWER_SPAWN_ENERGY_RATIO`] energy
/// and increasing your GPL by one point.
///
/// [Screeps documentation](https://docs.screeps.com/api/#StructurePowerSpawn.processPower)
///
/// [`POWER_SPAWN_ENERGY_RATIO`]: crate::constants::POWER_SPAWN_ENERGY_RATIO
pub fn process_power(&self) -> Result<(), ProcessPowerErrorCode> {
ProcessPowerErrorCode::result_from_i8(self.process_power_internal())
}
}
impl HasStore for StructurePowerSpawn {
fn store(&self) -> Store {
Self::store(self)
}
}
impl Attackable for StructurePowerSpawn {}
impl Dismantleable for StructurePowerSpawn {}
impl Repairable for StructurePowerSpawn {}
impl Transferable for StructurePowerSpawn {}
impl Withdrawable for StructurePowerSpawn {}