From fd28c16e6455aeff206543b1d1b6655729aaed07 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 20 Sep 2026 19:05:03 +0200 Subject: refactor(engine-ecs): move & rename component::Sequence to bundle::Bundle --- engine-ecs/src/bundle.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 engine-ecs/src/bundle.rs (limited to 'engine-ecs/src/bundle.rs') diff --git a/engine-ecs/src/bundle.rs b/engine-ecs/src/bundle.rs new file mode 100644 index 0000000..89e0cc4 --- /dev/null +++ b/engine-ecs/src/bundle.rs @@ -0,0 +1,40 @@ +use seq_macro::seq; + +use crate::component::{IntoParts, Parts}; +use crate::util::Array; + +pub trait Bundle +{ + type PartsArray: Array; + + fn cnt(&self) -> usize; + + fn into_parts_array(self) -> Self::PartsArray; +} + +macro_rules! gen_tuple_impls { + ($c: tt) => { + seq!(I in 0..$c { + impl<#(IntoCompParts~I: IntoParts,)*> Bundle for (#(IntoCompParts~I,)*) + { + type PartsArray = [Parts; $c]; + + fn cnt(&self) -> usize + { + $c + } + + fn into_parts_array(self) -> Self::PartsArray + { + [#({ + self.I.into_parts() + },)*] + } + } + }); + }; +} + +seq!(C in 0..17 { + gen_tuple_impls!(C); +}); -- cgit v1.2.3-18-g5258