#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Initializes the arsenal system with armory and garage data
 *
 * Arguments:
 * 0: Armory data <ARRAY> - [items, weapons, magazines, backpacks]
 * 1: Garage data <ARRAY> - [cars, armor, helicopters, planes, naval, static]
 *
 * Return Value:
 * BOOLEAN - true if initialization successful, false if invalid data
 *
 * Example:
 * [[_items, _weapons, _magazines, _backpacks], [_cars, _armor, _helis, _planes, _naval, _statics]] call forge_client_arsenal_fnc_initArsenal
 */

params [["_armory_data", [], [[]]], ["_garage_data", [], [[]]]];

if (!(_armory_data isEqualTypeArray GVAR(default_armory)) || (count _armory_data != 4)) then { _armory_data = GVAR(default_armory); };
if (!(_garage_data isEqualTypeArray GVAR(default_garage)) || (count _garage_data != 6)) then { _garage_data = GVAR(default_garage); };
if (GVAR(armory_type) == 0) then {
    {
        [GVAR(gear_box), _x, false, true, 1, _forEachIndex] call BFUNC(addVirtualItemCargo);
    } forEach _armory_data;
} else {
    {
        [GVAR(gear_box), _x] call AFUNC(arsenal,addVirtualItems);
    } forEach _armory_data;
};

_armory_data params [["_items", [], [[]]], ["_weapons", [], [[]]], ["_magazines", [], [[]]], ["_backpacks", [], [[]]]];
_garage_data params [["_cars", [], [[]]], ["_armor", [], [[]]], ["_helis", [], [[]]], ["_planes", [], [[]]], ["_naval", [], [[]]], ["_statics", [], [[]]]];

GVAR(armory_unlocks) = _armory_data;
GVAR(garage_unlocks) = _garage_data;

GVAR(item_unlocks) = _items;
GVAR(weapon_unlocks) = _weapons;
GVAR(magazine_unlocks) = _magazines;
GVAR(backpack_unlocks) = _backpacks;

GVAR(car_unlocks) = _cars;
GVAR(armor_unlocks) = _armor;
GVAR(heli_unlocks) = _helis;
GVAR(plane_unlocks) = _planes;
GVAR(naval_unlocks) = _naval;
GVAR(static_unlocks) = _statics;

{
    [_x] call FUNC(addVirtualVehicles);
} forEach GVAR(garage_unlocks);