bevy_input_sequence/
action.rs1use bevy::ecs::{
3 event::{Event, EventWriter},
4 observer::TriggerTargets,
5 prelude::Commands,
6 system::In,
7};
8
9pub fn send_event<E: Event + Clone>(event: E) -> impl FnMut(EventWriter<E>) {
25 move |mut writer: EventWriter<E>| {
26 writer.write(event.clone());
27 }
28}
29
30pub fn trigger<E: Event + Clone>(event: E) -> impl FnMut(Commands) {
32 move |mut commands: Commands| {
33 commands.trigger(event.clone());
34 }
35}
36
37pub fn trigger_targets<E: Event + Clone, T: TriggerTargets + Clone + Send + Sync + 'static>(
39 event: E,
40 targets: T,
41) -> impl FnMut(Commands) {
42 move |mut commands: Commands| {
43 commands.trigger_targets(event.clone(), targets.clone());
44 }
45}
46
47pub fn send_event_with_input<E: Event, Input: 'static, F: FnMut(Input) -> E>(
49 mut f: F,
50) -> impl FnMut(In<Input>, EventWriter<E>) {
51 move |In(x), mut writer: EventWriter<E>| {
52 writer.write(f(x));
53 }
54}