ACE3/addons/modules/XEH_postInit.sqf

53 lines
2.2 KiB
Plaintext
Raw Normal View History

2015-03-22 11:39:26 +00:00
#include "script_component.hpp"
["InitSettingsFromModules", {
// TODO This is a basic and limited implementation that mimics some of the functionality from the A3 module framework, but not all of it.
// We have to execute this in the postInit XEH because on object init, the parameters of the modules are not yet available. They are if we execute it at the start of postInit execution.
2015-11-17 20:02:20 +00:00
private _uniqueModulesHandled = [];
{
[_x] call {
params ["_logic"];
2015-11-17 20:02:20 +00:00
private _logicType = typeof _logic;
_logic hideobject true;
2015-03-22 11:39:26 +00:00
if (_logic getvariable [QGVAR(initalized), false]) exitwith {};
2015-11-17 20:02:20 +00:00
private _config = (configFile >> "CfgVehicles" >> _logicType);
if !(isClass _config) exitwith {};
2015-03-22 11:39:26 +00:00
2015-11-17 20:02:20 +00:00
private _isGlobal = getNumber (_config >> "isGlobal") > 0;
private _isDisposable = getNumber (_config >> "isDisposable") > 0;
private _isPersistent = getNumber (_config >> "isPersistent") > 0 || getnumber (_config >> "isGlobal") > 1;
private _isSingular = getNumber (_config >> "isSingular") > 0;
private _function = getText (_config >> "function");
if (isnil _function) then {
_function = compile _function;
} else {
_function = missionNamespace getvariable _function;
};
if (_isSingular && {_logicType in _uniqueModulesHandled}) then { //ToDo: should this be an exit?
ACE_LOGWARNING_1("Module [%1] - More than 1 singular module placed", _logicType);
};
if (_isSingular) then {_uniqueModulesHandled pushBack _logicType;};
2015-03-22 11:39:26 +00:00
if (_isGlobal || isServer) then {
[_logic, (synchronizedObjects _logic), true] call _function;
2015-03-22 11:45:46 +00:00
};
2015-03-22 11:39:26 +00:00
if !(_isPersistent) then {
_logic setvariable [QGVAR(initalized), true];
};
2015-03-22 11:39:26 +00:00
if (_isDisposable) then {
deleteVehicle _logic;
};
2015-03-22 11:45:46 +00:00
};
} forEach GVAR(moduleInitCollection);
if (isServer) then {
GVAR(serverModulesRead) = true;
publicVariable QGVAR(serverModulesRead);
};
2015-06-02 17:15:58 +00:00
}] call EFUNC(common,addEventhandler);