screeps/objects/impls/structure_container.rs
1use wasm_bindgen::prelude::*;
2
3use crate::{
4 objects::{RoomObject, Store, Structure},
5 prelude::*,
6};
7
8#[wasm_bindgen]
9extern "C" {
10 /// An object representing a [`StructureContainer`], which can store
11 /// resources and does not block creep movement, but requires regular repair
12 /// due to decay.
13 ///
14 /// [Screeps documentation](https://docs.screeps.com/api/#StructureContainer)
15 #[wasm_bindgen(extends = RoomObject, extends = Structure)]
16 #[derive(Clone, Debug)]
17 pub type StructureContainer;
18
19 /// The [`Store`] of the container, which contains information about what
20 /// resources it is it holding.
21 ///
22 /// [Screeps documentation](https://docs.screeps.com/api/#StructureContainer.store)
23 #[wasm_bindgen(method, getter)]
24 pub fn store(this: &StructureContainer) -> Store;
25
26 /// The number of ticks until the container will decay, losing
27 /// [`CONTAINER_DECAY`] hits. The time between each decay interval
28 /// depends whether the container is in an owned room;
29 /// [`CONTAINER_DECAY_TIME_OWNED`] in owned rooms and
30 /// [`CONTAINER_DECAY_TIME`] in all other rooms.
31 ///
32 /// [Screeps documentation](https://docs.screeps.com/api/#StructureContainer.ticksToDecay)
33 ///
34 /// [`CONTAINER_DECAY`]: crate::constants::CONTAINER_DECAY
35 /// [`CONTAINER_DECAY_TIME_OWNED`]: crate::constants::CONTAINER_DECAY_TIME_OWNED
36 /// [`CONTAINER_DECAY_TIME`]: crate::constants::CONTAINER_DECAY_TIME
37 #[wasm_bindgen(method, getter = ticksToDecay)]
38 pub fn ticks_to_decay(this: &StructureContainer) -> u32;
39}
40
41impl CanDecay for StructureContainer {
42 fn ticks_to_decay(&self) -> u32 {
43 Self::ticks_to_decay(self)
44 }
45}
46
47impl HasStore for StructureContainer {
48 fn store(&self) -> Store {
49 Self::store(self)
50 }
51}
52
53impl Attackable for StructureContainer {}
54impl Dismantleable for StructureContainer {}
55impl Repairable for StructureContainer {}
56impl Transferable for StructureContainer {}
57impl Withdrawable for StructureContainer {}