use_script("utils.lua");
use_script("rotate.lua");

function export_steam_generator(running_state_name)
    local templ = vsp_from_assets("templates/steamGenerator/steamGenerator" .. running_state_name .. ".vsp");

    for side = 0, 3 do
        local state_name = "output" .. get_side_name(side) .. running_state_name;
        local rotated_templ = rotate_sprite(templ, side);

        local colormap = vsp_clone(rotated_templ);
        local color_values = {};
        color_values[color_from_rgb(0, 255, 0)] = color_from_rgb(0x6F, 0x1F, 0x00);
        color_values[color_from_rgb(0, 0, 255)] = color_from_rgb(0x44, 0x44, 0x44);
        vsp_color_remap(colormap, color_values);

        local biasmap = vsp_clone(rotated_templ);
        local bias_values = {};
        bias_values[color_from_rgb(0, 255, 0)] = color_from_rgb(4, 8, 8);
        color_values[color_from_rgb(0, 0, 255)] = color_from_rgb(0, 0, 8);
        vsp_color_remap_with_default(biasmap, bias_values, 0);

        local lightspecmap = vsp_clone(rotated_templ);
        local lightspec_values = {};
        lightspec_values[color_from_rgb(0xFF, 0x3F, 0x00)] = WHITE;
        lightspec_values[color_from_rgb(0xBB, 0x2E, 0x00)] = WHITE;
        vsp_color_remap_with_default(lightspecmap, lightspec_values, 0);

        export_frame(state_name, {
            colormap = colormap,
            biasmap = biasmap,
            lightspecmap = lightspecmap,
        })
    end
end

export_steam_generator("Off");
export_steam_generator("On");