raidillon/engine/src/system.rs
reo 0c0d5cdb2a Fix imgui renderer once and for all
Finally solved the problems with the imgui renderer after a long chat with clankers. Fixed some other stuff as well.

Reminder to keep the rendered_this_frame check as that's what solved it. Probably a deeper issue down there that caused us to render twice, but whatever.
2025-09-10 01:31:43 +03:00

42 lines
No EOL
1.1 KiB
Rust

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<RefCell<DebugUIBuffer>>,
}
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);
}
}