diff --git a/CHANGELOG.md b/CHANGELOG.md index f2bb065..571b145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ -# UNRELEASED +# 0.7.0 +- Changed: Updated to Bevy `0.13`. - Changed: ***BREAKING*** `EntityEvent`s no longer bubble by default. - If you are using `#[derive(EntityEvent)]`, you will need to add the `#[can_bubble]` attribute to enable bubbling. - If you are manually implementing the trait, you will need to override the default `can_bubble` - trait method and return true. + trait method and return `true`. - Changed: dissolved the `bevy_eventlistener_core` crate. - Changed: `commands_mut`, `target_commands_mut`, `target_component_mut`, `listener_commands_mut`, and `listener_component_mut` have been changed to provide a mutable reference to diff --git a/Cargo.toml b/Cargo.toml index 9718526..a13f6d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ resolver = "2" [package] name = "bevy_eventlistener" -version = "0.6.2" +version = "0.7.0" edition = "2021" description = "Event listeners and callbacks for bevy" license = "MIT OR Apache-2.0" @@ -15,14 +15,14 @@ keywords = ["gamedev", "bevy", "eventlistener", "callbacks"] categories = ["game-engines", "rendering"] [dependencies] -bevy_eventlistener_derive = { path = "macros", version = "0.6.2" } -bevy_ecs = "0.12" -bevy_app = "0.12" -bevy_utils = "0.12" -bevy_hierarchy = "0.12" +bevy_eventlistener_derive = { path = "macros", version = "0.7.0" } +bevy_ecs = "0.13" +bevy_app = "0.13" +bevy_utils = "0.13" +bevy_hierarchy = "0.13" [dev-dependencies] -bevy = { version = "0.12", default-features = false, features = [ +bevy = { version = "0.13", default-features = false, features = [ "bevy_winit", "x11", ] } diff --git a/crates/macros/src/lib.rs b/crates/macros/src/lib.rs deleted file mode 100644 index 6cbe708..0000000 --- a/crates/macros/src/lib.rs +++ /dev/null @@ -1,48 +0,0 @@ -use proc_macro::TokenStream; -use quote::quote; - -#[proc_macro_derive(EntityEvent, attributes(target))] -pub fn derive(input: TokenStream) -> TokenStream { - let ast: syn::DeriveInput = syn::parse(input).unwrap(); - let name = &ast.ident; - let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); - - let mut target = None; - - match ast.data { - // Only process structs - syn::Data::Struct(ref data_struct) => { - // Check the kind of fields the struct contains - // Structs with named fields - if let syn::Fields::Named(ref fields_named) = data_struct.fields { - // Iterate over the fields - for field in fields_named.named.iter() { - // Get attributes #[..] on each field - for attr in field.attrs.iter() { - // Parse the attribute - match attr.meta { - // Find the duplicated idents - syn::Meta::Path(ref path) if path.get_ident().unwrap() == "target" => { - target = Some(field.ident.clone()); - } - _ => (), - } - } - } - } - } - // Panic when we don't have a struct - _ => panic!("Must be a struct"), - } - - let target = target.unwrap(); - - let gen = quote! { - impl #impl_generics EntityEvent for #name #ty_generics #where_clause { - fn target(&self) -> Entity { - self.#target - } - } - }; - gen.into() -} diff --git a/examples/event_listeners.rs b/examples/event_listeners.rs index 664dcf1..e697bf6 100644 --- a/examples/event_listeners.rs +++ b/examples/event_listeners.rs @@ -162,37 +162,51 @@ fn keyboard_events( for input in inputs .read() .filter(|input| !input.state.is_pressed()) - .filter_map(|input| input.key_code) + .map(|input| input.key_code) { match input { - KeyCode::Key1 => ev1.send(MyEvent { - target, - message: "Key 1".into(), - }), - KeyCode::Key2 => ev2.send(MyEvent { - target, - message: "Key 2".into(), - }), - KeyCode::Key3 => ev3.send(MyEvent { - target, - message: "Key 3".into(), - }), - KeyCode::Key4 => ev4.send(MyEvent { - target, - message: "Key 4".into(), - }), - KeyCode::Key5 => ev5.send(MyEvent { - target, - message: "Key 5".into(), - }), - KeyCode::Key6 => ev6.send(MyEvent { - target, - message: "Key 6".into(), - }), - KeyCode::Key7 => ev7.send(MyEvent { - target, - message: "Key 7".into(), - }), + KeyCode::Digit1 => { + ev1.send(MyEvent { + target, + message: "Key 1".into(), + }); + } + KeyCode::Digit2 => { + ev2.send(MyEvent { + target, + message: "Key 2".into(), + }); + } + KeyCode::Digit3 => { + ev3.send(MyEvent { + target, + message: "Key 3".into(), + }); + } + KeyCode::Digit4 => { + ev4.send(MyEvent { + target, + message: "Key 4".into(), + }); + } + KeyCode::Digit5 => { + ev5.send(MyEvent { + target, + message: "Key 5".into(), + }); + } + KeyCode::Digit6 => { + ev6.send(MyEvent { + target, + message: "Key 6".into(), + }); + } + KeyCode::Digit7 => { + ev7.send(MyEvent { + target, + message: "Key 7".into(), + }); + } _ => (), } } diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 9e36444..f646ef0 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_eventlistener_derive" -version = "0.6.2" +version = "0.7.0" edition = "2021" description = "Event listeners and callbacks for bevy" license = "MIT OR Apache-2.0" diff --git a/src/callbacks.rs b/src/callbacks.rs index ae4de81..9dc1faf 100644 --- a/src/callbacks.rs +++ b/src/callbacks.rs @@ -57,7 +57,7 @@ pub type ListenerMut<'w, E> = ResMut<'w, ListenerInput>; /// callback systems. /// /// ``` -/// # use bevy_eventlistener_core::{callbacks::ListenerMut, event_listener::EntityEvent}; +/// # use bevy_eventlistener::prelude::{ListenerMut, EntityEvent}; /// # use bevy_ecs::prelude::*; /// # #[derive(Clone, Event)] /// # struct MyEvent { diff --git a/src/lib.rs b/src/lib.rs index 68f7797..a83af15 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -115,7 +115,7 @@ fn replace_listener() { app.add_plugins(MinimalPlugins) .add_plugins(EventListenerPlugin::::default()) .add_systems(Update, move |mut event: EventWriter| { - event.send(Foo { target: entity }) + event.send(Foo { target: entity }); }) .update(); @@ -151,7 +151,7 @@ fn replace_listener_in_callback() { app.add_plugins(MinimalPlugins) .add_plugins(EventListenerPlugin::::default()) .add_systems(Update, move |mut event: EventWriter| { - event.send(Foo { target: entity }) + event.send(Foo { target: entity }); }) .update();