From 1f0181c834f5309e1021af5f08cae90b8f52bbd1 Mon Sep 17 00:00:00 2001 From: RJ Date: Mon, 11 Sep 2023 22:00:04 +0100 Subject: [PATCH] despawn_descendants when DespawnMarker detected --- src/lib.rs | 5 +---- src/systems.rs | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 294189d..d9399a1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,10 +202,7 @@ pub mod prelude { pub use crate::TimewarpSet; } -use bevy::{ - ecs::schedule::{BoxedSystemSet, ScheduleLabel}, - prelude::*, -}; +use bevy::prelude::*; use prelude::*; /// bevy_timewarp's systems run in these three sets, which get configured to run diff --git a/src/systems.rs b/src/systems.rs index ea3cd24..5e15b15 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -540,18 +540,18 @@ pub(crate) fn check_for_rollback_completion( /// despawn marker means remove all useful components, pending actual despawn after /// ROLLBACK_WINDOW frames have elapsed. pub(crate) fn remove_components_from_despawning_entities( - mut q: Query<(Entity, &mut ComponentHistory), (Added, With)>, + mut q: Query, With)>, mut commands: Commands, - game_clock: Res, ) { - for (entity, mut ct) in q.iter_mut() { + for entity in q.iter_mut() { debug!( "doing despawn marker component removal for {entity:?} / {:?}", std::any::type_name::() ); // record_component_death looks at RemovedComponents and will catch this, and // register the death (ie, comphist.report_death_at_frame) - commands.entity(entity).remove::(); + commands.entity(entity).remove::().despawn_descendants(); + // (also despawn any children, which in my game means the mesh/visual bits) } }