screeps/objects/impls/
structure_lab.rs1use wasm_bindgen::prelude::*;
2
3use crate::{
4    constants::ResourceType,
5    enums::action_error_codes::structure_lab::*,
6    objects::{Creep, OwnedStructure, RoomObject, Store, Structure},
7    prelude::*,
8};
9
10#[wasm_bindgen]
11extern "C" {
12    #[wasm_bindgen(extends = RoomObject, extends = Structure, extends = OwnedStructure)]
17    #[derive(Clone, Debug)]
18    pub type StructureLab;
19
20    #[wasm_bindgen(method, getter)]
25    pub fn cooldown(this: &StructureLab) -> u32;
26
27    #[wasm_bindgen(method, getter)]
32    pub fn store(this: &StructureLab) -> Store;
33
34    #[wasm_bindgen(method, getter = mineralType)]
39    pub fn mineral_type(this: &StructureLab) -> Option<ResourceType>;
40
41    #[wasm_bindgen(method, js_name = boostCreep)]
42    fn boost_creep_internal(this: &StructureLab, creep: &Creep, body_part_count: Option<u32>)
43        -> i8;
44
45    #[wasm_bindgen(method, js_name = reverseReaction)]
46    fn reverse_reaction_internal(
47        this: &StructureLab,
48        lab1: &StructureLab,
49        lab2: &StructureLab,
50    ) -> i8;
51
52    #[wasm_bindgen(method, js_name = runReaction)]
53    fn run_reaction_internal(this: &StructureLab, lab1: &StructureLab, lab2: &StructureLab) -> i8;
54
55    #[wasm_bindgen(method, js_name = unboostCreep)]
56    fn unboost_creep_internal(this: &StructureLab, creep: &Creep) -> i8;
57}
58
59impl StructureLab {
60    pub fn boost_creep(
69        &self,
70        creep: &Creep,
71        body_part_count: Option<u32>,
72    ) -> Result<(), BoostCreepErrorCode> {
73        BoostCreepErrorCode::result_from_i8(self.boost_creep_internal(creep, body_part_count))
74    }
75
76    pub fn reverse_reaction(
81        &self,
82        lab1: &StructureLab,
83        lab2: &StructureLab,
84    ) -> Result<(), ReverseReactionErrorCode> {
85        ReverseReactionErrorCode::result_from_i8(self.reverse_reaction_internal(lab1, lab2))
86    }
87
88    pub fn run_reaction(
93        &self,
94        lab1: &StructureLab,
95        lab2: &StructureLab,
96    ) -> Result<(), RunReactionErrorCode> {
97        RunReactionErrorCode::result_from_i8(self.run_reaction_internal(lab1, lab2))
98    }
99
100    pub fn unboost_creep(&self, creep: &Creep) -> Result<(), UnboostCreepErrorCode> {
108        UnboostCreepErrorCode::result_from_i8(self.unboost_creep_internal(creep))
109    }
110}
111
112impl HasCooldown for StructureLab {
113    fn cooldown(&self) -> u32 {
114        Self::cooldown(self)
115    }
116}
117
118impl HasStore for StructureLab {
119    fn store(&self) -> Store {
120        Self::store(self)
121    }
122}
123
124impl Attackable for StructureLab {}
125impl Dismantleable for StructureLab {}
126impl Repairable for StructureLab {}
127impl Transferable for StructureLab {}
128impl Withdrawable for StructureLab {}