use std::error::Error; use bevy_ecs::{schedule::Schedule, world::World}; use vulkano::sync::GpuFuture; use crate::core::{app::context::WindowContext, scene::schedule::SceneScedule}; mod extract; pub mod manager; pub mod schedule; /// Structure Scene qui contient le world et l'implémentation AsScene pub struct Scene { pub world: World, pub loop_schedule: Schedule, pub implementation: Box, } impl Scene { pub fn new(implementation: Box, world: World) -> Self { Self { world, loop_schedule: SceneScedule::base_schedule(), implementation, } } pub fn loaded(&self) -> bool { self.implementation.loaded() } pub fn load(&mut self, window_context: &mut WindowContext) -> Result<(), Box> { self.implementation.load(&mut self.world, window_context) } pub fn update(&mut self, window_context: &WindowContext) -> Result<(), Box> { self.implementation.update(&mut self.world, window_context) } pub fn render( &mut self, acquire_future: Box, window_context: &mut WindowContext, ) -> Result, Box> { self.implementation .render(acquire_future, &mut self.world, window_context) } pub fn unload(&mut self) { self.implementation.unload() } } /// Trait pour les implémentations de scènes pub trait AsScene { fn loaded(&self) -> bool; fn load( &mut self, world: &mut World, window_context: &mut WindowContext, ) -> Result<(), Box>; fn update( &mut self, world: &mut World, window_context: &WindowContext, ) -> Result<(), Box>; fn render( &mut self, acquire_future: Box, world: &mut World, window_context: &mut WindowContext, ) -> Result, Box>; fn unload(&mut self); }