mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Optimize spectator unit list function
Making good use of the new `select` CODE syntax.
This commit is contained in:
parent
9ee2f10f63
commit
74399be109
@ -33,43 +33,37 @@ if !(_newUnits isEqualTo []) exitWith {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
private ["_sides","_cond","_filteredUnits","_filteredGroups"];
|
|
||||||
|
|
||||||
// Unit setting filter
|
// Unit setting filter
|
||||||
_newUnits = [[],allPlayers,playableUnits,allUnits] select GVAR(filterUnits);
|
private _newUnits = [[],allPlayers,playableUnits,allUnits] select GVAR(filterUnits);
|
||||||
|
|
||||||
// Side setting filter
|
// Side setting filter
|
||||||
_sides = [];
|
private _sideFilter = [
|
||||||
_cond = [{_this == (side group player)},{(_this getFriend (side group player)) >= 0.6},{(_this getFriend (side group player)) < 0.6},{true}] select GVAR(filterSides);
|
{_x == (side group player)},
|
||||||
{
|
{(_x getFriend (side group player)) >= 0.6},
|
||||||
if (_x call _cond) then {
|
{(_x getFriend (side group player)) < 0.6},
|
||||||
_sides pushBack _x;
|
{true}
|
||||||
};
|
] select GVAR(filterSides);
|
||||||
} forEach GVAR(availableSides);
|
|
||||||
|
private _filteredSides = GVAR(availableSides) select _sideFilter;
|
||||||
|
|
||||||
// Filter units and append to list
|
// Filter units and append to list
|
||||||
_filteredUnits = [];
|
private _filteredUnits = (_newUnits - GVAR(unitBlacklist)) select {
|
||||||
{
|
(alive _x) &&
|
||||||
if (
|
{(_x isKindOf "CAManBase")} &&
|
||||||
(alive _x) &&
|
{(side group _x) in _filteredSides} && // Side filter
|
||||||
{(_x isKindOf "CAManBase")} &&
|
{simulationEnabled _x} &&
|
||||||
{(side group _x) in _sides} && // Side filter
|
{!(_x getVariable [QGVAR(isStaged), false])} // Who watches the watchmen?
|
||||||
{simulationEnabled _x} &&
|
};
|
||||||
{!(_x getVariable [QGVAR(isStaged), false])} // Who watches the watchmen?
|
|
||||||
) then {
|
|
||||||
_filteredUnits pushBack _x;
|
|
||||||
};
|
|
||||||
} forEach (_newUnits - GVAR(unitBlacklist));
|
|
||||||
_filteredUnits append GVAR(unitWhitelist);
|
_filteredUnits append GVAR(unitWhitelist);
|
||||||
|
|
||||||
// Cache icons and colour for drawing
|
// Cache icons and colour for drawing
|
||||||
_filteredGroups = [];
|
private _filteredGroups = [];
|
||||||
{
|
{
|
||||||
// Intentionally re-applied to units in case their status changes
|
// Intentionally re-applied to units in case their status changes
|
||||||
[_x] call FUNC(cacheUnitInfo);
|
[_x] call FUNC(cacheUnitInfo);
|
||||||
_filteredGroups pushBack (group _x);
|
_filteredGroups pushBackUnique (group _x);
|
||||||
} forEach _filteredUnits;
|
} forEach _filteredUnits;
|
||||||
|
|
||||||
// Replace previous lists entirely (removes any no longer valid)
|
// Replace previous lists entirely (removes any no longer valid)
|
||||||
|
GVAR(groupList) = _filteredGroups;
|
||||||
GVAR(unitList) = _filteredUnits arrayIntersect _filteredUnits;
|
GVAR(unitList) = _filteredUnits arrayIntersect _filteredUnits;
|
||||||
GVAR(groupList) = _filteredGroups arrayIntersect _filteredGroups;
|
|
||||||
|
Loading…
Reference in New Issue
Block a user