summaryrefslogtreecommitdiff
path: root/src/bundle.rs
diff options
context:
space:
mode:
authorDominik Kaiser2026-06-02 23:23:57 +0200
committerDominik Kaiser2026-06-02 23:23:57 +0200
commit4632dd8e9e95a377993ef677a157202fda8072f9 (patch)
tree60990f769556109c98e697c72dac1ad92f774d0f /src/bundle.rs
downloadecs-main.tar.gz
ecs-main.zip
Implement ECSHEADmain
Diffstat (limited to 'src/bundle.rs')
-rw-r--r--src/bundle.rs34
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);