use bevy::prelude::*;
use shared::{GameState, tb_entities::EnemySpawn};

pub fn plugin(app: &mut App) {
    app.add_systems(OnExit(GameState::MapLoading), despawn_enemy_spawns);
}

/// Despawn enemy spawners because only the server will ever spawn enemies with them, and they have a
/// collider.
fn despawn_enemy_spawns(mut commands: Commands, enemy_spawns: Query<Entity, With<EnemySpawn>>) {
    for spawner in enemy_spawns.iter() {
        commands.entity(spawner).despawn();
    }
}
