Skip to content

EntityWorldMut::(try_)resource_scope #20139

Open
@BigWingBeat

Description

@BigWingBeat

What problem does this solve or what need does it fill?

EntityWorldMut mirrors many of the methods on World, but not all of them. One of the methods it does not mirror is resource_scope. If you need to use resource_scope in a context where you have an EntityWorldMut, such as an EntityCommand, you currently need to deconstruct and then reconstruct it like so:

let id = entity_world_mut.id();
let world = entity_world_mut.into_world_mut();
world.resource_scope::<_, _>(|world, res| {
    let entity_world_mut = world.entity_mut(id);
    /* ... */
});

What solution would you like?

Add resource_scope and try_resource_scope methods to EntityWorldMut that mirror the corresponding methods on World.

What alternative(s) have you considered?

  • Change methods like EntityCommand::apply, BundleEffect::apply, and anything else that takes an EntityWorldMut as a parameter, to instead separately take an Entity and a &mut World as parameters.
  • Continue using the aforementioned workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions