Skip to content

Commit

Permalink
Merge pull request #1 from aevyrie/plugin-adds-event
Browse files Browse the repository at this point in the history
Make `EventListenerPlugin` add bevy event
  • Loading branch information
aevyrie committed Jul 4, 2023
2 parents 12c2648 + 21e3382 commit 38b4b8a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 2 additions & 1 deletion crates/bevy_eventlistener_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ impl<E> Default for EventListenerPlugin<E> {

impl<E: EntityEvent> Plugin for EventListenerPlugin<E> {
fn build(&self, app: &mut App) {
app.insert_resource(EventDispatcher::<E>::default())
app.add_event::<E>()
.insert_resource(EventDispatcher::<E>::default())
.add_systems(
(
EventDispatcher::<E>::build.run_if(on_event::<E>()),
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ fn main() {
App::new()
.add_plugins(MinimalPlugins)
.add_plugin(LogPlugin::default())
// Note that this plugin will add the `Attack` event to bevy:
.add_plugin(EventListenerPlugin::<Attack>::default())
.add_event::<Attack>()
.add_startup_system(setup)
.add_system(attack_armor.run_if(on_timer(Duration::from_millis(200))))
.run();
Expand Down
2 changes: 0 additions & 2 deletions examples/stress_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ fn main() {
.add_plugin(StressTestPlugin::<4>)
// add an event that has no listeners in the hierarchy
.add_plugin(EventListenerPlugin::<TestEvent<9>>::default())
.add_event::<TestEvent<9>>()
.add_system(send_events::<9>)
.run();
}
Expand All @@ -37,7 +36,6 @@ struct StressTestPlugin<const N: usize>;
impl<const N: usize> Plugin for StressTestPlugin<N> {
fn build(&self, app: &mut App) {
app.add_plugin(EventListenerPlugin::<TestEvent<N>>::default())
.add_event::<TestEvent<N>>()
.add_startup_system(setup::<N>)
.add_system(send_events::<N>);
}
Expand Down

0 comments on commit 38b4b8a

Please sign in to comment.