app: Move render_pass into scene
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m8s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m8s
This commit is contained in:
parent
131811a539
commit
f835941432
7 changed files with 250 additions and 267 deletions
46
src/core/scene/manager.rs
Normal file
46
src/core/scene/manager.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
use super::{Scene, SceneContext};
|
||||
|
||||
pub struct SceneManager {
|
||||
current_scene: Option<Box<dyn Scene>>,
|
||||
}
|
||||
|
||||
impl SceneManager {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
current_scene: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_scene_if_not_loaded(&mut self, scene_context: &SceneContext) {
|
||||
if let Some(current_scene) = self.current_scene.as_mut() {
|
||||
if !current_scene.loaded() {
|
||||
current_scene.load(scene_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_scene(&mut self, scene: Box<dyn Scene>) {
|
||||
if let Some(current_scene) = self.current_scene.as_mut() {
|
||||
current_scene.unload();
|
||||
}
|
||||
self.current_scene = Some(scene);
|
||||
}
|
||||
|
||||
pub fn current_scene(&self) -> Option<&Box<dyn Scene>> {
|
||||
if let Some(current_scene) = self.current_scene.as_ref() {
|
||||
if current_scene.loaded() {
|
||||
return Some(current_scene);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn current_scene_mut(&mut self) -> Option<&mut Box<dyn Scene>> {
|
||||
if let Some(current_scene) = self.current_scene.as_mut() {
|
||||
if current_scene.loaded() {
|
||||
return Some(current_scene);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue