Unit cycling

This commit is contained in:
SilentSpike 2015-07-21 16:06:07 +01:00
parent dc19bff189
commit 1890bc1d59
3 changed files with 10 additions and 4 deletions

View File

@ -22,26 +22,32 @@ params [["_stepMode",0], ["_stepUnit",0], ["_stepVision",0]];
private ["_modes","_visions","_iMode","_iVision","_countModes","_countVisions","_newMode","_newVision","_newUnit"];
_modes = GVAR(availableModes);
_units = GVAR(unitList);
_visions = GVAR(availableVisions);
// Get current index
_iMode = abs(_modes find GVAR(camMode));
_iUnit = abs(_units find GVAR(camUnit));
_iVision = abs(_visions find GVAR(camVision));
_countModes = count _modes;
_countUnits = count _units;
_countVisions = count _visions;
// Step index by step number (lopp ends)
_iMode = (_iMode + _stepMode) % _countModes;
if (_iMode < 0) then { _iMode = _countModes + _iMode; };
_iUnit = (_iUnit + _stepUnit) % _countUnits;
if (_iUnit < 0) then { _iUnit = _countUnits + _iUnit; };
_iVision = (_iVision + _stepVision) % _countVisions;
if (_iVision < 0) then { _iVision = _countVisions + _iVision; };
// Get value at new index
_newMode = _modes select _iMode;
_newUnit = _units select _iUnit;
_newVision = _visions select _iVision;
_newUnit = GVAR(camUnit);
[_newMode, _newUnit, _newVision] call FUNC(transitionCamera);

View File

@ -203,10 +203,10 @@ switch (toLower _mode) do {
[-1] call FUNC(cycleCamera);
};
case 203: { // Left arrow
[nil,1] call FUNC(cycleCamera);
};
case 205: { // Right arrow
[nil,-1] call FUNC(cycleCamera);
};
case 208: { // Down arrow
[1] call FUNC(cycleCamera);

View File

@ -28,7 +28,7 @@ if (isNull _display) exitWith { [_this select 1] call CBA_fnc_removePerFrameHand
// Camera shouldn't stay on unit that isn't in the list
if !(GVAR(camUnit) in GVAR(unitList)) then {
[0,objNull] call FUNC(transitionCamera);
[nil,1] call FUNC(cycleCamera);
};
// Reduce overhead when unit tree is hidden