-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add World::resource_scope_by_id
#13466
Comments
Wondering if the |
I would keep it mutable for consistency with |
Interested in picking this up with my group. Purdue Team |
@Shatur I was trying to follow along both bevy_replicon and bevy's code base at these function calls.
|
Resources have functions like this: https://docs.rs/bevy/latest/bevy/ecs/prelude/struct.World.html#method.get_resource_by_id
We no longer need it in Replicon :) |
The signature should look something like this. Basically, you're adapting the impl World {
fn resource_scopy_by_id<U> (id: ComponentId, f: impl FnOnce](&mut World, Ptr<'_>) -> U,) -> U { todo!() }
} |
How can this behavior be expected from passing one id. From what I've been reading it seems like a given ID is used to access one resource at a time without the type being know.
To me it seems like this could only be used to do one resource at a time if nesting isn't used. Please explain how the dynamic access can be used on multiple resources at once by id when only one id is given.
Thanks! |
This isn't the goal. The goal is simply to create an equivalent to |
What problem does this solve or what need does it fill?
I working on https://github.com/projectharmonia/bevy_replicon and we do a lot of type erasure internally for perfomance and a nice API.
Sometimes I need to access a resource mutably by ID and other resources just as reference. Since we don't have something like
World::resource_scope_by_id
, I do the inverse:What solution would you like?
But it would be nicer to do it like this:
The text was updated successfully, but these errors were encountered: