Switch EntityWorldMut::retain to StaticBundle
This commit is contained in:
parent
28a21bdaf3
commit
c33033a5e7
@ -190,9 +190,9 @@ pub fn clear() -> impl EntityCommand {
|
||||
}
|
||||
|
||||
/// An [`EntityCommand`] that removes all components from an entity,
|
||||
/// except for those in the given [`Bundle`].
|
||||
/// except for those in the given [`StaticBundle`].
|
||||
#[track_caller]
|
||||
pub fn retain<T: Bundle>() -> impl EntityCommand {
|
||||
pub fn retain<T: StaticBundle>() -> impl EntityCommand {
|
||||
let caller = MaybeLocation::caller();
|
||||
move |mut entity: EntityWorldMut| {
|
||||
entity.retain_with_caller::<T>(caller);
|
||||
|
@ -1943,7 +1943,7 @@ impl<'a> EntityCommands<'a> {
|
||||
/// # bevy_ecs::system::assert_is_system(remove_combat_stats_system);
|
||||
/// ```
|
||||
#[track_caller]
|
||||
pub fn retain<B: Bundle>(&mut self) -> &mut Self {
|
||||
pub fn retain<B: StaticBundle>(&mut self) -> &mut Self {
|
||||
self.queue(entity_command::retain::<B>())
|
||||
}
|
||||
|
||||
|
@ -2151,12 +2151,15 @@ impl<'w> EntityWorldMut<'w> {
|
||||
///
|
||||
/// If the entity has been despawned while this `EntityWorldMut` is still alive.
|
||||
#[track_caller]
|
||||
pub fn retain<T: Bundle>(&mut self) -> &mut Self {
|
||||
pub fn retain<T: StaticBundle>(&mut self) -> &mut Self {
|
||||
self.retain_with_caller::<T>(MaybeLocation::caller())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn retain_with_caller<T: Bundle>(&mut self, caller: MaybeLocation) -> &mut Self {
|
||||
pub(crate) fn retain_with_caller<T: StaticBundle>(
|
||||
&mut self,
|
||||
caller: MaybeLocation,
|
||||
) -> &mut Self {
|
||||
let old_location = self.location();
|
||||
let archetypes = &mut self.world.archetypes;
|
||||
let storages = &mut self.world.storages;
|
||||
@ -2168,7 +2171,7 @@ impl<'w> EntityWorldMut<'w> {
|
||||
let retained_bundle = self
|
||||
.world
|
||||
.bundles
|
||||
.register_info::<T>(&mut registrator, storages);
|
||||
.register_static_info::<T>(&mut registrator, storages);
|
||||
// SAFETY: `retained_bundle` exists as we just initialized it.
|
||||
let retained_bundle_info = unsafe { self.world.bundles.get_unchecked(retained_bundle) };
|
||||
let old_archetype = &mut archetypes[old_location.archetype_id];
|
||||
|
Loading…
Reference in New Issue
Block a user