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