#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Initializes the garages
 *
 * Arguments:
 * None
 *
 * Return Value:
 * None
 *
 * Example:
 * None
 *
 * Public: No
 */

{
	private _configName = configName(_x);
	private _className = (missionConfigFile >> "CfgGarages" >> "garages" >> _configName >> "className") call BFUNC(getCfgData);
	private _pos = (missionConfigFile >> "CfgGarages" >> "garages" >> _configName >> "pos") call BFUNC(getCfgData);
	private _dir = (missionConfigFile >> "CfgGarages" >> "garages" >> _configName >> "dir") call BFUNC(getCfgData);
    private _type = (missionConfigFile >> "CfgGarages" >> "garages" >> _configName >> "type") call BFUNC(getCfgData);

	if (_type == "object") then {
        private _garage = createSimpleObject [_className, [0, 0, 0]];

        _garage setPosATL _pos;
	    _garage setDir _dir;
	    _garage allowDamage false;
	    _garage setVariable ["isGarage", true, true];
    } else {
        private _group = createGroup civilian;
        private _garage = _group createUnit [_className, [0, 0, 0], [], 0, "NONE"];

		_garage disableAI "MOVE";
        _garage setPosATL _pos;
	    _garage setDir _dir;
	    _garage allowDamage false;
	    _garage setVariable ["isGarage", true, true];
		_garage setVariable ["BIS_enableRandomization", false];
    };

	diag_log text format ["[FORGE Garage] ClassName: '%1' Pos: '%2' Dir: '%3' Type: '%4'", _className, _pos, _dir, _type];

} forEach ("true" configClasses (missionConfigFile >> "CfgGarages" >> "garages"));