diff options
| author | HampusM <hampus@hampusmat.com> | 2026-09-20 19:05:03 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-09-20 19:05:03 +0200 |
| commit | fd28c16e6455aeff206543b1d1b6655729aaed07 (patch) | |
| tree | b606fe2ce433abd20116fa553ceedb027ea18cd1 /engine-ecs/src/bundle.rs | |
| parent | bc1aab63bae307fab30d5c04d947ff95ead9eb0f (diff) | |
refactor(engine-ecs): move & rename component::Sequence to bundle::Bundle
Diffstat (limited to 'engine-ecs/src/bundle.rs')
| -rw-r--r-- | engine-ecs/src/bundle.rs | 40 |
1 files changed, 40 insertions, 0 deletions
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<Parts>; + + 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); +}); |
