-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make WorldId
a SystemParam
#7736
Comments
I have tested this, and it seems to work in practice, but I have no idea if it's safe or if it's the correct way to do this. /// SAFETY: No idea
unsafe impl ReadOnlySystemParam for WorldId {}
/// SAFETY: No idea
unsafe impl SystemParam for WorldId {
type State = WorldId;
type Item<'world, 'state> = WorldId;
fn init_state(world: &mut super::World, _: &mut crate::system::SystemMeta) -> Self::State {
world.id
}
unsafe fn get_param<'world, 'state>(
_: &'state mut Self::State,
_: &crate::system::SystemMeta,
world: &'world super::World,
_: u32,
) -> Self::Item<'world, 'state> {
world.id
}
} |
That looks generally correct to me beyond the safety comments. Something along the lines of Another alternative is to just read it from the System itself, since systems are bound to the World they're initialized on. |
# Objective Fixes bevyengine#7736 ## Solution Implement the `SystemParam` trait for `WorldId` ## Changelog - `WorldId` can now be taken as a system parameter and will return the id of the world the system is running in
Originally posted by @james7132 in #7726 (review)
This should be able to draw directly from the implementation in the linked PR: it should return the
WorldId
of the world that the system is running on.The text was updated successfully, but these errors were encountered: