#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Adds vehicle to player's garage unlocks and updates virtual garage
 */


params [["_class", "", [""]], ["_type", "", [""]]];

private _default = [[],[],[],[],[],[]];
// private _garage_unlocks = player getVariable ["Garage_Unlocks", _default];
private _garage_unlocks = GETVAR(player,Garage_Unlocks,_default);

private _typeToNumber = switch (_type) do {
    case "car": {0};
    case "armor": {1};
    case "heli": {2};
    case "plane": {3};
    case "naval": {4};
    case "static": {5};
    default {0};
};

private _index = (_garage_unlocks select _typeToNumber) pushBackUnique _class;

if (_index > -1) then {
    // player setVariable ["Garage_Unlocks", _garage_unlocks, true];
    SETPVAR(player,Garage_Unlocks,_garage_unlocks);
    [[_class]] call FUNC(addVirtualVehicles);
    
    TRACE_2("Vehicle added to garage",_class,_type);
    true
} else {
    false
};