rename update and declare
This commit is contained in:
parent
d42d9eae2e
commit
bac7bd2c4d
@ -1222,7 +1222,7 @@ impl<'w> BundleInserter<'w> {
|
||||
let swapped_location =
|
||||
// SAFETY: If the swap was successful, swapped_entity must be valid.
|
||||
unsafe { entities.get_constructed(swapped_entity).debug_checked_unwrap() };
|
||||
entities.update(
|
||||
entities.update_location(
|
||||
swapped_entity.row(),
|
||||
Some(EntityLocation {
|
||||
archetype_id: swapped_location.archetype_id,
|
||||
@ -1233,7 +1233,7 @@ impl<'w> BundleInserter<'w> {
|
||||
);
|
||||
}
|
||||
let new_location = new_archetype.allocate(entity, result.table_row);
|
||||
entities.update(entity.row(), Some(new_location));
|
||||
entities.update_location(entity.row(), Some(new_location));
|
||||
let after_effect = bundle_info.write_components(
|
||||
table,
|
||||
sparse_sets,
|
||||
@ -1271,7 +1271,7 @@ impl<'w> BundleInserter<'w> {
|
||||
let swapped_location =
|
||||
// SAFETY: If the swap was successful, swapped_entity must be valid.
|
||||
unsafe { entities.get_constructed(swapped_entity).debug_checked_unwrap() };
|
||||
entities.update(
|
||||
entities.update_location(
|
||||
swapped_entity.row(),
|
||||
Some(EntityLocation {
|
||||
archetype_id: swapped_location.archetype_id,
|
||||
@ -1285,7 +1285,7 @@ impl<'w> BundleInserter<'w> {
|
||||
// redundant copies
|
||||
let move_result = table.move_to_superset_unchecked(result.table_row, new_table);
|
||||
let new_location = new_archetype.allocate(entity, move_result.new_row);
|
||||
entities.update(entity.row(), Some(new_location));
|
||||
entities.update_location(entity.row(), Some(new_location));
|
||||
|
||||
// If an entity was moved into this entity's table spot, update its table row.
|
||||
if let Some(swapped_entity) = move_result.swapped_entity {
|
||||
@ -1293,7 +1293,7 @@ impl<'w> BundleInserter<'w> {
|
||||
// SAFETY: If the swap was successful, swapped_entity must be valid.
|
||||
unsafe { entities.get_constructed(swapped_entity).debug_checked_unwrap() };
|
||||
|
||||
entities.update(
|
||||
entities.update_location(
|
||||
swapped_entity.row(),
|
||||
Some(EntityLocation {
|
||||
archetype_id: swapped_location.archetype_id,
|
||||
@ -1612,7 +1612,7 @@ impl<'w> BundleRemover<'w> {
|
||||
if let Some(swapped_entity) = remove_result.swapped_entity {
|
||||
let swapped_location = world.entities.get_constructed(swapped_entity).unwrap();
|
||||
|
||||
world.entities.update(
|
||||
world.entities.update_location(
|
||||
swapped_entity.row(),
|
||||
Some(EntityLocation {
|
||||
archetype_id: swapped_location.archetype_id,
|
||||
@ -1653,7 +1653,7 @@ impl<'w> BundleRemover<'w> {
|
||||
if let Some(swapped_entity) = move_result.swapped_entity {
|
||||
let swapped_location = world.entities.get_constructed(swapped_entity).unwrap();
|
||||
|
||||
world.entities.update(
|
||||
world.entities.update_location(
|
||||
swapped_entity.row(),
|
||||
Some(EntityLocation {
|
||||
archetype_id: swapped_location.archetype_id,
|
||||
@ -1676,7 +1676,9 @@ impl<'w> BundleRemover<'w> {
|
||||
|
||||
// SAFETY: The entity is valid and has been moved to the new location already.
|
||||
unsafe {
|
||||
world.entities.update(entity.row(), Some(new_location));
|
||||
world
|
||||
.entities
|
||||
.update_location(entity.row(), Some(new_location));
|
||||
}
|
||||
|
||||
(new_location, pre_remove_result)
|
||||
@ -1790,7 +1792,7 @@ impl<'w> BundleSpawner<'w> {
|
||||
caller,
|
||||
);
|
||||
|
||||
let was_at = entities.declare(entity.row(), Some(location));
|
||||
let was_at = entities.new_location(entity.row(), Some(location));
|
||||
// We need to assert here.
|
||||
// Even if we can ensure that this entity is fresh from an allocator,
|
||||
// it does not prevent users constructing arbitrary rows, which may overlap with the allocator.
|
||||
|
@ -1013,7 +1013,7 @@ impl Entities {
|
||||
/// - `location` must be valid for the entity at `row` or immediately made valid afterwards
|
||||
/// before handing control to unknown code.
|
||||
#[inline]
|
||||
pub(crate) unsafe fn update(
|
||||
pub(crate) unsafe fn update_location(
|
||||
&mut self,
|
||||
row: EntityRow,
|
||||
location: EntityIdLocation,
|
||||
@ -1031,14 +1031,14 @@ impl Entities {
|
||||
/// - `location` must be valid for the entity at `row` or immediately made valid afterwards
|
||||
/// before handing control to unknown code.
|
||||
#[inline]
|
||||
pub(crate) unsafe fn declare(
|
||||
pub(crate) unsafe fn new_location(
|
||||
&mut self,
|
||||
row: EntityRow,
|
||||
location: EntityIdLocation,
|
||||
) -> EntityIdLocation {
|
||||
self.ensure_row_index_is_valid(row);
|
||||
// SAFETY: We just did `ensure_row`
|
||||
self.update(row, location)
|
||||
self.update_location(row, location)
|
||||
}
|
||||
|
||||
/// Ensures the row is within the bounds of [`Self::meta`], expanding it if necessary.
|
||||
|
@ -2468,7 +2468,7 @@ impl<'w> EntityWorldMut<'w> {
|
||||
}
|
||||
// SAFETY: Since we had a location, and it was valid, this is safe.
|
||||
unsafe {
|
||||
let was_at = self.world.entities.update(self.entity.row(), None);
|
||||
let was_at = self.world.entities.update_location(self.entity.row(), None);
|
||||
debug_assert_eq!(was_at, Some(location));
|
||||
self.world
|
||||
.entities
|
||||
@ -2485,7 +2485,7 @@ impl<'w> EntityWorldMut<'w> {
|
||||
// SAFETY: swapped_entity is valid and the swapped entity's components are
|
||||
// moved to the new location immediately after.
|
||||
unsafe {
|
||||
self.world.entities.update(
|
||||
self.world.entities.update_location(
|
||||
swapped_entity.row(),
|
||||
Some(EntityLocation {
|
||||
archetype_id: swapped_location.archetype_id,
|
||||
@ -2520,7 +2520,7 @@ impl<'w> EntityWorldMut<'w> {
|
||||
// SAFETY: `moved_entity` is valid and the provided `EntityLocation` accurately reflects
|
||||
// the current location of the entity and its component data.
|
||||
unsafe {
|
||||
self.world.entities.update(
|
||||
self.world.entities.update_location(
|
||||
moved_entity.row(),
|
||||
Some(EntityLocation {
|
||||
archetype_id: moved_location.archetype_id,
|
||||
|
@ -1205,7 +1205,7 @@ impl World {
|
||||
// empty
|
||||
let location = archetype.allocate(entity, table_row);
|
||||
let change_tick = self.change_tick();
|
||||
let was_at = self.entities.declare(entity.row(), Some(location));
|
||||
let was_at = self.entities.new_location(entity.row(), Some(location));
|
||||
assert!(
|
||||
was_at.is_none(),
|
||||
"Attempting to construct an empty entity, but it was already constructed."
|
||||
|
Loading…
Reference in New Issue
Block a user