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
@@ -208,7 +208,7 @@ impl Table {
208
208
/// Fetches a read-only slice of the entities stored within the [`Table`].
209
209
#[inline]
210
210
pubfnentities(&self) -> &[Entity]{
211
-
&self.entities[self.disabled_entitiesasusize..]
211
+
&self.entities
212
212
}
213
213
214
214
/// Get the valid table rows (i.e. non-disabled entities).
@@ -227,7 +227,11 @@ impl Table {
227
227
self.entities.capacity()
228
228
}
229
229
230
-
/// 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`.
230
+
/// Disables or enables the entity at `row` by swapping it with the first
231
+
/// enabled or disabled entity. Returns the swapped entities with their
232
+
/// respective table rows, or `None` if no swap occurred. If a
233
+
/// swap occurred, the caller is responsible for updating the entity's
234
+
/// location.
231
235
///
232
236
/// # Safety
233
237
/// `row` must be in-bounds (`row.as_usize()` < `self.len()`) and not disabled.
0 commit comments