ACE3/addons/overheating/functions/fnc_updateSpareBarrelsTemperaturesThread.sqf

36 lines
1.2 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2016-02-27 03:29:30 +00:00
/*
* Author: esteldunedain
* Calculate cooldown of all the stored spare barrels.
*
2016-06-18 09:50:41 +00:00
* Arguments:
2016-02-27 03:29:30 +00:00
* None
*
2016-06-18 09:50:41 +00:00
* Return Value:
2016-02-27 03:29:30 +00:00
* None
*
* Example:
* [] call ace_overheating_fnc_updateSpareBarrelsTemperaturesThread
*
* Public: No
*/
TRACE_1("updateSpareBarrelsTemperaturesThread1",GVAR(storedSpareBarrels));
{
_y params ["_initialTemp","_initialTime", "_barrelMass"];
2016-02-27 03:29:30 +00:00
// Calculate cooling
private _finalTemp = [_initialTemp, _barrelMass, CBA_missionTime - _initialTime, 0] call FUNC(calculateCooling); //the zero is to indicate an open bolt gun. Barrel is outside of a gun here, so always open.
TRACE_4("updateSpareBarrelsTemperaturesThread2",_barrelMagazineID,_initialTemp,_finalTemp,_barrelMass);
if (_finalTemp <= (ambientTemperature select 0)) then {
// The barrel is cool enough to finish calculating. Remove it from the hash
GVAR(storedSpareBarrels) deleteAt _x;
2016-02-27 03:29:30 +00:00
} else {
// Store the new temp
GVAR(storedSpareBarrels) set [_x, [_finalTemp, CBA_missionTime, _barrelMass]];
2016-02-27 03:29:30 +00:00
};
} forEach GVAR(storedSpareBarrels);
2016-02-27 03:29:30 +00:00
// Schedule for execution again after 10 seconds
[DFUNC(updateSpareBarrelsTemperaturesThread), [], 10] call CBA_fnc_waitAndExecute;