Skip to content
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 RemovedComponentEvents::iter #12815

Merged
merged 2 commits into from Apr 1, 2024

Conversation

Shatur
Copy link
Contributor

@Shatur Shatur commented Mar 31, 2024

Objective

Sometimes it's useful to iterate over removed entities. For example, in my library bevy_replicon I need it to iterate over all removals to replicate them over the network.

Right now we do lookups, but it would be more convenient and faster to just iterate over all removals.

Solution

Add RemovedComponentEvents::iter.


Changelog

Added

  • RemovedComponentEvents::iter to iterate over all removed components.

Sometimes it's useful to iterate over removed entities. For example, in
my library https://github.com/projectharmonia/bevy_replicon I need it
to iterate over all removals to replicate them over the network.

Right now we do lookups, but it would be more convenient and faster to
just iterate.
@pablo-lua pablo-lua added A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use labels Mar 31, 2024
Copy link
Contributor

@pablo-lua pablo-lua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and simple. Just a typo here

crates/bevy_ecs/src/removal_detection.rs Outdated Show resolved Hide resolved
Co-authored-by: Pablo Reinhardt <126117294+pablo-lua@users.noreply.github.com>
@pablo-lua pablo-lua added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 31, 2024
@mockersf mockersf added this pull request to the merge queue Apr 1, 2024
Merged via the queue into bevyengine:main with commit 891c2f1 Apr 1, 2024
28 checks passed
@Shatur Shatur deleted the component-events-iter branch April 1, 2024 21:00
chompaa pushed a commit to chompaa/bevy that referenced this pull request Apr 5, 2024
# Objective

Sometimes it's useful to iterate over removed entities. For example, in
my library
[bevy_replicon](https://github.com/projectharmonia/bevy_replicon) I need
it to iterate over all removals to replicate them over the network.

Right now we do lookups, but it would be more convenient and faster to
just iterate over all removals.

## Solution

Add `RemovedComponentEvents::iter`.

---

## Changelog

### Added

- `RemovedComponentEvents::iter` to iterate over all removed components.

---------

Co-authored-by: Pablo Reinhardt <126117294+pablo-lua@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants