bevy/crates/bevy_ecs/src
eugineerd 3b6d01972b
Unify filtering by id in EntityClonerBuilder (#19977)
# Objective
#19649 introduced new `*_if_new` and `*_by_bundle_id_*` variations to
`EntityClonerBuilder` filtering functionality, which resulted in
increase in method permutations - there are now 8 allow variants to
support various id types and 2 different insert modes.

## Solution
This PR introduces a new trait `FilterableIds` to unify all id types and
their `IntoIterator` implementations, which is somewhat similar to
`WorldEntityFetch`. It supports `TypeId`, `ComponentId` and `BundleId`,
allowing us to reduce the number of `allow` methods to 4: `allow`,
`allow_if_new`, `allow_by_ids`, `allow_by_ids_if_new`. The function
signature is a bit less readable now, but the docs mention types that
can be passed in.

## Testing
All existing tests pass, performance is unchanged.

---------

Co-authored-by: urben1680 <55257931+urben1680@users.noreply.github.com>
2025-07-07 20:00:37 +00:00
..
entity Unify filtering by id in EntityClonerBuilder (#19977) 2025-07-07 20:00:37 +00:00
error Don't create errors for ignored failed commands (#19718) 2025-06-29 16:34:20 +00:00
event Observer trigger refactor (#19935) 2025-07-04 16:27:21 +00:00
observer Observer trigger refactor (#19935) 2025-07-04 16:27:21 +00:00
query Have System::run_unsafe return Result. (#19145) 2025-07-03 21:48:09 +00:00
reflect ECS: put strings only used for debug behind a feature (#19558) 2025-06-18 20:15:25 +00:00
relationship improved the entity_index_map unit test (#19936) 2025-07-03 20:36:09 +00:00
schedule Have System::run_unsafe return Result. (#19145) 2025-07-03 21:48:09 +00:00
storage bevy_ecs: remove use of needless_return (#19859) 2025-06-29 17:12:33 +00:00
system Have System::run_unsafe return Result. (#19145) 2025-07-03 21:48:09 +00:00
world Observer trigger refactor (#19935) 2025-07-04 16:27:21 +00:00
archetype.rs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
batching.rs Nonmax all rows (#19132) 2025-05-26 17:39:55 +00:00
bundle.rs Remove Bundle::register_required_components (#19967) 2025-07-06 18:15:28 +00:00
change_detection.rs Have System::run_unsafe return Result. (#19145) 2025-07-03 21:48:09 +00:00
component.rs Let Component::map_entities defer to MapEntities (#19414) 2025-06-23 21:05:04 +00:00
entity_disabling.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
hierarchy.rs Fix some typos (#19788) 2025-06-23 22:32:46 +00:00
intern.rs Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
label.rs Remove upcasting methods + Cleanup interned label code (#18984) 2025-05-26 15:38:12 +00:00
lib.rs Observer trigger refactor (#19935) 2025-07-04 16:27:21 +00:00
lifecycle.rs Observer trigger refactor (#19935) 2025-07-04 16:27:21 +00:00
name.rs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
never.rs Use never_say_never hack to work around Rust 2024 regression for fn traits (#18804) 2025-04-14 19:59:48 +00:00
resource.rs refactor(utils): move SyncCell and SyncUnsafeCell to bevy_platform (#19305) 2025-05-27 04:57:26 +00:00
spawn.rs Remove Bundle::register_required_components (#19967) 2025-07-06 18:15:28 +00:00
traversal.rs Let query items borrow from query state to avoid needing to clone (#15396) 2025-06-16 21:05:41 +00:00