You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// It is also useful for reserving an id; commands will often allocate an `Entity` but not provide it a location until the command is applied.
1319
1319
pubtypeEntityIdLocation = Option<EntityLocation>;
1320
1320
1321
+
/// An [`Entity`] that has been disabled. This entity will not be found by queries or accessible via other ECS operations, but it's components are still stored in the ECS.
1322
+
/// This is useful for temporarily disabling an entity without fully despawning it or invoking archetype moves. This entity keeps track of its location, so it can be re-enabled later.
Copy file name to clipboardExpand all lines: crates/bevy_ecs/src/storage/table/mod.rs
+26-8Lines changed: 26 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -198,7 +198,7 @@ impl Table {
198
198
/// Fetches a read-only slice of the entities stored within the [`Table`].
199
199
#[inline]
200
200
pubfnentities(&self) -> &[Entity]{
201
-
&self.entities[self.disabled_entitiesasusize..]
201
+
&self.entities
202
202
}
203
203
204
204
/// Get the valid table rows (i.e. non-disabled entities).
@@ -217,7 +217,11 @@ impl Table {
217
217
self.entities.capacity()
218
218
}
219
219
220
-
/// Disables the entity at the given row, moving it to the back of the table and returns the entities that were swapped (if any) together with their new `TableRow`.
220
+
/// Disables or enables the entity at `row` by swapping it with the first
221
+
/// enabled or disabled entity. Returns the swapped entities with their
222
+
/// respective table rows, or `None` if no swap occurred. If a
223
+
/// swap occurred, the caller is responsible for updating the entity's
224
+
/// location.
221
225
///
222
226
/// # Safety
223
227
/// `row` must be in-bounds (`row.as_usize()` < `self.len()`) and not disabled.
0 commit comments