fix: don't recursivly despawn entities that handles depsawning themselfs
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -3,6 +3,8 @@ use std::sync::Arc;
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::nodes::spatial::SpatialNode;
|
||||
|
||||
use super::bevy_channel::{BevyChannel, BevyChannelReader};
|
||||
pub struct EntityHandlePlugin;
|
||||
|
||||
@@ -13,9 +15,21 @@ impl Plugin for EntityHandlePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn despawn(mut cmds: Commands, mut reader: ResMut<BevyChannelReader<Entity>>) {
|
||||
fn despawn(
|
||||
mut cmds: Commands,
|
||||
mut reader: ResMut<BevyChannelReader<Entity>>,
|
||||
child_query: Query<&Children>,
|
||||
has_spatial: Query<Has<SpatialNode>>,
|
||||
) {
|
||||
while let Some(e) = reader.read() {
|
||||
cmds.entity(e).try_despawn();
|
||||
if let Ok(children) = child_query.get(e) {
|
||||
for e in children {
|
||||
if has_spatial.get(*e).unwrap_or_default() {
|
||||
cmds.entity(*e).remove::<ChildOf>();
|
||||
}
|
||||
}
|
||||
}
|
||||
cmds.entity(e).despawn();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ pub struct TextNodePlugin;
|
||||
impl Plugin for TextNodePlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
// Text init stuff
|
||||
// 1.0 for font size in meters
|
||||
app.add_plugins(MeshTextPlugin);
|
||||
app.world_mut()
|
||||
.resource_mut::<FontSettings>()
|
||||
|
||||
Reference in New Issue
Block a user