Rename crate folders to remove raidillon prefix

This commit is contained in:
reo 2025-08-17 21:14:59 +03:00
parent 176ea52ab0
commit 3458662cfc
29 changed files with 31 additions and 28 deletions

74
core/src/scene.rs Normal file
View file

@ -0,0 +1,74 @@
use std::collections::HashMap;
use std::path::{Path, PathBuf};
pub struct Scene {
title: String,
world: hecs::World,
skybox_texture_path: Option<PathBuf>,
}
impl Scene {
pub fn new(title: String, skybox_texture_path: Option<PathBuf>) -> Self {
Self {
title,
world: hecs::World::new(),
skybox_texture_path,
}
}
}
impl AsRef<Scene> for Scene {
fn as_ref(&self) -> &Scene {
&self
}
}
impl AsMut<Scene> for Scene {
fn as_mut(&mut self) -> &mut Scene {
self
}
}
type SceneID = String;
pub struct SceneManager {
scenes: HashMap<SceneID, Scene>,
active_scene: Option<SceneID>,
}
impl SceneManager {
pub fn new() -> Self {
let scenes = HashMap::new();
Self {
scenes,
active_scene: None,
}
}
pub fn current(&self) -> &Scene {
match &self.active_scene {
Some(id) => self.scenes[id].as_ref(),
None => panic!("No active scene"),
}
}
pub fn current_mut(&mut self) -> &mut Scene {
match &mut self.active_scene {
Some(id) => self.scenes.get_mut(id.as_mut()).unwrap().as_mut(),
None => panic!("No active scene"),
}
}
pub fn set_active_scene(&mut self, scene: SceneID) {
self.active_scene = Some(scene);
}
pub fn add_scene(&mut self, id: SceneID, scene: Scene) {
self.scenes.insert(id, scene);
}
pub fn remove_scene(&mut self, id: SceneID) {
self.scenes.remove(&id);
}
}