2015-08-22 14:25:10 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* handle Litter Create
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Litter Class <STRING>
|
|
|
|
* 1: Position <ARRAY>
|
|
|
|
* 2: Unit <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-04-18 15:31:03 +00:00
|
|
|
#include "script_component.hpp"
|
2015-04-18 18:37:06 +00:00
|
|
|
|
|
|
|
if(!hasInterface) exitWith { false };
|
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
params ["_litterClass", "_position", "_unit"];
|
2015-04-19 16:04:42 +00:00
|
|
|
private["_litterObject", "_maxLitterCount"];
|
2015-04-30 06:17:26 +00:00
|
|
|
//IGNORE_PRIVATE_WARNING(_values);
|
2015-04-18 15:31:03 +00:00
|
|
|
|
2015-04-18 18:16:18 +00:00
|
|
|
if (isNil QGVAR(allCreatedLitter)) then {
|
2015-04-18 15:31:03 +00:00
|
|
|
GVAR(allCreatedLitter) = [];
|
|
|
|
GVAR(litterPFHRunning) = false;
|
|
|
|
};
|
|
|
|
|
2015-04-18 18:37:06 +00:00
|
|
|
_litterObject = _litterClass createVehicleLocal _position;
|
|
|
|
_litterObject setDir _direction;
|
2015-05-14 00:29:09 +00:00
|
|
|
_litterObject setPosATL _position;
|
|
|
|
// Move the litter next frame to get rid of HORRIBLE spacing, fixes #1112
|
2015-08-22 14:25:10 +00:00
|
|
|
[{ params ["_object", "_pos"]; _object setPosATL _pos; }, [_litterObject, _position]] call EFUNC(common,execNextFrame);
|
|
|
|
|
|
|
|
_maxLitterCount = getArray (configFile >> "ACE_Settings" >> QGVAR(litterSimulationDetail) >> "_values") select GVAR(litterSimulationDetail);
|
2015-04-19 16:04:42 +00:00
|
|
|
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);
|
2015-04-18 15:31:03 +00:00
|
|
|
};
|
|
|
|
|
2015-05-21 16:42:44 +00:00
|
|
|
GVAR(allCreatedLitter) pushBack [ACE_time, [_litterObject]];
|
2015-04-18 18:37:06 +00:00
|
|
|
|
|
|
|
if(!GVAR(litterPFHRunning) && {GVAR(litterCleanUpDelay) > 0}) then {
|
2015-08-06 05:28:43 +00:00
|
|
|
GVAR(litterPFHRunning) = true;
|
2015-04-18 18:37:06 +00:00
|
|
|
[{
|
|
|
|
{
|
2015-08-22 14:25:10 +00:00
|
|
|
_x params ["_time", "_objects"];
|
|
|
|
if (ACE_time - _time >= GVAR(litterCleanUpDelay)) then {
|
2015-04-18 18:37:06 +00:00
|
|
|
{
|
|
|
|
deleteVehicle _x;
|
2015-08-22 14:25:10 +00:00
|
|
|
} forEach _objects;
|
2015-11-30 16:23:48 +00:00
|
|
|
GVAR(allCreatedLitter) set[_forEachIndex, objNull];
|
2015-04-18 18:37:06 +00:00
|
|
|
};
|
2015-04-18 18:48:44 +00:00
|
|
|
} forEach GVAR(allCreatedLitter);
|
2015-04-18 18:37:06 +00:00
|
|
|
GVAR(allCreatedLitter) = GVAR(allCreatedLitter) - [objNull];
|
|
|
|
|
2015-11-30 16:14:05 +00:00
|
|
|
if ( (count GVAR(allCreatedLitter)) == 0) exitWith {
|
2015-04-18 18:37:06 +00:00
|
|
|
[(_this select 1)] call CBA_fnc_removePerFrameHandler;
|
|
|
|
GVAR(litterPFHRunning) = false;
|
2015-08-22 14:25:10 +00:00
|
|
|
};
|
2015-08-04 07:34:31 +00:00
|
|
|
}, 30, []] call CBA_fnc_addPerFrameHandler;
|
2015-04-18 18:37:06 +00:00
|
|
|
};
|