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
79
use crate::content::numeric_enum;

numeric_enum! {
    pub enum LogicField for u8 | TryFromU8Error
    {
        TotalItems, FirstItem, TotalLiquids, TotalPower, ItemCapacity, LiquidCapacity, PowerCapacity, PowerNetCapacity, PowerNetStored, PowerNetIn,
        PowerNetOut, Ammo, AmmoCapacity, Health, MaxHealth, Heat, Efficiency, Progress, Timescale, Rotation, PosX, PosY, ShootX, ShootY, Size, Dead, Range,
        Shooting, Boosting, MineX, MineY, Mining, Speed, Team, Type, Flag, Controlled, Controller, Name, PayloadCount, PayloadType, Enabled, Shoot, ShootP,
        Config, Color
    }
}

macro_rules!match_select
{
	($val:expr, $base:ty, $($name:ident),+) =>
	{
		match $val
		{
			$(<$base>::$name => true,)+
			_ => false,
		}
	};
}

impl LogicField {
    #[must_use] pub fn is_readable(&self) -> bool {
        match_select!(
            self,
            LogicField,
            TotalItems,
            FirstItem,
            TotalLiquids,
            TotalPower,
            ItemCapacity,
            LiquidCapacity,
            PowerCapacity,
            PowerNetCapacity,
            PowerNetStored,
            PowerNetIn,
            PowerNetOut,
            Ammo,
            AmmoCapacity,
            Health,
            MaxHealth,
            Heat,
            Efficiency,
            Progress,
            Timescale,
            Rotation,
            PosX,
            PosY,
            ShootX,
            ShootY,
            Size,
            Dead,
            Range,
            Shooting,
            Boosting,
            MineX,
            MineY,
            Mining,
            Speed,
            Team,
            Type,
            Flag,
            Controlled,
            Controller,
            Name,
            PayloadCount,
            PayloadType,
            Enabled,
            Color
        )
    }

    #[must_use] pub fn is_writable(&self) -> bool {
        match_select!(self, LogicField, Enabled, Shoot, ShootP, Config, Color)
    }
}