mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'src/logic/mod.rs')
| -rw-r--r-- | src/logic/mod.rs | 115 |
1 files changed, 55 insertions, 60 deletions
diff --git a/src/logic/mod.rs b/src/logic/mod.rs index b8a98fc..b5e7cc6 100644 --- a/src/logic/mod.rs +++ b/src/logic/mod.rs @@ -10,72 +10,67 @@ numeric_enum! { } } -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!( + pub const fn is_readable(self) -> bool { + use LogicField::{ + Ammo, AmmoCapacity, Boosting, Color, Controlled, Controller, Dead, Efficiency, Enabled, + FirstItem, Flag, Health, Heat, ItemCapacity, LiquidCapacity, MaxHealth, MineX, MineY, + Mining, Name, PayloadCount, PayloadType, PosX, PosY, PowerCapacity, PowerNetCapacity, + PowerNetIn, PowerNetOut, PowerNetStored, Progress, Range, Rotation, ShootX, ShootY, + Shooting, Size, Speed, Team, Timescale, TotalItems, TotalLiquids, TotalPower, Type, + }; + matches!( 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 + 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) + pub const fn is_writable(self) -> bool { + use LogicField::{Color, Config, Enabled, Shoot, ShootP}; + matches!(self, Enabled | Shoot | ShootP | Config | Color) } } |