Skip to main content

mindus/block/
production.rs

1//! the industry part of mindustry
2use crate::block::simple::*;
3use crate::block::*;
4use crate::data::DataRead;
5
6// format: call [`read_production_block`], seed: [`i32`]
7make_simple!(SeparatorBlock => |_, buff: &mut DataRead| buff.skip(12));
8
9make_simple!(
10    ProductionBlock,
11    |_, _, _, _, r: Rotation, s| {
12        // electrolyzer exclusive
13        // ozone <- e(^) -> hydrogen
14        let mut base = load!("electrolyzer", s);
15        let mut hydro = load!(s -> match r {
16            Rotation::Up | Rotation::Left => "electrolyzer-hydrogen-output1"
17            Rotation::Down | Rotation::Right => "electrolyzer-hydrogen-output2"
18        });
19        unsafe { hydro.rotate(r.count()) };
20        unsafe { base.overlay(&hydro) };
21
22        let mut ozone = load!(s -> match r {
23            Rotation::Down | Rotation::Right => "electrolyzer-ozone-output1"
24            Rotation::Up | Rotation::Left => "electrolyzer-ozone-output2"
25        });
26        unsafe { ozone.rotate(r.mirrored(true, true).count()) };
27        unsafe { base.overlay(&ozone) };
28        base
29    },
30    |b: &mut Build, buff: &mut DataRead| {
31        // format:
32        // - progress: `f32`
33        // - warmup: `f32`
34        // (cultivator)
35        // `f32`
36        buff.skip(8 + if b.name() == "cultivator" { 4 } else { 0 })
37    }
38);
39
40make_simple!(
41    HeatCrafter,
42    |_, n, _, _, r: Rotation, s| {
43        let mut base = load!(from n which is ["phase-heater" | "electric-heater" | "oxidation-chamber" | "slag-heater" | "heat-source" | "heat-reactor"], s);
44        let mut top = match r {
45            Rotation::Up | Rotation::Right => {
46                load!(concat "top1" => n which is ["phase-heater" | "electric-heater" | "oxidation-chamber" | "slag-heater" | "heat-source" | "heat-reactor"], s)
47            }
48            Rotation::Down | Rotation::Left => {
49                load!(concat "top2" => n which is ["phase-heater" | "electric-heater" | "oxidation-chamber" | "slag-heater" | "heat-source" | "heat-reactor"], s)
50            }
51        };
52        unsafe { top.rotate(r.rotated(false).count()) };
53        unsafe { base.overlay(&top) };
54        base
55    },
56    |_, buff: &mut DataRead| {
57        // format:
58        // - progress: `f32`
59        // - warmup: `f32`
60        // - heat: f32
61        buff.skip(12)?;
62        Ok(())
63    }
64);
65make_simple!(HeatConduit, |_, n, _, _, r: Rotation, s| {
66    let mut base =
67        load!(from n which is ["heat-router" | "heat-redirector" | "small-heat-redirector"], s);
68    if n == "heat-router" {
69        let t1 = load!("heat-router-top1", s);
70        let t2 = load!("heat-router-top2", s);
71        let x = |n| unsafe {
72            match n {
73                Rotation::Up => t1.clone().rotated(3),
74                Rotation::Right => t1.clone(),
75                Rotation::Down => t2.clone().rotated(1),
76                Rotation::Left => t2.clone().rotated(2),
77            }
78        };
79        unsafe {
80            base.overlay(&x(r.rotated(false)));
81            base.overlay(&x(r));
82            base.overlay(&x(r.rotated(true)));
83        }
84        base
85    } else {
86        let mut top = match r {
87            Rotation::Up | Rotation::Right => {
88                load!(concat "top1" => n which is ["heat-router" | "heat-redirector" | "small-heat-redirector"], s)
89            }
90            Rotation::Down | Rotation::Left => {
91                load!(concat "top2" => n which is ["heat-router" | "heat-redirector" | "small-heat-redirector"], s)
92            }
93        };
94        unsafe { top.rotate(r.rotated(false).count()) };
95        unsafe { base.overlay(&top) };
96        base
97    }
98});