cleanup
This commit is contained in:
parent
343bba314c
commit
656d7f02f0
22
src/world.rs
22
src/world.rs
|
@ -172,7 +172,7 @@ fn spawn_despawn_asteroids(
|
|||
q_player: Query<&Position, With<actor::PlayerCamera>>,
|
||||
mut ew_despawn: EventWriter<DespawnEvent>,
|
||||
mut db: ResMut<ActiveAsteroids>,
|
||||
mut q_asteroid: Query<(Entity, &SceneInstance), With<Asteroid>>,
|
||||
mut q_asteroid: Query<&SceneInstance, With<Asteroid>>,
|
||||
mut last_player_cell: Local<I64Vec3>,
|
||||
id2pos: Res<actor::Id2Pos>,
|
||||
asset_server: Res<AssetServer>,
|
||||
|
@ -216,19 +216,13 @@ fn spawn_despawn_asteroids(
|
|||
|| origin.y < y_min || origin.y > y_max
|
||||
|| origin.z < z_min || origin.z > z_max
|
||||
{
|
||||
let mut despawning_worked = false;
|
||||
for (ent, sceneinstance) in &mut q_asteroid {
|
||||
if ent == asteroid.entity {
|
||||
ew_despawn.send(DespawnEvent {
|
||||
entity: asteroid.entity,
|
||||
sceneinstance: **sceneinstance,
|
||||
origin: origin.clone(),
|
||||
});
|
||||
despawning_worked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if !despawning_worked {
|
||||
if let Ok(sceneinstance) = q_asteroid.get(asteroid.entity) {
|
||||
ew_despawn.send(DespawnEvent {
|
||||
entity: asteroid.entity,
|
||||
sceneinstance: **sceneinstance,
|
||||
origin: origin.clone(),
|
||||
});
|
||||
} else {
|
||||
error!("Couldn't despawn asteroid:");
|
||||
dbg!(origin);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue