Replace contexts with resources

- Implements a new macro to generate code for a new structure: TypeMap
- TypeMaps are wrappers for HashMaps that use TypeIDs as keys.
- Refactor the entire codebase to use the new resource structures.
- This commit is the first step towards getting rid of "god context objects everywhere".
This commit is contained in:
reo 2025-10-15 22:33:04 +03:00
parent 6e42d94b44
commit ef055a1bda
16 changed files with 287 additions and 93 deletions

View file

@ -6,7 +6,7 @@ use indexmap::IndexMap;
use glium::{Display, Frame};
use glium::glutin::surface::WindowSurface;
use raidillon_assets::ModelManagerRef;
use raidillon_core::DebugUIBuffer;
use raidillon_core::{define_typemap, DebugUIBuffer};
use raidillon_core::scene::Scene;
use glam::Vec3;
@ -15,7 +15,7 @@ pub struct RenderingContext<'a> {
pub target: &'a mut Frame,
pub window: Arc<Mutex<glium::winit::window::Window>>,
pub asset_manager: ModelManagerRef,
pub debug_ui_buffer: Rc<RefCell<DebugUIBuffer>>,
pub debug_ui_buffer: &'a DebugUIBuffer,
pub env_light_dir: Vec3,
}
@ -35,6 +35,8 @@ pub trait RenderingSystem {
Self: Sized;
}
// define_typemap!(RenderingSystemManager, RenderingSystem);
pub struct RenderingSystemManager {
pub systems: IndexMap<TypeId, Box<dyn RenderingSystem>>,
}