ACE3/addons/medical/functions/fnc_handleCreateLitter.sqf

52 lines
1.8 KiB
Plaintext
Raw Normal View History

2015-04-18 18:37:06 +00:00
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
2015-04-18 18:37:06 +00:00
if(!hasInterface) exitWith { false };
PARAMS_3(_litterClass,_position,_direction);
private["_litterObject", "_maxLitterCount"];
2015-04-30 06:17:26 +00:00
//IGNORE_PRIVATE_WARNING(_values);
if (isNil QGVAR(allCreatedLitter)) then {
GVAR(allCreatedLitter) = [];
GVAR(litterPFHRunning) = false;
};
2015-04-18 18:37:06 +00:00
_litterObject = _litterClass createVehicleLocal _position;
_litterObject setDir _direction;
_litterObject setPosATL _position;
// Move the litter next frame to get rid of HORRIBLE spacing, fixes #1112
2015-05-14 14:15:52 +00:00
[{ (_this select 0) setPosATL (_this select 1); }, [_litterObject, _position]] call EFUNC(common,execNextFrame);
_maxLitterCount = getArray (configFile >> "ACE_Settings" >> QGVAR(litterSimulationDetail) >> "_values") select GVAR(litterSimulationDetail);
if((count GVAR(allCreatedLitter)) > _maxLitterCount ) then {
2015-04-18 18:37:06 +00:00
// gank the first litter object, and spawn ours.
private["_oldLitter"];
_oldLitter = GVAR(allCreatedLitter) deleteAt 0;
{
deleteVehicle _x;
} forEach (_oldLitter select 1);
};
GVAR(allCreatedLitter) pushBack [ACE_time, [_litterObject]];
2015-04-18 18:37:06 +00:00
if(!GVAR(litterPFHRunning) && {GVAR(litterCleanUpDelay) > 0}) then {
[{
{
if (ACE_time - (_x select 0) >= GVAR(litterCleanUpDelay)) then {
2015-04-18 18:37:06 +00:00
{
deleteVehicle _x;
} forEach (_x select 1);
2015-04-18 18:37:06 +00:00
GVAR(allCreatedLitter) set[_foreachIndex, objNull];
};
} forEach GVAR(allCreatedLitter);
2015-04-18 18:37:06 +00:00
GVAR(allCreatedLitter) = GVAR(allCreatedLitter) - [objNull];
if ( (count GVAR(allCreatedLitter)) == 0) exitwith {
[(_this select 1)] call CBA_fnc_removePerFrameHandler;
GVAR(litterPFHRunning) = false;
};
}, 30, []] call cba_fnc_addPerFrameHandler;
};
true