mindustry logic execution, map- and schematic- parsing and rendering
add list
bendn 2024-11-23
parent 9770ef4 · commit 9a45772
-rw-r--r--mindus/src/content.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/mindus/src/content.rs b/mindus/src/content.rs
index 6c2872c..13cc5eb 100644
--- a/mindus/src/content.rs
+++ b/mindus/src/content.rs
@@ -42,6 +42,20 @@ macro_rules! numeric_enum {
pub(crate) use numeric_enum;
+macro_rules! count_exprs {
+ ($($e:expr)*) => {
+ $($crate::content::one!($e) +)* 0
+ }
+}
+
+macro_rules! one {
+ ($e:expr) => {
+ 1
+ };
+}
+pub(crate) use count_exprs;
+pub(crate) use one;
+
macro_rules! content_enum {
($vis:vis enum $tname:ident / $ctype:ident for u16 | $error:ident {$($val:literal),* $(,)?}) =>
{
@@ -50,6 +64,10 @@ macro_rules! content_enum {
$([<$val:camel>]),*,
});
+ impl $tname {
+ pub const ALL: [Self; $crate::content::count_exprs!($($val)+)] = [$(Self::[<$val:camel>]),+];
+ }
+
impl $crate::content::Content for $tname {
fn get_type(&self) -> $crate::content::Type {
$crate::content::Type::$ctype