bevy_sequential_actions/macros.rs
1/// Helper macro for creating an array of boxed actions.
2///
3/// ```rust,no_run
4/// # use bevy_ecs::prelude::*;
5/// # use bevy_sequential_actions::*;
6/// #
7/// # struct EmptyAction;
8/// # impl Action for EmptyAction {
9/// # fn is_finished(&self, _a: Entity, _w: &World) -> bool { true }
10/// # fn on_start(&mut self, _a: Entity, _w: &mut World) -> bool { true }
11/// # fn on_stop(&mut self, _a: Option<Entity>, _w: &mut World, _r: StopReason) {}
12/// # }
13/// #
14/// # let action_a = EmptyAction;
15/// # let action_b = EmptyAction;
16/// #
17/// let actions: [Box<dyn Action>; 3] = actions![
18/// action_a,
19/// action_b,
20/// |agent: Entity, world: &mut World| -> bool {
21/// // on_start
22/// true
23/// },
24/// ];
25/// ```
26#[macro_export]
27macro_rules! actions {
28 ( $( $action:expr ),+ $(,)? ) => {
29 [ $( $crate::IntoBoxedAction::into_boxed_action($action) ),+ ]
30 }
31}