Skip to content

Commit e1b995f

Browse files
authored
Add documentation for bevy::ecs::Query::removed (#950)
Add documentation for bevy::ecs::Query::removed
1 parent 2c9b795 commit e1b995f

File tree

1 file changed

+15
-0
lines changed
  • crates/bevy_ecs/src/system/query

1 file changed

+15
-0
lines changed

crates/bevy_ecs/src/system/query/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ impl<'a, Q: WorldQuery, F: QueryFilter> Query<'a, Q, F> {
181181
.map_err(QueryError::ComponentError)
182182
}
183183

184+
/// Returns an array containing the `Entity`s in this `Query` that had the given `Component`
185+
/// removed in this update.
186+
///
187+
/// `removed::<C>()` only returns entities whose components were removed before the
188+
/// current system started.
189+
///
190+
/// Regular systems do not apply `Commands` until the end of their stage. This means component
191+
/// removals in a regular system won't be accessible through `removed::<C>()` in the same
192+
/// stage, because the removal hasn't actually occurred yet. This can be solved by executing
193+
/// `removed::<C>()` in a later stage. `AppBuilder::add_system_to_stage()` can be used to
194+
/// control at what stage a system runs.
195+
///
196+
/// Thread local systems manipulate the world directly, so removes are applied immediately. This
197+
/// means any system that runs after a thread local system in the same update will pick up
198+
/// removals that happened in the thread local system, regardless of stages.
184199
pub fn removed<C: Component>(&self) -> &[Entity] {
185200
self.world.removed::<C>()
186201
}

0 commit comments

Comments
 (0)