ACE3/addons/spectator/functions/fnc_handleUnits.sqf

39 lines
1020 B
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
2015-07-18 17:25:59 +00:00
// Camera shouldn't stay on unit that isn't in the list
if !(GVAR(camUnit) in GVAR(unitList)) then {
[0,objNull] call FUNC(updateCamera);
};
2015-07-19 12:40:08 +00:00
// Reduce overhead when unit tree is hidden
if (GVAR(showUnit) && GVAR(showInterface)) then {
// Reduce overhead by spreading across frames
[FUNC(handleInterface),["onUnitsUpdate",[_display]],1] call EFUNC(common,waitAndExecute);
};