#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Adds vehicles to virtual garage and categorizes them by type
 *
 * Arguments:
 * 0: Vehicles <ARRAY> - Array of vehicle classnames
 *
 * Return Value:
 * None
 *
 * Examples:
 * ["B_T_LSV_01_unarmed_F", "car"] call forge_client_arsenal_fnc_addVirtualVehicles
 *
 * Public: Yes
 */

params [["_vehicles", [], [[]]]];

private _garage_unlocks = GETVAR(player,Garage_Unlocks,GVAR(default_garage));
_garage_unlocks params ["_cars", "_armor", "_helis", "_planes", "_naval", "_static"];

{
    switch true do {
        case (_x isKindOf "Car"): {
            if ((_x isKindOf "Tank") || (_x isKindOf "Wheeled_APC_F")) exitWith {};
            _cars pushBackUnique _x;
        };
        case (_x isKindOf "Tank"): { _armor pushBackUnique _x; };
        case (_x isKindOf "Helicopter"): { _helis pushBackUnique _x; };
        case (_x isKindOf "Plane"): { _planes pushBackUnique _x; };
        case (_x isKindOf "Ship"): { _naval pushBackUnique _x; };
        case (_x isKindOf "Static"): { _static pushBackUnique _x; };
    };
} forEach _vehicles;

{
    GVAR(car_unlocks) append [getText(configFile >> "CfgVehicles" >> _x >> "model"),[configFile >> "CfgVehicles" >> _x]];
} forEach _cars;

{
    GVAR(armor_unlocks) append [getText(configFile >> "CfgVehicles" >> _x >> "model"),[configFile >> "CfgVehicles" >> _x]];
} forEach _armor;

{
    GVAR(heli_unlocks) append [getText(configFile >> "CfgVehicles" >> _x >> "model"),[configFile >> "CfgVehicles" >> _x]];
} forEach _helis;

{
    GVAR(plane_unlocks) append [getText(configFile >> "CfgVehicles" >> _x >> "model"),[configFile >> "CfgVehicles" >> _x]];
} forEach _planes;

{
    GVAR(naval_unlocks) append [getText(configFile >> "CfgVehicles" >> _x >> "model"),[configFile >> "CfgVehicles" >> _x]];
} forEach _naval;

{
    GVAR(static_unlocks) append [getText(configFile >> "CfgVehicles" >> _x >> "model"),[configFile >> "CfgVehicles" >> _x]];
} forEach _static;