Skip to content

EntityCommands get mutable reference to added components #4917

@starwolfy

Description

@starwolfy

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

When implementing modular systems-based entity spawning, you gather Commands to obtain EntityCommands for the specific entity that is being spawned in the series of added entity builder systems running that frame. Sometimes one entity builder system wants to obtain a mutable component a previous builder already added to that specific (ie adding an offset to the entity's existing Transform component). To my knowledge, this is not possible right now.

What solution would you like?

Some methods similar to that of Query. Ie get_component and get_component_mut get added to EntityCommands.

What alternative(s) have you considered?

One could add their own resource shared across those entity building systems and store&modify components through it and add a final system that wraps it up and adds it to EntityCommands.

Additional context

In the context of plugins expanding the default spawn components of each entity: plugins would insert their own labeled builder systems to the loop to tap into the spawning process of entities coming to life in the next frame from the EntityCommands frame. Currently, you cannot obtain or edit components that have already been passed to EntityCommands and building entities this way requires your own Resource that has to be some type of generic component container with various implementations to deal with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions