diff --git a/ecs/src/world.rs b/ecs/src/world.rs index 8a8d59d..e3f6651 100644 --- a/ecs/src/world.rs +++ b/ecs/src/world.rs @@ -14,13 +14,13 @@ pub struct WorldBuilder { pub(crate) updates: Updates, pub events: Events, pub resources: Resources, - systems: Vec Result<()> + Send + Sync + 'static>>, + systems: Vec Result + Send + Sync + 'static>>, } impl WorldBuilder { pub fn add_system(&mut self, f: F) where - F: Fn(&mut World) -> Result<()> + Send + Sync + 'static, + F: Fn(&mut World) -> Result + Send + Sync + 'static, { self.systems.push(Box::new(f)); } @@ -66,7 +66,7 @@ pub struct World { start_time: Instant, - systems: Vec Result<()> + Send + Sync + 'static>>, + systems: Vec Result + Send + Sync + 'static>>, } impl World { @@ -349,7 +349,9 @@ impl World { self.commit_entity_changes()?; for system in systems.iter() { - system(self)?; + if !system(self)? { + return Ok(()); + } } } } diff --git a/engine/src/engine/engine.rs b/engine/src/engine/engine.rs index 96143ec..07a4436 100644 --- a/engine/src/engine/engine.rs +++ b/engine/src/engine/engine.rs @@ -207,6 +207,15 @@ impl Engine { world.resources.insert(engine); 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); Ok(()) @@ -247,10 +256,13 @@ impl Engine { pub fn build_path(&self, path: &str) -> AssetPath { (self.resource_base_path.as_str(), path).into() } +} - pub fn main_system(world: &mut World) -> Result<()> { - // - - Ok(()) +impl Engine { + fn main_system(world: &mut World) -> Result { + world + .resources + .get_mut_unchecked::() + .next_frame::<()>(world) } } diff --git a/engine/src/scene/scene/scene_base.rs b/engine/src/scene/scene/scene_base.rs index f8e96a3..82c7b29 100644 --- a/engine/src/scene/scene/scene_base.rs +++ b/engine/src/scene/scene/scene_base.rs @@ -55,15 +55,18 @@ pub struct Scene { impl Scene { pub(crate) fn new( - device: &Arc, - queue: &Arc>, - (screen_width, screen_height): (f32, f32), - images: &TargetMode>>, rasterizer_info: RasterizerInfo, raytracer_info: RaytracingInfo, graphics_info: GraphicsInfo, world: &mut WorldBuilder, ) -> Result<()> { + let context = world.resources.get::(); + + 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, SceneType) = Self::create_rendering_front_end( device,