Init plugins + first system
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 5m40s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 5m40s
This commit is contained in:
parent
dda368e802
commit
6639f0bb1e
4 changed files with 48 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
use bevy_app::{App, AppExit};
|
||||
use bevy_app::{App, AppExit, PluginsState};
|
||||
use config::WindowConfig;
|
||||
use raw_handle::{DisplayHandleWrapper, EventLoopProxyWrapper};
|
||||
use state::WindowState;
|
||||
|
@ -35,6 +35,11 @@ impl Window {
|
|||
}
|
||||
|
||||
fn runner(mut app: App, event_loop: EventLoop<()>) -> AppExit {
|
||||
if app.plugins_state() == PluginsState::Ready {
|
||||
app.finish();
|
||||
app.cleanup();
|
||||
}
|
||||
|
||||
app.world_mut()
|
||||
.insert_resource(EventLoopProxyWrapper::new(event_loop.create_proxy()));
|
||||
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use bevy_app::App;
|
||||
use bevy_ecs::world::World;
|
||||
use bevy_app::{App, PluginsState};
|
||||
use bevy_ecs::{event, world::World};
|
||||
use winit::{
|
||||
application::ApplicationHandler, event::WindowEvent, event_loop::ActiveEventLoop,
|
||||
window::WindowId,
|
||||
};
|
||||
|
||||
use super::{config::WindowConfig, raw_handle::WindowWrapper};
|
||||
use super::{
|
||||
config::WindowConfig,
|
||||
raw_handle::{DisplayHandleWrapper, WindowWrapper},
|
||||
};
|
||||
|
||||
pub struct WindowState {
|
||||
app: App,
|
||||
|
@ -33,13 +36,32 @@ impl ApplicationHandler for WindowState {
|
|||
.insert_resource(WindowWrapper(Arc::new(window)));
|
||||
}
|
||||
|
||||
fn new_events(&mut self, event_loop: &ActiveEventLoop, cause: winit::event::StartCause) {
|
||||
if self.app.plugins_state() == PluginsState::Ready {
|
||||
self.app.finish();
|
||||
self.app.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
fn window_event(&mut self, event_loop: &ActiveEventLoop, _id: WindowId, event: WindowEvent) {
|
||||
match event {
|
||||
WindowEvent::CloseRequested => {
|
||||
log::debug!("The close button was pressed; stopping");
|
||||
event_loop.exit();
|
||||
}
|
||||
WindowEvent::RedrawRequested => {
|
||||
log::debug!("The window was requested to be redrawn");
|
||||
if self.app.plugins_state() == PluginsState::Cleaned {
|
||||
self.app.update();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn about_to_wait(&mut self, _event_loop: &ActiveEventLoop) {
|
||||
let window_wrapper = self.app.world().get_resource::<WindowWrapper>().unwrap();
|
||||
|
||||
window_wrapper.0.request_redraw();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ use crate::core::{
|
|||
window::{Window, config::WindowConfig},
|
||||
};
|
||||
|
||||
pub mod test_plugin;
|
||||
|
||||
pub fn init(app: &mut App) {
|
||||
let window_config = WindowConfig {
|
||||
title: "Rust ASH Test".to_string(),
|
||||
|
@ -12,6 +14,7 @@ pub fn init(app: &mut App) {
|
|||
height: 600,
|
||||
};
|
||||
|
||||
app.add_plugins(test_plugin::TestPlugin);
|
||||
Window::new(app, window_config).unwrap();
|
||||
Vulkan::new(app).unwrap();
|
||||
// Vulkan::new(app).unwrap();
|
||||
}
|
||||
|
|
13
src/game/test_plugin.rs
Normal file
13
src/game/test_plugin.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
use bevy_app::{App, Last, Plugin, Startup};
|
||||
|
||||
pub struct TestPlugin;
|
||||
|
||||
impl Plugin for TestPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Last, setup_system);
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_system() {
|
||||
log::info!("Hello, world!");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue