1use core::marker::PhantomData;
2
3use bevy_app::{App, Plugin};
4use bevy_ecs::prelude::Entity;
5use bevy_reflect::TypeUuid;
6
7pub trait Action:
11 Sized
12 + Clone
13 + std::fmt::Debug
14 + PartialEq
15 + Eq
16 + std::hash::Hash
17 + Send
18 + Sync
19 + 'static
20 + Default
21 + TypeUuid
22{
23}
24
25#[derive(Clone, Debug)]
27pub struct ActionEvent<T: Action> {
28 pub action: T,
29 pub entity: Entity,
30}
31
32#[derive(Default)]
34pub struct ActionPlugin<T: Action>(PhantomData<T>);
35
36impl<T: Action> Plugin for ActionPlugin<T> {
37 fn build(&self, app: &mut App) {
38 app.add_event::<ActionEvent<T>>();
39 }
40}