Tagging - Cache required items check and use uniqueItems (#6582)

* Cache required items check and use uniqueItems

* Use config-case for required items
This commit is contained in:
mharis001 2018-09-21 16:11:02 -04:00 committed by PabstMirror
parent afbf2049ea
commit 61000df120
6 changed files with 10 additions and 6 deletions

View File

@ -48,7 +48,6 @@ if (_textures isEqualTo []) exitWith {
};
_identifier = [_identifier] call CBA_fnc_removeWhitespace;
_requiredItem = toLower _requiredItem;
// Add
[QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon]] call CBA_fnc_globalEventJIP;

View File

@ -33,7 +33,7 @@ private _actions = [];
},
{
(_this select 2) params ["_unit", "", "", "_requiredItem"];
_requiredItem in ((items _unit) apply {toLower _x})
_requiredItem in (_unit call EFUNC(common,uniqueItems))
},
{},
[_unit, _class, _textures, _requiredItem]

View File

@ -25,6 +25,8 @@ params ["_identifier", "_displayName", "_requiredItem"];
if !(GVAR(cachedTags) select {_x select 0 == _identifier} isEqualTo []) exitWith {
INFO_2("Tag with selected identifier already exists: %1 (%2)",_identifier,_displayName)
};
_requiredItem = configName (configFile >> "CfgWeapons" >> _requiredItem); // Convert To config case
_this set [2, _requiredItem];
GVAR(cachedTags) pushBack _this;
GVAR(cachedRequiredItems) pushBackUnique _requiredItem;

View File

@ -19,7 +19,9 @@
params ["_unit"];
// Exit if no required item in inventory
if ((GVAR(cachedRequiredItems) arrayIntersect ((items _unit) apply {toLower _x})) isEqualTo []) exitWith {false};
if ([_unit, {
GVAR(cachedRequiredItems) arrayIntersect (_unit call EFUNC(common,uniqueItems)) isEqualTo []
}, _unit, QGVAR(checkRequiredItemsCache), 9999, "cba_events_loadoutEvent"] call EFUNC(common,cachedCall)) exitWith {false};
private _startPosASL = eyePos _unit;
private _cameraPosASL = AGLToASL positionCameraToWorld [0, 0, 0];
@ -36,7 +38,6 @@
// Exit if trying to tag a non static object
TRACE_1("Obj:",_intersections);
// Exit if trying to tag a non static object
if ((!isNull _object) && {
// If the class is alright, do not exit
if (_object isKindOf "Static") exitWith {false};

View File

@ -25,7 +25,7 @@
_failure = true;
};
private _requiredItem = toLower (getText (_x >> "requiredItem"));
private _requiredItem = getText (_x >> "requiredItem");
if (_requiredItem == "") then {
ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing requiredItem",_class);
_failure = true;
@ -33,6 +33,8 @@
if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) then {
ERROR_2("Failed compiling ACE_Tags for tag: %1 - requiredItem %2 does not exist",_class,_requiredItem);
_failure = true;
} else {
_requiredItem = configName (configFile >> "CfgWeapons" >> _requiredItem); // convert to config case
};
};

View File

@ -48,6 +48,6 @@ if (GVAR(quickTag) == 3) then {
// Tag
if !(_possibleTags isEqualTo []) then {
private _availableTags = _possibleTags select {(_x select 2) in ((items _unit) apply {toLower _x})};
private _availableTags = _possibleTags select {(_x select 2) in (_unit call EFUNC(common,uniqueItems))};
[_unit, selectRandom ((selectRandom _availableTags) select 3)] call FUNC(tag);
};