use std::cell::RefCell; use std::rc::Rc; use raidillon_core::scene::Scene; use indexmap::IndexMap; use winit::event::Event; use raidillon_core::context::PlatformContext; use raidillon_core::DebugUIBuffer; pub struct SystemContext<'a> { // TODO: time delta etc. pub scene: &'a mut Scene, pub platform_context: PlatformContext, pub debug_ui_buffer: Rc>, } 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>, } impl SystemManager { pub fn new() -> Self { let systems = IndexMap::default(); Self { systems } } pub fn add_system(&mut self, id: SystemID, system: Box) { self.systems.insert(id, system); } pub fn remove_system(&mut self, id: SystemID) { self.systems.shift_remove(&id); } }