mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
handle cleanup
This commit is contained in:
parent
852b4df61d
commit
e54c68f7f9
@ -1,4 +1,8 @@
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
if(!hasInterface) exitWith { false };
|
||||
|
||||
PARAMS_3(_litterClass,_position,_direction);
|
||||
private["_litterObject"];
|
||||
|
||||
@ -7,15 +11,37 @@ if (isNil QGVAR(allCreatedLitter)) then {
|
||||
GVAR(litterPFHRunning) = false;
|
||||
};
|
||||
|
||||
if((count GVAR(allCreatedLitter)) <= GVAR(litterSimulationDetail) ) then {
|
||||
_litterObject = _litterClass createVehicleLocal _position;
|
||||
_litterObject setDir _direction;
|
||||
} else {
|
||||
// @TODO: We hit max litter items, remove a few of them to work with what we have.
|
||||
// Basically, we should just start FIFO'ing these
|
||||
_litterObject = _litterClass createVehicleLocal _position;
|
||||
_litterObject setDir _direction;
|
||||
|
||||
if((count GVAR(allCreatedLitter)) > GVAR(litterSimulationDetail) ) then {
|
||||
// gank the first litter object, and spawn ours.
|
||||
private["_oldLitter"];
|
||||
_oldLitter = GVAR(allCreatedLitter) deleteAt 0;
|
||||
{
|
||||
deleteVehicle _x;
|
||||
} forEach (_oldLitter select 1);
|
||||
};
|
||||
|
||||
GVAR(allCreatedLitter) pushBack _litterObject;
|
||||
//GVAR(allCreatedLitter) = GVAR(allCreatedLitter) - [objNull];
|
||||
GVAR(allCreatedLitter) pushBack [time, [_litterObject]];
|
||||
|
||||
if(!GVAR(litterPFHRunning) && {GVAR(litterCleanUpDelay) > 0}) then {
|
||||
[{
|
||||
{
|
||||
if (time - (_x select 0) >= GVAR(litterCleanUpDelay)) then {
|
||||
{
|
||||
deleteVehicle _x;
|
||||
} foreach (_this select 1);
|
||||
GVAR(allCreatedLitter) set[_foreachIndex, objNull];
|
||||
};
|
||||
}foreach GVAR(allCreatedLitter);
|
||||
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
|
Loading…
Reference in New Issue
Block a user