diff --git a/src/effect.rs b/src/effect.rs index 3586031..b847afd 100644 --- a/src/effect.rs +++ b/src/effect.rs @@ -1,6 +1,4 @@ use bevy::ecs::system::SystemParam; -use bevy::prelude::*; -use variadics_please::all_tuples; /// Define a state transition in `bevy`'s ECS. /// @@ -14,19 +12,3 @@ pub trait Effect { /// Perform the state transition on the parameter. fn affect(self, param: &mut ::Item<'_, '_>); } - -macro_rules! impl_effect { - ($(($E:ident, $e:ident, $p:ident)),*) => { - impl<$($E),*> Effect for ($($E,)*) - where $($E: Effect,)* { - type MutParam = ParamSet<'static, 'static, ($(<$E as Effect>::MutParam,)*)>; - - fn affect(self, param: &mut ::Item<'_, '_>) { - let ($($e,)*) = self; - $($e.affect(&mut param.$p());)* - } - } - }; -} - -all_tuples!(impl_effect, 1, 8, E, e, p); diff --git a/src/effects/mod.rs b/src/effects/mod.rs index bc71038..5d8b496 100644 --- a/src/effects/mod.rs +++ b/src/effects/mod.rs @@ -17,6 +17,8 @@ pub use entity_components::{EntityComponentsPut, EntityComponentsWith}; mod command; pub use command::{CommandInsertResource, CommandQueue, CommandRemoveResource}; +mod variadic; + #[cfg(test)] mod one_way_fn; diff --git a/src/effects/variadic.rs b/src/effects/variadic.rs new file mode 100644 index 0000000..a162f49 --- /dev/null +++ b/src/effects/variadic.rs @@ -0,0 +1,23 @@ +//! Implements [`Effect`] for tuples of effects up to size 8. + +use bevy::ecs::system::SystemParam; +use bevy::prelude::*; +use variadics_please::all_tuples; + +use crate::Effect; + +macro_rules! impl_effect { + ($(($E:ident, $e:ident, $p:ident)),*) => { + impl<$($E),*> Effect for ($($E,)*) + where $($E: Effect,)* { + type MutParam = ParamSet<'static, 'static, ($(<$E as Effect>::MutParam,)*)>; + + fn affect(self, param: &mut ::Item<'_, '_>) { + let ($($e,)*) = self; + $($e.affect(&mut param.$p());)* + } + } + }; +} + +all_tuples!(impl_effect, 1, 8, E, e, p);