use glam::Quat;

use crate::world::World;

pub fn rotate_system(world: &mut World, delta: f32)
{
    let entities = world.rotates.all();

    for entity in entities
    {
        if let Some(rotate) = world.rotates.get(entity)
        {
            let rotation_delta = Quat::from_axis_angle(rotate.axis, rotate.speed * delta);

            world.transforms.with_mut(entity, |transform| {
                transform.rotation = rotation_delta * transform.rotation;
            });
        }
    }
}
