Skip to content

Expose Scheduler#35

Merged
wick3dr0se merged 4 commits intowick3dr0se:mainfrom
oli-obk:non-static-systems
Apr 16, 2025
Merged

Expose Scheduler#35
wick3dr0se merged 4 commits intowick3dr0se:mainfrom
oli-obk:non-static-systems

Conversation

@oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Apr 16, 2025

Best reviewed commit-by-commit

we keep the current scheduler to make transitioning easier. If we fully rip out the scheduler from the World, that means we can actually remove the World argument of systems, and just capture the world in closures 😆 not sure that is too much tho. So let's first get a bit of a feel for this new system (pun intended).

return;
fn move_system(world: &World, game_state: &mut GameState) {
if game_state.paused {
return;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core part of this PR. it becomes much rarer that you need to use closures, though it's still very practical for things like textures that do not change and are only loaded once, as they can just be captured by immutable reference and do not have to be part of the mutable resource argument (here GameState).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soo much cleaner than passing around individual resources to each system.. Looks solid to me 😄


scheduler.register(|_world, state| {
*state += 1;
assert_eq!(immut_resource, "foo");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's an example of a system referring to something outside the system without capturing it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 that's sick

@wick3dr0se
Copy link
Owner

Yea I think that's a good solution for now.. Time will tell what needs to happen but it all looks great to me

@wick3dr0se wick3dr0se merged commit 2a8f23b into wick3dr0se:main Apr 16, 2025
7 checks passed
@oli-obk oli-obk deleted the non-static-systems branch April 16, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants