2020-07-10 04:18:35 +00:00
|
|
|
use crate::WindowCloseRequested;
|
2022-03-01 19:33:56 +00:00
|
|
|
use bevy_app::AppExit;
|
|
|
|
use bevy_ecs::event::{EventReader, EventWriter};
|
2020-07-10 04:18:35 +00:00
|
|
|
|
|
|
|
pub fn exit_on_window_close_system(
|
2021-03-07 20:42:04 +00:00
|
|
|
mut app_exit_events: EventWriter<AppExit>,
|
2021-01-19 06:23:30 +00:00
|
|
|
mut window_close_requested_events: EventReader<WindowCloseRequested>,
|
2020-07-10 04:18:35 +00:00
|
|
|
) {
|
2021-01-19 06:23:30 +00:00
|
|
|
if window_close_requested_events.iter().next().is_some() {
|
2020-07-10 04:18:35 +00:00
|
|
|
app_exit_events.send(AppExit);
|
|
|
|
}
|
2020-04-25 01:55:15 +00:00
|
|
|
}
|