mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Move the dead body cleanup PFH to a loop using waitAndExecute
This commit is contained in:
parent
90a54397ae
commit
9e682253f3
@ -18,6 +18,7 @@ PREP(addUnconsciousCondition);
|
||||
PREP(addUnloadPatientActions);
|
||||
PREP(addVitalLoop);
|
||||
PREP(adjustPainLevel);
|
||||
PREP(bodyCleanupLoop);
|
||||
PREP(canAccessMedicalEquipment);
|
||||
PREP(canTreat);
|
||||
PREP(canTreatCached);
|
||||
|
30
addons/medical/functions/fnc_bodyCleanupLoop.sqf
Normal file
30
addons/medical/functions/fnc_bodyCleanupLoop.sqf
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Author: Glowbal, esteldunedain
|
||||
* Loop that cleans up litter
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* ReturnValue:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
{
|
||||
TRACE_2("body",_x,isPlayer _x);
|
||||
if ((!isNull _x) && {!isPlayer _x}) then {deleteVehicle _x};
|
||||
} forEach GVAR(bodiesToDelete);
|
||||
|
||||
// deleteVehicle doesn't have instant results so it won't usualy be filtered until next run
|
||||
GVAR(bodiesToDelete) = GVAR(bodiesToDelete) - [objNull];
|
||||
|
||||
// If no more bodies remain, exit the loop
|
||||
if (GVAR(bodiesToDelete) isEqualTo []) exitWith {
|
||||
TRACE_1("array emptied - rem PFEH",GVAR(bodiesToDelete));
|
||||
};
|
||||
|
||||
// Schedule the loop to be executed again 20 sec later
|
||||
[DFUNC(bodyCleanupLoop), [], 20] call EFUNC(common,waitAndExecute);
|
@ -26,23 +26,9 @@ TRACE_2("",_target,isPlayer _target);
|
||||
if (isNil QGVAR(bodiesToDelete)) then {GVAR(bodiesToDelete) = [];};
|
||||
GVAR(bodiesToDelete) pushBack _target;
|
||||
|
||||
//Start up PFEH to wait for bodies to be free to delete
|
||||
if ((count GVAR(bodiesToDelete)) == 1) then {
|
||||
TRACE_1("starting PFEH",GVAR(bodiesToDelete));
|
||||
[{
|
||||
{
|
||||
TRACE_2("body",_x,isPlayer _x);
|
||||
if ((!isNull _x) && {!isPlayer _x}) then {deleteVehicle _x};
|
||||
} forEach GVAR(bodiesToDelete);
|
||||
|
||||
//deleteVehicle doesn't have instant results so it won't usualy be filtered until next run
|
||||
GVAR(bodiesToDelete) = GVAR(bodiesToDelete) - [objNull];
|
||||
|
||||
if (GVAR(bodiesToDelete) isEqualTo []) then {
|
||||
TRACE_1("array emptied - rem PFEH",GVAR(bodiesToDelete));
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
}, 20, []] call CBA_fnc_addPerFrameHandler;
|
||||
// Start up a loop to wait for bodies to be free to delete
|
||||
if ((count GVAR(bodiesToDelete)) > 0) then {
|
||||
[] call FUNC(bodyCleanupLoop);
|
||||
};
|
||||
|
||||
nil
|
||||
|
Loading…
Reference in New Issue
Block a user