#include "script_component.hpp"

if (isNil QGVAR(GarageClass)) then { call FUNC(initGarageClass); };
if (isNil QGVAR(VGarageClass)) then { call FUNC(initVGClass); };

[QGVAR(initGarage), {
    GVAR(GarageClass) call ["init", []];
}] call CFUNC(addEventHandler);

[QGVAR(responseInitGarage), {
    params [["_data", createHashMap, [createHashMap]]];

    GVAR(GarageClass) call ["sync", [_data, true]];
}] call CFUNC(addEventHandler);

[QGVAR(responseSyncGarage), {
    params [["_data", createHashMap, [createHashMap, []]], ["_jip", false, [false]]];

    GVAR(GarageClass) call ["sync", [_data, _jip]];
}] call CFUNC(addEventHandler);

[QGVAR(initVG), {
    GVAR(VGarageClass) call ["init", []];
}] call CFUNC(addEventHandler);

[QGVAR(responseInitVG), {
    params [["_data", createHashMap, [createHashMap]]];

    GVAR(VGarageClass) call ["sync", [_data, true]];
}] call CFUNC(addEventHandler);

[QGVAR(responseSyncVG), {
    params [["_data", createHashMap, [createHashMap, []]], ["_jip", false, [false]]];

    GVAR(VGarageClass) call ["sync", [_data, _jip]];
}] call CFUNC(addEventHandler);

[{
    EGVAR(bank,BankClass) get "isLoaded";
}, {
    [QGVAR(initGarage), []] call CFUNC(localEvent);
}] call CFUNC(waitUntilAndExecute);

[{
    GVAR(GarageClass) get "isLoaded";
}, {
    [QGVAR(initVG), []] call CFUNC(localEvent);
}] call CFUNC(waitUntilAndExecute);
