ACE3/addons/field_rations/functions/fnc_getRemainingWater.sqf
jonpas 742626ff1a
General - Relative script_component.hpp includes (#9378)
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-09-12 20:58:10 +02:00

45 lines
1.2 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: mharis001, PabstMirror
* Returns the remaining water in a source.
*
* Arguments:
* 0: Water source <OBJECT>
*
* Return Value:
* Remaining water <NUMBER>
*
* Example:
* [_source] call ace_field_rations_fnc_getRemainingWater
*
* Public: Yes
*/
params [["_source", objNull, [objNull]]];
if (!alive _source) exitWith {0};
private _water = _source getVariable QGVAR(currentWaterSupply);
if (isNil "_water") then {
private _configOf = configOf _source;
if !(isNull _configOf) then {
// Check for waterSupply entry since we have valid typeOf
_water = getNumber (_configOf >> QXGVAR(waterSupply));
if (_water == 0) then {_water = REFILL_WATER_DISABLED};
if (_water != REFILL_WATER_DISABLED) then {
if (_source call CBA_fnc_isTerrainObject) then {
_water = REFILL_WATER_INFINITE;
} else {
_source setVariable [QGVAR(currentWaterSupply), _water, true];
};
};
} else {
// Check the p3d name against list
_water = if ((getModelInfo _source select 0) in GVAR(waterSourceP3ds)) then {REFILL_WATER_INFINITE} else {REFILL_WATER_DISABLED};
};
};
_water