Moved events to ECS (#1823)

Fixes #1809. It makes it also possible to use `derive` for `SystemParam` inside ECS and avoid manual implementation. An alternative solution to macro changes is to use `use crate as bevy_ecs;` in `event.rs`.
This commit is contained in:
Yoh Deadfall 2021-04-13 20:36:37 +00:00
parent 01142a137e
commit 04a37f722a
11 changed files with 18 additions and 21 deletions

View file

@ -1,11 +1,11 @@
use crate::{ use crate::{
app::{App, AppExit}, app::{App, AppExit},
event::Events,
plugin::Plugin, plugin::Plugin,
CoreStage, PluginGroup, PluginGroupBuilder, StartupStage, CoreStage, PluginGroup, PluginGroupBuilder, StartupStage,
}; };
use bevy_ecs::{ use bevy_ecs::{
component::{Component, ComponentDescriptor}, component::{Component, ComponentDescriptor},
event::Events,
schedule::{ schedule::{
RunOnce, Schedule, Stage, StageLabel, State, SystemDescriptor, SystemSet, SystemStage, RunOnce, Schedule, Stage, StageLabel, State, SystemDescriptor, SystemSet, SystemStage,
}, },

View file

@ -1,6 +1,5 @@
mod app; mod app;
mod app_builder; mod app_builder;
mod event;
mod plugin; mod plugin;
mod plugin_group; mod plugin_group;
mod schedule_runner; mod schedule_runner;
@ -8,17 +7,15 @@ mod schedule_runner;
pub use app::*; pub use app::*;
pub use app_builder::*; pub use app_builder::*;
pub use bevy_derive::DynamicPlugin; pub use bevy_derive::DynamicPlugin;
pub use event::*; pub use bevy_ecs::event::*;
pub use plugin::*; pub use plugin::*;
pub use plugin_group::*; pub use plugin_group::*;
pub use schedule_runner::*; pub use schedule_runner::*;
pub mod prelude { pub mod prelude {
pub use crate::{ pub use crate::{
app::App, app::App, app_builder::AppBuilder, CoreStage, DynamicPlugin, Plugin, PluginGroup,
app_builder::AppBuilder, StartupStage,
event::{EventReader, EventWriter},
CoreStage, DynamicPlugin, Plugin, PluginGroup, StartupStage,
}; };
} }

View file

@ -1,5 +1,6 @@
use super::{App, AppBuilder}; use super::{App, AppBuilder};
use crate::{app::AppExit, event::Events, plugin::Plugin, ManualEventReader}; use crate::{app::AppExit, plugin::Plugin, ManualEventReader};
use bevy_ecs::event::Events;
use bevy_utils::{Duration, Instant}; use bevy_utils::{Duration, Instant};
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]

View file

@ -16,4 +16,4 @@ proc-macro = true
syn = "1.0" syn = "1.0"
quote = "1.0" quote = "1.0"
proc-macro2 = "1.0" proc-macro2 = "1.0"
find-crate = "0.6" find-crate = "0.6"

View file

@ -1,4 +1,5 @@
use bevy_ecs::{ use crate as bevy_ecs;
use crate::{
component::Component, component::Component,
system::{Local, Res, ResMut, SystemParam}, system::{Local, Res, ResMut, SystemParam},
}; };
@ -76,7 +77,7 @@ enum State {
/// ///
/// # Example /// # Example
/// ``` /// ```
/// use bevy_app::Events; /// use bevy_ecs::event::Events;
/// ///
/// struct MyEvent { /// struct MyEvent {
/// value: usize /// value: usize

View file

@ -2,6 +2,7 @@ pub mod archetype;
pub mod bundle; pub mod bundle;
pub mod component; pub mod component;
pub mod entity; pub mod entity;
pub mod event;
pub mod query; pub mod query;
#[cfg(feature = "bevy_reflect")] #[cfg(feature = "bevy_reflect")]
pub mod reflect; pub mod reflect;
@ -16,6 +17,7 @@ pub mod prelude {
pub use crate::{ pub use crate::{
bundle::Bundle, bundle::Bundle,
entity::Entity, entity::Entity,
event::{EventReader, EventWriter},
query::{Added, ChangeTrackers, Changed, Or, QueryState, With, WithBundle, Without}, query::{Added, ChangeTrackers, Changed, Or, QueryState, With, WithBundle, Without},
schedule::{ schedule::{
AmbiguitySetLabel, ExclusiveSystemDescriptorCoercion, ParallelSystemDescriptorCoercion, AmbiguitySetLabel, ExclusiveSystemDescriptorCoercion, ParallelSystemDescriptorCoercion,

View file

@ -1,6 +1,5 @@
use crate::{ElementState, Input}; use crate::{ElementState, Input};
use bevy_app::prelude::EventReader; use bevy_ecs::{event::EventReader, system::ResMut};
use bevy_ecs::system::ResMut;
use bevy_math::Vec2; use bevy_math::Vec2;
/// A mouse button input event /// A mouse button input event

View file

@ -2,10 +2,8 @@ use crate::{
keyboard::{KeyCode, KeyboardInput}, keyboard::{KeyCode, KeyboardInput},
ElementState, ElementState,
}; };
use bevy_app::{ use bevy_app::AppExit;
prelude::{EventReader, EventWriter}, use bevy_ecs::prelude::{EventReader, EventWriter};
AppExit,
};
/// Sends the AppExit event whenever the "esc" key is pressed. /// Sends the AppExit event whenever the "esc" key is pressed.
pub fn exit_on_esc_system( pub fn exit_on_esc_system(

View file

@ -1,8 +1,8 @@
use super::CameraProjection; use super::CameraProjection;
use bevy_app::prelude::EventReader;
use bevy_ecs::{ use bevy_ecs::{
component::Component, component::Component,
entity::Entity, entity::Entity,
event::EventReader,
query::Added, query::Added,
reflect::ReflectComponent, reflect::ReflectComponent,
system::{Query, QuerySet, Res}, system::{Query, QuerySet, Res},

View file

@ -2,11 +2,11 @@ use crate::{
pipeline::{IndexFormat, PrimitiveTopology, RenderPipelines, VertexFormat}, pipeline::{IndexFormat, PrimitiveTopology, RenderPipelines, VertexFormat},
renderer::{BufferInfo, BufferUsage, RenderResourceContext, RenderResourceId}, renderer::{BufferInfo, BufferUsage, RenderResourceContext, RenderResourceId},
}; };
use bevy_app::prelude::EventReader;
use bevy_asset::{AssetEvent, Assets, Handle}; use bevy_asset::{AssetEvent, Assets, Handle};
use bevy_core::AsBytes; use bevy_core::AsBytes;
use bevy_ecs::{ use bevy_ecs::{
entity::Entity, entity::Entity,
event::EventReader,
query::{Changed, With}, query::{Changed, With},
system::{Local, Query, QuerySet, Res}, system::{Local, Query, QuerySet, Res},
world::Mut, world::Mut,

View file

@ -5,9 +5,8 @@ use super::{
use crate::renderer::{ use crate::renderer::{
RenderResource, RenderResourceContext, RenderResourceId, RenderResourceType, RenderResource, RenderResourceContext, RenderResourceId, RenderResourceType,
}; };
use bevy_app::prelude::EventReader;
use bevy_asset::{AssetEvent, Assets, Handle}; use bevy_asset::{AssetEvent, Assets, Handle};
use bevy_ecs::system::Res; use bevy_ecs::{event::EventReader, system::Res};
use bevy_reflect::TypeUuid; use bevy_reflect::TypeUuid;
use bevy_utils::HashSet; use bevy_utils::HashSet;
use thiserror::Error; use thiserror::Error;