wip: Changes of the week

- Move engine to a different crate
- Add engine trait
- Refactor the rest of the codebase to work with these changes
- Add debug ui buffer, use it to finish imgui support
This commit is contained in:
reo 2025-09-07 17:00:04 +03:00
parent 3fd5b09a94
commit 15122b8ebd
20 changed files with 344 additions and 117 deletions

View file

@ -1,38 +0,0 @@
use crate::Scene;
use indexmap::IndexMap;
use winit::event::Event;
use crate::context::PlatformContext;
pub struct SystemContext<'a> {
// TODO: time delta etc.
pub scene: &'a mut Scene,
pub platform_context: PlatformContext,
}
pub trait System {
/// Initialize the system.
fn initialize(&mut self);
/// Spawn the first entities of the world.
fn load_world(&mut self, ctx: &mut SystemContext);
fn update(&mut self, ctx: &mut SystemContext);
}
pub type SystemID = &'static str;
pub struct SystemManager {
pub systems: IndexMap<SystemID, Box<dyn System>>,
}
impl SystemManager {
pub fn new() -> Self {
let systems = IndexMap::default();
Self { systems }
}
pub fn add_system(&mut self, id: SystemID, system: Box<dyn System>) {
self.systems.insert(id, system);
}
pub fn remove_system(&mut self, id: SystemID) {
self.systems.shift_remove(&id);
}
}