use bevy::prelude::*;
use ops::sin;

#[derive(Component, Reflect)]
#[reflect(Component)]
pub struct SquishAnimation(pub f32);

pub fn plugin(app: &mut App) {
    app.add_systems(Update, update);
}

fn update(mut query: Query<(&mut Transform, &SquishAnimation)>, time: Res<Time>) {
    for (mut transform, keymesh) in query.iter_mut() {
        transform.scale = Vec3::new(
            keymesh.0,
            keymesh.0 + (sin(time.elapsed_secs() * 6.) * 0.2),
            keymesh.0,
        );
    }
}
