pub use bevy::ecs::{
entity::Entity,
system::{Command, SystemState},
world::World,
};
pub type EntityCallback = fn(Entity, &mut World);
#[derive(Clone, Copy)]
pub struct RunEntityCallback {
pub entity: Entity,
pub func: EntityCallback,
}
impl Command for RunEntityCallback {
fn apply(self, world: &mut World) {
(self.func)(self.entity, world)
}
}
#[macro_export]
macro_rules! moshi {
($($I:ident: $T:ty),* => $B:block) => {
|mut world: &mut World| {
let mut system_state: SystemState<($($T),*)> = SystemState::new(world);
#[allow(unused_mut)]
let ($(mut $I),*) = system_state.get_mut(&mut world);
$B
}
};
([$($LI:ident: $LT:ty),*], $($I:ident: $T:ty),* => $B:block) => {
|$($LI: $LT),*, mut world: &mut World| {
let mut system_state: SystemState<($($T),*)> = SystemState::new(world);
#[allow(unused_mut)]
let ($(mut $I),*) = system_state.get_mut(&mut world);
$B
}
};
}