speed up fnc_getClaimObjects (#8459)

This commit is contained in:
GhostIsSpooky 2021-10-12 18:09:56 -03:00 committed by GitHub
parent 40ec4e9137
commit 82f705b5a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,22 +24,17 @@ private _return = [];
{ {
private _requiredList = _x; //eg ["ace_track", "ace_track"] private _requiredList = _x; //eg ["ace_track", "ace_track"]
private _ableToAquire = []; //will be array of ojbects private _ableToAquire = []; //will be array of objects
{ {
private _nearObjects = nearestObjects [_unit, [_x], _maxRange]; private _nearObjects = _unit nearEntities [_x, _maxRange];
private _canClaimObject = objNull;
{ {
if ((!(_x in _ableToAquire)) if (!(_x in _ableToAquire) && {(_x getVariable [QEGVAR(common,owner), objNull]) in [objNull, _unit]}) exitWith { // skip claimed objects
&& {[_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)} _ableToAquire pushBack _x
&&{(damage _x) < 1} };
) exitWith { _canClaimObject = _x; };
} forEach _nearObjects; } forEach _nearObjects;
if (isNull _canClaimObject) exitWith {}; } forEach _requiredList;
_ableToAquire pushBack _canClaimObject;
} forEach _x;
TRACE_2("Check required equals available",_requiredList,_ableToAquire); TRACE_2("Check required equals available",_requiredList,_ableToAquire);
if ((count _ableToAquire) == (count _requiredList)) exitWith {_return = _ableToAquire}; if ((count _ableToAquire) == (count _requiredList)) exitWith {_return = _ableToAquire};
false } forEach _objectsToClaim;
} count _objectsToClaim;
_return _return