mindustry logic execution, map- and schematic- parsing and rendering
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! the industry part of mindustry
use crate::block::simple::*;
use crate::block::*;
use crate::data::DataRead;

// format: call [`read_production_block`], seed: [`i32`]
make_simple!(SeparatorBlock => |_, buff: &mut DataRead| buff.skip(12));

make_simple!(
    ProductionBlock,
    |_, _, _, _, r: Rotation, s| {
        // electrolyzer exclusive
        // ozone <- e(^) -> hydrogen
        let mut base = load!("electrolyzer", s);
        let mut hydro = load!(s -> match r {
            Rotation::Up | Rotation::Left => "electrolyzer-hydrogen-output1"
            Rotation::Down | Rotation::Right => "electrolyzer-hydrogen-output2"
        });
        unsafe { hydro.rotate(r.count()) };
        unsafe { base.overlay(&hydro) };

        let mut ozone = load!(s -> match r {
            Rotation::Down | Rotation::Right => "electrolyzer-ozone-output1"
            Rotation::Up | Rotation::Left => "electrolyzer-ozone-output2"
        });
        unsafe { ozone.rotate(r.mirrored(true, true).count()) };
        unsafe { base.overlay(&ozone) };
        base
    },
    |b: &mut Build<'_>, buff: &mut DataRead| {
        // format:
        // - progress: `f32`
        // - warmup: `f32`
        // (cultivator)
        // `f32`
        buff.skip(8 + if b.name() == "cultivator" { 4 } else { 0 })
    }
);

make_simple!(
    HeatCrafter,
    |_, n, _, _, r: Rotation, s| {
        let mut base = load!(from n which is ["phase-heater" | "electric-heater" | "oxidation-chamber" | "slag-heater" | "heat-source"], s);
        let mut top = match r {
            Rotation::Up | Rotation::Right => {
                load!(concat "top1" => n which is ["phase-heater" | "electric-heater" | "oxidation-chamber" | "slag-heater" | "heat-source"], s)
            }
            Rotation::Down | Rotation::Left => {
                load!(concat "top2" => n which is ["phase-heater" | "electric-heater" | "oxidation-chamber" | "slag-heater" | "heat-source"], s)
            }
        };
        unsafe { top.rotate(r.rotated(false).count()) };
        unsafe { base.overlay(&top) };
        base
    },
    |_, buff: &mut DataRead| {
        // format:
        // - progress: `f32`
        // - warmup: `f32`
        // - heat: f32
        buff.skip(12)?;
        Ok(())
    }
);
make_simple!(HeatConduit, |_, n, _, _, r: Rotation, s| {
    let mut base = load!(from n which is ["heat-router" | "heat-redirector"], s);
    let mut top = match r {
        Rotation::Up | Rotation::Right => {
            load!(concat "top1" => n which is ["heat-router" | "heat-redirector"], s)
        }
        Rotation::Down | Rotation::Left => {
            load!(concat "top2" => n which is ["heat-router" | "heat-redirector"], s)
        }
    };
    unsafe { top.rotate(r.rotated(false).count()) };
    unsafe { base.overlay(&top) };
    base
});