|
1 | | -use crate::{entity::Entity, world::World}; |
| 1 | +use crate::{entity::Entity, identifier::masks::IdentifierMask, world::World}; |
2 | 2 | use bevy_utils::EntityHashMap; |
3 | 3 |
|
4 | | -use super::inc_generation_by; |
5 | | - |
6 | 4 | /// Operation to map all contained [`Entity`] fields in a type to new values. |
7 | 5 | /// |
8 | 6 | /// As entity IDs are valid only for the [`World`] they're sourced from, using [`Entity`] |
@@ -70,10 +68,10 @@ impl<'m> EntityMapper<'m> { |
70 | 68 | } |
71 | 69 |
|
72 | 70 | // this new entity reference is specifically designed to never represent any living entity |
73 | | - let new = Entity { |
74 | | - generation: inc_generation_by(self.dead_start.generation, self.generations), |
75 | | - index: self.dead_start.index, |
76 | | - }; |
| 71 | + let new = Entity::new( |
| 72 | + self.dead_start.index(), |
| 73 | + IdentifierMask::inc_masked_high_by(self.dead_start.generation, self.generations), |
| 74 | + ); |
77 | 75 | self.generations += 1; |
78 | 76 |
|
79 | 77 | self.map.insert(entity, new); |
@@ -109,7 +107,7 @@ impl<'m> EntityMapper<'m> { |
109 | 107 | // SAFETY: Entities data is kept in a valid state via `EntityMap::world_scope` |
110 | 108 | let entities = unsafe { world.entities_mut() }; |
111 | 109 | assert!(entities.free(self.dead_start).is_some()); |
112 | | - assert!(entities.reserve_generations(self.dead_start.index, self.generations)); |
| 110 | + assert!(entities.reserve_generations(self.dead_start.index(), self.generations)); |
113 | 111 | } |
114 | 112 |
|
115 | 113 | /// Creates an [`EntityMapper`] from a provided [`World`] and [`EntityHashMap<Entity, Entity>`], then calls the |
|
0 commit comments