2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-02-29 02:20:26 +00:00
|
|
|
/*
|
2019-06-03 15:31:46 +00:00
|
|
|
* Author: Glowbal, esteldunedain, mharis001
|
|
|
|
* Handles cleaning up litter objects that have reached the end of their lifetime.
|
2016-02-29 02:20:26 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Return Value:
|
2016-02-29 02:20:26 +00:00
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
2019-06-03 15:31:46 +00:00
|
|
|
* [] call ace_medical_treatment_fnc_litterCleanupLoop
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
2016-02-29 02:20:26 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
{
|
2019-06-03 15:31:46 +00:00
|
|
|
_x params ["_object", "_timeCreated"];
|
2016-09-19 07:55:30 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
// Litter array has older objects at the beginning
|
|
|
|
// Can exit on first element that still has lifetime remaining
|
|
|
|
if (CBA_missionTime - _timeCreated < GVAR(litterCleanupDelay)) exitWith {};
|
2016-09-19 07:55:30 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
deleteVehicle _object;
|
|
|
|
GVAR(litterObjects) set [_forEachIndex, objNull];
|
|
|
|
} forEach GVAR(litterObjects);
|
2016-09-19 07:55:30 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
GVAR(litterObjects) = GVAR(litterObjects) - [objNull];
|
2016-09-19 07:55:30 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
// Exit the loop if no litter objects left
|
|
|
|
if (GVAR(litterObjects) isEqualTo []) exitWith {
|
|
|
|
GVAR(litterCleanup) = false;
|
2016-02-29 02:20:26 +00:00
|
|
|
};
|
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
// Schedule cleanup loop to executed again
|
|
|
|
[FUNC(litterCleanupLoop), [], LITTER_CLEANUP_CHECK_DELAY] call CBA_fnc_waitAndExecute;
|