diff options
| author | Dominik Kaiser | 2026-06-02 23:23:57 +0200 |
|---|---|---|
| committer | Dominik Kaiser | 2026-06-02 23:23:57 +0200 |
| commit | 4632dd8e9e95a377993ef677a157202fda8072f9 (patch) | |
| tree | 60990f769556109c98e697c72dac1ad92f774d0f /src/bundle.rs | |
| download | ecs-4632dd8e9e95a377993ef677a157202fda8072f9.tar.gz ecs-4632dd8e9e95a377993ef677a157202fda8072f9.zip | |
Diffstat (limited to 'src/bundle.rs')
| -rw-r--r-- | src/bundle.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/bundle.rs b/src/bundle.rs new file mode 100644 index 0000000..08753a7 --- /dev/null +++ b/src/bundle.rs @@ -0,0 +1,34 @@ +use super::Entity; +use super::component::{Component, ComponentStorage}; + +pub trait ComponentBundle<W> { + fn insert(self, world: &mut W, entity: Entity); +} + +macro_rules! impl_bundle_tuple { + ($($T:ident),+) => { + impl<W, $($T),+> ComponentBundle<W> for ($($T,)+) + where + $( + $T: Component, + W: ComponentStorage<$T>, + )+ + { + #[allow(non_snake_case)] + fn insert(self, world: &mut W, entity: Entity) { + let ($($T,)+) = self; + + $( + world.insert(entity, $T); + )+ + } + } + }; +} + +impl_bundle_tuple!(A); +impl_bundle_tuple!(A, B); +impl_bundle_tuple!(A, B, C); +impl_bundle_tuple!(A, B, C, D); +impl_bundle_tuple!(A, B, C, D, E); +impl_bundle_tuple!(A, B, C, D, E, F); |
