#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Adds item to player's armory unlocks and updates virtual arsenal
 *
 * Arguments:
 * 0: Classname of item to add <STRING>
 * 1: Type of item to add <STRING>
 *
 * Return Value:
 * None
 *
 * Examples:
 * ["B_AssaultPack_rgr", "backpack"] call forge_client_arsenal_fnc_addArmoryItem
 *
 * Public: Yes
 */

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

private _armory_unlocks = GETVAR(player,Armory_Unlocks,GVAR(default_armory));
private _typeToNumber = switch (_type) do {
    case "facewear";
    case "headgear";
    case "hmd";
    case "item";
    case "uniform";
    case "vest": {0};
    case "weapon": {1};
    case "magazine": {2};
    case "backpack": {3};
    default {0};
};

private _index = (_armory_unlocks select _typeToNumber) pushBackUnique _class;

if (_index > -1) then {
    SETPVAR(player,Armory_Unlocks,_armory_unlocks);
    
    if (GVAR(armory_type) == 0) then {
        [GVAR(gear_box), [_class], false, true, 1, _typeToNumber] call BFUNC(addVirtualItemCargo);
    } else {
        [GVAR(gear_box), [_class]] call AFUNC(arsenal,addVirtualItems);
    };

    true
} else {
    false
};