#include "..\script_component.hpp"

/*
 * Function: forge_client_bank_fnc_initBank
 * Author: IDSolutions
 *
 * [Description]
 * Initializes the bank system
 *
 * Arguments:
 * None
 *
 * Return Value:
 * None
 *
 * Examples:
 * None
 *
 * Public: Yes
 */

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

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

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

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

	diag_log text format ["[FORGE Bank] ClassName: '%1' Pos: '%2' Dir: '%3'", _className, _pos, _dir];
} forEach ("true" configClasses (missionConfigFile >> "CfgBanks" >> "banks"));