New function to precisely control spectatable sides

This commit is contained in:
SilentSpike 2015-07-25 11:32:42 +01:00
parent 69d1db2872
commit 7107514b05
3 changed files with 36 additions and 1 deletions

View File

@ -18,11 +18,13 @@ PREP(setSpectator);
PREP(transitionCamera); PREP(transitionCamera);
PREP(toggleInterface); PREP(toggleInterface);
PREP(updateCameraModes); PREP(updateCameraModes);
PREP(updateSpectatableSides);
PREP(updateUnits); PREP(updateUnits);
PREP(updateVisionModes); PREP(updateVisionModes);
// Permanent variables // Permanent variables
GVAR(availableModes) = [0,1,2]; GVAR(availableModes) = [0,1,2];
GVAR(availableSides) = [west,east,resistance,civilian];
GVAR(availableVisions) = [-2,-1,0,1]; GVAR(availableVisions) = [-2,-1,0,1];
GVAR(camMode) = 0; GVAR(camMode) = 0;

View File

@ -0,0 +1,33 @@
/*
* Author: SilentSpike
* Adds or removes sides from the selection available to spectate by the local player.
* Note that the side filter setting is applied to the available sides dynamically.
*
* Default selection is [west,east,resistance,civilian]
*
* Arguments:
* 0: Sides to add <ARRAY>
* 1: Sides to remove <ARRAY>
*
* Return Value:
* Spectatable sides <ARRAY>
*
* Example:
* [[west], [east,civilian]] call ace_spectator_fnc_updateSpectatableSides
*
* Public: Yes
*/
#include "script_component.hpp"
params [["_addSides",[],[[]]], ["_removeSides",[],[[]]]];
// Add and remove sides
_addSides append (GVAR(availableSides) - _removeSides);
// Only need array of unique sides
_addSides arrayIntersect _addSides;
GVAR(availableSides) = _addSides;
_addSides

View File

@ -45,7 +45,7 @@ _cond = [{_this == (side group player)},{(_this getFriend (side group player)) >
if (_x call _cond) then { if (_x call _cond) then {
_sides pushBack _x; _sides pushBack _x;
}; };
} forEach [west,east,resistance,civilian]; } forEach GVAR(availableSides);
// Filter units and append to list // Filter units and append to list
_filteredUnits = []; _filteredUnits = [];