#include "..\script_component.hpp"

/*
 * File: fnc_initGarage.sqf
 * Author: IDSolutions
 * Date: 2025-12-17
 * Last Update: 2026-01-30
 * Public: No
 *
 * Description:
 * Initializes all garages defined in the mission configuration.
 *
 * Arguments:
 * None
 *
 * Return Value:
 * None
 *
 * Example:
 * call forge_server_garage_fnc_initGarage
 */

// TODO: Refactor to read from placed objects and their variables instead of missionConfig entries.

private _mC = "FORGE_CfgGarages";
private _garages = "true" configClasses (missionConfigFile >> "FORGE_CfgGarages" >> "garages");

{
	private _configName = configName(_x);
	private _className = (missionConfigFile >> _mC >> "garages" >> _configName >> "className") call BFUNC(getCfgData);
	private _pos = (missionConfigFile >> _mC >> "garages" >> _configName >> "pos") call BFUNC(getCfgData);
	private _dir = (missionConfigFile >> _mC >> "garages" >> _configName >> "dir") call BFUNC(getCfgData);
	private _garage = createSimpleObject [_className, [0, 0, 0]];

	_garage setPosATL _pos;
	_garage setDir _dir;
	_garage allowDamage false;
	_garage setVariable ["isGarage", true, true];

	diag_log format ["[FORGE:Server:Garage] ClassName: %1 Pos: %2 Dir: %3", _className, _pos, _dir];
} forEach _garages;
