Move World into dedicated Scene struct
This commit is contained in:
parent
8ce620a74b
commit
c494574389
6 changed files with 73 additions and 28 deletions
|
@ -7,7 +7,48 @@ use crate::core::app::context::WindowContext;
|
|||
|
||||
pub mod manager;
|
||||
|
||||
pub trait Scene {
|
||||
/// Structure Scene qui contient le world et l'implémentation AsScene
|
||||
pub struct Scene {
|
||||
pub world: World,
|
||||
pub implementation: Box<dyn AsScene>,
|
||||
}
|
||||
|
||||
impl Scene {
|
||||
pub fn new(implementation: Box<dyn AsScene>, world: World) -> Self {
|
||||
Self {
|
||||
world,
|
||||
implementation,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn loaded(&self) -> bool {
|
||||
self.implementation.loaded()
|
||||
}
|
||||
|
||||
pub fn load(&mut self, window_context: &mut WindowContext) -> Result<(), Box<dyn Error>> {
|
||||
self.implementation.load(&mut self.world, window_context)
|
||||
}
|
||||
|
||||
pub fn update(&mut self, window_context: &WindowContext) -> Result<(), Box<dyn Error>> {
|
||||
self.implementation.update(&mut self.world, window_context)
|
||||
}
|
||||
|
||||
pub fn render(
|
||||
&mut self,
|
||||
acquire_future: Box<dyn GpuFuture>,
|
||||
window_context: &mut WindowContext,
|
||||
) -> Result<Box<dyn GpuFuture>, Box<dyn Error>> {
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue