2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2017-08-12 13:25:48 +00:00
|
|
|
/*
|
|
|
|
* Author: Nelson Duarte, SilentSpike
|
|
|
|
* Function used to switch to next or previous camera focus
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Next/Prev unit <BOOL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [false] call ace_spectator_fnc_switchFocus
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
private _next = param [0, true];
|
|
|
|
private _entities = [true] call FUNC(getTargetEntities);
|
2017-08-30 15:36:53 +00:00
|
|
|
private _focus = GVAR(camFocus);
|
2017-08-12 13:25:48 +00:00
|
|
|
|
|
|
|
// No entities to switch to
|
|
|
|
if ((_entities isEqualTo []) || (_entities isEqualTo [_focus])) exitWith {};
|
|
|
|
|
|
|
|
private _index = (_entities find _focus) max 0;
|
|
|
|
|
|
|
|
_index = (_index + ([-1, 1] select _next)) % (count _entities);
|
|
|
|
if (_index < 0) then { _index = count _entities + _index; };
|
|
|
|
|
|
|
|
[_entities select _index] call FUNC(setFocus);
|