ACE3/addons/ui/functions/fnc_handlePlayerChanged.sqf
Filip Maciejewski d0fd45e220
UI - Infantry speed indictator (#8384)
Co-authored-by: jonpas <jonpas33@gmail.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2021-10-05 18:47:24 +02:00

33 lines
897 B
Plaintext

#include "script_component.hpp"
/*
* Author: veteran29
* Handles switching units.
*
* Arguments:
* 0: New Unit <OBJECT>
* 1: Old Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [newbob, oldbob] call ace_ui_fnc_handlePlayerChanged
*
* Public: No
*/
params ["_newUnit", "_oldUnit"];
TRACE_2("unit changed",_newUnit,_oldUnit);
if (!isNull _oldUnit) then {
_oldUnit removeEventHandler ["AnimChanged", _oldUnit getVariable [QGVAR(animHandler), -1]];
_oldUnit setVariable [QGVAR(animHandler), nil];
TRACE_1("remove old",_oldUnit getVariable QGVAR(animHandler));
};
// Don't add a new EH if the unit respawned
if (_newUnit getVariable [QGVAR(animHandler), -1] == -1) then {
private _animHandler = _newUnit addEventHandler ["AnimChanged", LINKFUNC(onAnimChanged)];
TRACE_1("add new",_animHandler);
_newUnit setVariable [QGVAR(animHandler), _animHandler];
};