From 4632dd8e9e95a377993ef677a157202fda8072f9 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Tue, 2 Jun 2026 23:23:57 +0200 Subject: Implement ECS --- src/bundle.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/bundle.rs (limited to 'src/bundle.rs') 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 { + fn insert(self, world: &mut W, entity: Entity); +} + +macro_rules! impl_bundle_tuple { + ($($T:ident),+) => { + impl ComponentBundle 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); -- cgit v1.2.3