Common - Use hashmap for canInteractWith check (#10189)

This commit is contained in:
PabstMirror 2024-08-11 18:29:33 -05:00 committed by GitHub
parent fff66bc27c
commit 3ff635f82d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 33 deletions

View File

@ -12,6 +12,8 @@ GVAR(showHudHash) = createHashMap;
GVAR(vehicleIconCache) = createHashMap; // for getVehicleIcon GVAR(vehicleIconCache) = createHashMap; // for getVehicleIcon
GVAR(wheelSelections) = createHashMap; GVAR(wheelSelections) = createHashMap;
GVAR(InteractionConditions) = createHashMap;
GVAR(blockItemReplacement) = false; GVAR(blockItemReplacement) = false;
// Cache for FUNC(isModLoaded) // Cache for FUNC(isModLoaded)

View File

@ -19,17 +19,4 @@
params ["_conditionName", "_conditionFunc"]; params ["_conditionName", "_conditionFunc"];
_conditionName = toLowerANSI _conditionName; _conditionName = toLowerANSI _conditionName;
GVAR(InteractionConditions) set [_conditionName, _conditionFunc];
private _conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
_conditions params ["_conditionNames", "_conditionFuncs"];
private _index = _conditionNames find _conditionName;
if (_index == -1) then {
_index = count _conditionNames;
};
_conditionNames set [_index, _conditionName];
_conditionFuncs set [_index, _conditionFunc];
GVAR(InteractionConditions) = _conditions;

View File

@ -27,15 +27,11 @@ private _owner = _target getVariable [QGVAR(owner), objNull];
if (!isNull _owner && {_unit != _owner}) exitWith {false}; if (!isNull _owner && {_unit != _owner}) exitWith {false};
// check general conditions // check general conditions
private _conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
_conditions params ["_conditionNames", "_conditionFuncs"];
private _canInteract = true; private _canInteract = true;
{ {
if (!(_x in _exceptions) && {!([_unit, _target] call (_conditionFuncs select _forEachIndex))}) exitWith { if (!(_x in _exceptions) && {!([_unit, _target] call _y)}) exitWith {
_canInteract = false; _canInteract = false;
}; };
} forEach _conditionNames; } forEach GVAR(InteractionConditions);
_canInteract _canInteract

View File

@ -18,16 +18,4 @@
params ["_conditionName"]; params ["_conditionName"];
_conditionName = toLowerANSI _conditionName; _conditionName = toLowerANSI _conditionName;
GVAR(InteractionConditions) deleteAt _conditionName;
private _conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
_conditions params ["_conditionNames", "_conditionFuncs"];
private _index = _conditionNames find _conditionName;
if (_index == -1) exitWith {};
_conditionNames deleteAt _index;
_conditionFuncs deleteAt _index;
GVAR(InteractionConditions) = _conditions;