change events to allow for any number of arguments

This commit is contained in:
Brandon Danyluk 2021-05-18 02:46:30 -06:00
parent 72ca725242
commit e67aefcf51

View File

@ -24,19 +24,22 @@ if (isServer) then {
GVAR(nonTrackingProjectiles) pushBack _projectile;
}] call CBA_fnc_addEventHandler;
[QGVAR(registerLauncher), {
params ["_launcher"];
GVAR(launchers) pushBackUnique _launcher;
_launcher setVariable [QGVAR(targetList), []];
_launcher setVariable [QGVAR(launchState), LAUNCH_STATE_IDLE];
_launcher setVariable [QGVAR(lastLaunchTime), 0];
_launcher setVariable [QGVAR(engagedTargets), [[], objNull] call CBA_fnc_hashCreate];
_launcher setVariable [QEGVAR(missileguidance,target), objNull];
[QGVAR(registerLaunchers), {
{
GVAR(launchers) pushBackUnique _x;
_x setVariable [QGVAR(targetList), []];
_x setVariable [QGVAR(launchState), LAUNCH_STATE_IDLE];
_x setVariable [QGVAR(lastLaunchTime), 0];
_x setVariable [QGVAR(engagedTargets), [[], objNull] call CBA_fnc_hashCreate];
_x setVariable [QEGVAR(missileguidance,target), objNull];
} forEach _this;
}] call CBA_fnc_addEventHandler;
[QGVAR(registerTracker), {
params ["_tracker", "_range"];
GVAR(trackers) pushBack [_tracker, _range];
[QGVAR(registerTrackers), {
{
_x params ["_tracker", "_range"];
GVAR(trackers) pushBack [_tracker, _range];
} forEach _this;
}] call CBA_fnc_addEventHandler;
[QGVAR(registerInterceptor), {
@ -51,23 +54,26 @@ if (isServer) then {
// duplicate event to add event handler
[QGVAR(registerLauncher), {
params ["_launcher"];
if !(local _launcher) exitWith {};
_launcher addEventHandler ["Fired", {
params ["_launcher", "", "", "", "", "", "_projectile"];
private _target = _launcher getVariable [QEGVAR(missileguidance,target), objNull];
if !(isNull _target) then {
[QGVAR(registerInterceptor), [_projectile, _target]] call CBA_fnc_serverEvent;
{
if (local _x) then {
_x addEventHandler ["Fired", {
params ["_launcher", "", "", "", "", "", "_projectile"];
private _target = _launcher getVariable [QEGVAR(missileguidance,target), objNull];
if !(isNull _target) then {
[QGVAR(registerInterceptor), [_projectile, _target]] call CBA_fnc_serverEvent;
};
}];
};
}];
} forEach _this;
}] call CBA_fnc_addEventHandler;
// When something is fired, determine if we want to track it. If so, send it to the server for processing
GVAR(projectilesToIntercept) = [];
[QGVAR(addProjectileToIntercept), {
params ["_type"];
GVAR(projectilesToIntercept) pushBackUnique _type;
[QGVAR(addProjectilesToIntercept), {
{
GVAR(projectilesToIntercept) pushBackUnique _x;
} forEach _this;
}] call CBA_fnc_addEventHandler;
["All", "fired", {