mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
45 lines
1.3 KiB
Plaintext
45 lines
1.3 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
// Delay between state runs
|
|
#define DELAY 10
|
|
#define DEFAULT_STATE [0, "Default", {}, {}, {}, []]
|
|
|
|
GVAR(monitoredUnitsList) = [];
|
|
GVAR(monitoredUnitsListIsSorted) = false;
|
|
|
|
[{
|
|
params ["_args", "_pfhId"];
|
|
|
|
if (!GVAR(monitoredUnitsListIsSorted)) then {
|
|
GVAR(monitoredUnitsList) sort true;
|
|
GVAR(monitoredUnitsListIsSorted) = true;
|
|
};
|
|
|
|
private _delete = false;
|
|
private _exit = false;
|
|
{
|
|
_x params ["_unit"];
|
|
|
|
if (!isNull _unit && alive _unit) then {
|
|
private _unitState = _unit getvariable [QGVAR(state), [CBA_missionTime, DEFAULT_STATE]];
|
|
_unitState params ["_lastTime", "_state"];
|
|
|
|
if ((_lastTime + DELAY) > CBA_missionTime) exitWith {_exit = true;};
|
|
_state params ["_name", "_handler", "_onEntry", "_onExit", "_transitions"];
|
|
_unitState set [0, CBA_missionTime];
|
|
|
|
_unit setvariable [QGVAR(state), _unitState];
|
|
|
|
[_unit, _name] call _handler;
|
|
} else {
|
|
_delete = true;
|
|
GVAR(monitoredUnitsList) set [_forEachIndex, objNull];
|
|
};
|
|
if (_exit) exitwith {};
|
|
} forEach GVAR(monitoredUnitsList);
|
|
|
|
if (_delete) then {
|
|
GVAR(monitoredUnitsList) = GVAR(monitoredUnitsList) - [objNull];
|
|
};
|
|
}, 0, []] call CBA_fnc_addPerFrameHandler;
|