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