mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Move the litter cleanup PFH to a loop using waitAndExecute
This commit is contained in:
parent
4b702f68df
commit
90a54397ae
@ -117,3 +117,4 @@ PREP(unconsciousPFH);
|
||||
// Networked litter
|
||||
PREP(createLitter);
|
||||
PREP(handleCreateLitter);
|
||||
PREP(litterCleanupLoop);
|
||||
|
@ -44,22 +44,7 @@ if((count GVAR(allCreatedLitter)) > _maxLitterCount ) then {
|
||||
GVAR(allCreatedLitter) pushBack [ACE_time, [_litterObject]];
|
||||
|
||||
if(!GVAR(litterPFHRunning) && {GVAR(litterCleanUpDelay) > 0}) then {
|
||||
// Start the litter cleanup loop
|
||||
GVAR(litterPFHRunning) = true;
|
||||
[{
|
||||
{
|
||||
_x params ["_time", "_objects"];
|
||||
if (ACE_time - _time >= GVAR(litterCleanUpDelay)) then {
|
||||
{
|
||||
deleteVehicle _x;
|
||||
} forEach _objects;
|
||||
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;
|
||||
call FUNC(litterCleanupLoop);
|
||||
};
|
||||
|
33
addons/medical/functions/fnc_litterCleanupLoop.sqf
Normal file
33
addons/medical/functions/fnc_litterCleanupLoop.sqf
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Glowbal, esteldunedain
|
||||
* Loop that cleans up litter
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* ReturnValue:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
{
|
||||
_x params ["_time", "_objects"];
|
||||
if (ACE_time - _time >= GVAR(litterCleanUpDelay)) then {
|
||||
{
|
||||
deleteVehicle _x;
|
||||
} forEach _objects;
|
||||
GVAR(allCreatedLitter) set[_forEachIndex, objNull];
|
||||
};
|
||||
} forEach GVAR(allCreatedLitter);
|
||||
GVAR(allCreatedLitter) = GVAR(allCreatedLitter) - [objNull];
|
||||
|
||||
// If no more litter remaining, exit the loop
|
||||
if ( (count GVAR(allCreatedLitter)) == 0) exitWith {
|
||||
GVAR(litterPFHRunning) = false;
|
||||
};
|
||||
|
||||
// Schedule the loop to be executed again 30 sec later
|
||||
[DFUNC(litterCleanupLoop), [], 30] call EFUNC(common,waitAndExecute);
|
Loading…
Reference in New Issue
Block a user