ACE3/addons/spectator/functions/fnc_handleUnits.sqf

41 lines
1.1 KiB
Plaintext
Raw Normal View History

2015-07-16 10:15:33 +00:00
/*
* Author: SilentSpike
* Maintains the spectatable unit list and updates the unit tree accordingly
2015-07-18 17:46:46 +00:00
* Also updates current camera unit when status changes
2015-07-16 10:15:33 +00:00
*
* Arguments:
* 0: Parameters <ANY>
* 1: PFH handle <NUMBER>
2015-07-16 10:15:33 +00:00
*
* Return Value:
* None <NIL>
*
* Example:
2015-07-19 12:40:08 +00:00
* [ace_spectator_fnc_handleUnits, 10, _display] call CBA_fnc_addPerFrameHandler;
2015-07-16 10:15:33 +00:00
*
* Public: No
*/
#include "script_component.hpp"
params ["_display"];
2015-07-17 01:30:00 +00:00
// Kill PFH when display is closed
if (isNull _display) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
2015-07-16 10:15:33 +00:00
2015-07-18 15:50:11 +00:00
// Remove all dead and null units from the list
[] call FUNC(updateUnits);
2015-07-18 15:50:11 +00:00
// Camera shouldn't stay on unit that isn't in the list (unless dead)
2015-07-18 17:25:59 +00:00
if !(GVAR(camUnit) in GVAR(unitList)) then {
if (alive GVAR(camUnit) || isNull GVAR(camUnit)) then {
[nil,1] call FUNC(cycleCamera);
};
2015-07-18 17:25:59 +00:00
};
2015-07-19 12:40:08 +00:00
// Reduce overhead when unit tree is hidden
2015-07-19 22:03:40 +00:00
if (ctrlShown (_display displayCtrl IDC_UNIT)) then {
2015-07-19 12:40:08 +00:00
// Reduce overhead by spreading across frames
[FUNC(handleInterface),["onUnitsUpdate",[(_display displayCtrl IDC_UNIT) controlsGroupCtrl IDC_UNIT_TREE]],1] call CBA_fnc_waitAndExecute;
2015-07-19 12:40:08 +00:00
};