ACE3/addons/cargo/functions/fnc_validateCargoSpace.sqf
SilentSpike f65f6e9b72 Add support for virtual cargo
Allows cargo objects to be added via classname and reduces simulation/synchronization overhead. Objects become physical upon unloading and cannot be re-made virtual, only scripts can add such virtual objects.

Also separates the player feedback from the loading/unloading code and adds a progress bar.
2015-09-27 17:34:37 +01:00

39 lines
881 B
Plaintext

/*
* Author: Glowbal
* Validate the vehicle cargo space.
*
* Arguments:
* 0: Object <OBJECT>
*
* Return value:
* None
*
* Example:
* [object] call ace_cargo_fnc_validateCargoSpace
*
* Public: No
*/
#include "script_component.hpp"
private ["_loaded", "_newLoaded", "_totalSpaceOccupied"];
params ["_vehicle"];
_loaded = _vehicle getVariable [QGVAR(loaded), []];
_newLoaded = [];
_totalSpaceOccupied = 0;
{
if ((typeName _x == "STRING") || {!isNull _x}) then {
_newLoaded pushback _x;
_totalSpaceOccupied = _totalSpaceOccupied + ([_x] call FUNC(getSizeItem));
};
true
} count _loaded;
if (count _loaded != count _newLoaded) then {
_vehicle setVariable [QGVAR(loaded), _newLoaded, true];
};
_vehicle setVariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(space)) - _totalSpaceOccupied, true];