#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Initializes the lockers
 *
 * Arguments:
 * N/A
 *
 * Return Value:
 * N/A
 *
 * Examples:
 * [] call forge_client_locker_fnc_initLocker;
 *
 * Public: Yes
 */

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

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

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

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

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

} forEach ("true" configClasses (missionConfigFile >> "CfgLockers" >> "lockers"));