Replace Contexts with Resources #7
No reviewers
Labels
No labels
bug
codex
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: reo/raidillon#7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "2025-10-15-resources"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
THREAD: Reminder to clean up unused code
@ -22,3 +22,1 @@fn handle_event(&mut self, _ctx: &mut SystemContext) {}fn fixed_update(&mut self, _ctx: &mut SystemContext) {}fn frame_update(&mut self, _ctx: &mut SystemContext) {}fn load_world(&mut self, res: &mut EngineResources, scene: &mut Scene) {}I'm wondering if I should put scene inside EngineResources instead 🤔
@ -63,1 +67,3 @@let mut dbg_ui = ctx.debug_ui_buffer.borrow_mut();fn frame_update(&mut self, res: &mut EngineResources, scene: &mut Scene) {let pctx = res.get::<PlatformContext>().unwrap().clone();let dbg_ui = scene.resources.get_mut::<DebugUIBuffer>().unwrap();Looking at this mess makes me want to invent a simple domain-specific language to specify which resources a system needs, and then make a macro to generate this code.
I've never made a list of the most over-engineered things I've created. If I were to start now I wouldn't have trouble deciding which one gets the top spot.
Solved by implementing
get_manyThe nasty repetition in
define_typemap!can probably be eliminated with a procedural macro, but I don't think it's worth my time. I'd rather do physics right now and think about procedural macros if I ever need to look up 10 resources in a single query or something.I probably should've written a test for
TypeMap,get_manyis alright butget_many_mutreturnsNonefor existing resources.