Skip to content

Create manual set_changed and set_added methods #1718

Description

@alice-i-cecile

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

Existing solutions to manually toggle entities as changed or added are unclear and clunky workarounds.

You might want to do this if, for example, you need to re-process an entity as changed even though its data was not set directly.

What solution would you like?

Create either commands.entity(e).set_changed() or commands.entity(e).set_changed(bool). Uses new syntax from #1703.

Also create set_added and World variants of the above.

What alternative(s) have you considered?

For set_changed, you can manually deref_mut a component, but this is a bit more obscure and requires mutable access to the component.

For set_added, you can manually remove and re-add a component, but this is expensive, slow (WRT command processing) and obscure.

Additional context

Discussed in #1471 and #1711. The bool form of the new methods is more powerful, but also slightly more verbose, and might not have great use cases / present a footgun. I'm personally in favor of the bool method in order to provide more expressive power, but it would be good to have a more full discussion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleC-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