use crate::world::World;

pub fn state_machine_system(world: &mut World, delta: f32)
{
    for entity in world.state_machines.all()
    {
        if let Some(mut state_machine) = world.state_machines.components.remove(&entity)
        {
            state_machine.update(world, entity, delta);
            world
                .state_machines
                .components
                .insert(entity, state_machine);
        }
    }
}

pub fn state_machine_physics_system(world: &mut World, delta: f32)
{
    for entity in world.state_machines.all()
    {
        if let Some(mut state_machine) = world.state_machines.components.remove(&entity)
        {
            state_machine.physics_update(world, entity, delta);
            world
                .state_machines
                .components
                .insert(entity, state_machine);
        }
    }
}
