Compare commits

..

2 commits

Author SHA1 Message Date
6f56ec8d83 Update Rust crate rusqlite to 0.33.0 2025-02-27 21:02:36 +00:00
b90a81bcc5 Fix close event 2025-02-27 19:25:40 +01:00
3 changed files with 29 additions and 12 deletions

View file

@ -14,13 +14,13 @@ pub struct WorldBuilder {
pub(crate) updates: Updates, pub(crate) updates: Updates,
pub events: Events, pub events: Events,
pub resources: Resources, pub resources: Resources,
systems: Vec<Box<dyn Fn(&mut World) -> Result<()> + Send + Sync + 'static>>, systems: Vec<Box<dyn Fn(&mut World) -> Result<bool> + Send + Sync + 'static>>,
} }
impl WorldBuilder { impl WorldBuilder {
pub fn add_system<F>(&mut self, f: F) pub fn add_system<F>(&mut self, f: F)
where where
F: Fn(&mut World) -> Result<()> + Send + Sync + 'static, F: Fn(&mut World) -> Result<bool> + Send + Sync + 'static,
{ {
self.systems.push(Box::new(f)); self.systems.push(Box::new(f));
} }
@ -66,7 +66,7 @@ pub struct World {
start_time: Instant, start_time: Instant,
systems: Vec<Box<dyn Fn(&mut World) -> Result<()> + Send + Sync + 'static>>, systems: Vec<Box<dyn Fn(&mut World) -> Result<bool> + Send + Sync + 'static>>,
} }
impl World { impl World {
@ -349,7 +349,9 @@ impl World {
self.commit_entity_changes()?; self.commit_entity_changes()?;
for system in systems.iter() { for system in systems.iter() {
system(self)?; if !system(self)? {
return Ok(());
}
} }
} }
} }

View file

@ -207,6 +207,15 @@ impl Engine {
world.resources.insert(engine); world.resources.insert(engine);
world.resources.insert(engine_settings); world.resources.insert(engine_settings);
let scene = Scene::new(
create_info.rasterizer_info,
create_info.raytracing_info,
create_info.graphics_info,
world,
)?;
world.resources.insert(scene);
world.add_system(Self::main_system); world.add_system(Self::main_system);
Ok(()) Ok(())
@ -247,10 +256,13 @@ impl Engine {
pub fn build_path(&self, path: &str) -> AssetPath { pub fn build_path(&self, path: &str) -> AssetPath {
(self.resource_base_path.as_str(), path).into() (self.resource_base_path.as_str(), path).into()
} }
}
pub fn main_system(world: &mut World) -> Result<()> { impl Engine {
// fn main_system(world: &mut World) -> Result<bool> {
world
Ok(()) .resources
.get_mut_unchecked::<Context>()
.next_frame::<()>(world)
} }
} }

View file

@ -55,15 +55,18 @@ pub struct Scene {
impl Scene { impl Scene {
pub(crate) fn new( pub(crate) fn new(
device: &Arc<Device>,
queue: &Arc<Mutex<Queue>>,
(screen_width, screen_height): (f32, f32),
images: &TargetMode<Vec<Arc<Image>>>,
rasterizer_info: RasterizerInfo, rasterizer_info: RasterizerInfo,
raytracer_info: RaytracingInfo, raytracer_info: RaytracingInfo,
graphics_info: GraphicsInfo, graphics_info: GraphicsInfo,
world: &mut WorldBuilder, world: &mut WorldBuilder,
) -> Result<()> { ) -> Result<()> {
let context = world.resources.get::<Context>();
let device = context.device();
let queue = context.queue();
let (screen_width, screen_height) = (context.width() as f32, context.height() as f32);
let images = &context.images();
let (renderer, render_type): (Box<dyn RenderingFrontEnd + Send + Sync>, SceneType) = let (renderer, render_type): (Box<dyn RenderingFrontEnd + Send + Sync>, SceneType) =
Self::create_rendering_front_end( Self::create_rendering_front_end(
device, device,