- Add a common in-process event bus - Emit task lifecycle events from task store and instances - Register CAD listeners to invalidate task state
54 lines
2.1 KiB
Plaintext
54 lines
2.1 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
|
|
if (isNil QGVAR(TaskLifecycleEventLogTokens)) then {
|
|
private _logTaskLifecycleEvent = {
|
|
params ["_event"];
|
|
|
|
["INFO", format [
|
|
"Task lifecycle event: %1 taskID=%2 taskType=%3 status=%4 participants=%5",
|
|
_event getOrDefault ["event", ""],
|
|
_event getOrDefault ["taskID", ""],
|
|
_event getOrDefault ["taskType", ""],
|
|
_event getOrDefault ["status", ""],
|
|
_event getOrDefault ["participants", []]
|
|
]] call EFUNC(common,log);
|
|
};
|
|
|
|
GVAR(TaskLifecycleEventLogTokens) = [
|
|
EGVAR(common,EventBus) call ["on", ["task.created", _logTaskLifecycleEvent, "task.lifecycle.log"]],
|
|
EGVAR(common,EventBus) call ["on", ["task.started", _logTaskLifecycleEvent, "task.lifecycle.log"]],
|
|
EGVAR(common,EventBus) call ["on", ["task.completed", _logTaskLifecycleEvent, "task.lifecycle.log"]],
|
|
EGVAR(common,EventBus) call ["on", ["task.failed", _logTaskLifecycleEvent, "task.lifecycle.log"]],
|
|
EGVAR(common,EventBus) call ["on", ["task.cleared", _logTaskLifecycleEvent, "task.lifecycle.log"]]
|
|
];
|
|
};
|
|
|
|
["ace_explosives_defuse", {
|
|
private _taskID = "";
|
|
private _explosive = objNull;
|
|
{
|
|
if (_x isEqualType objNull && { !isNull _x }) then {
|
|
if (isNull _explosive) then { _explosive = _x; };
|
|
_taskID = _x getVariable ["assignedTask", ""];
|
|
if (_taskID isNotEqualTo "") exitWith {};
|
|
};
|
|
} forEach _this;
|
|
|
|
if (_taskID isEqualTo "" && { !isNull _explosive }) then {
|
|
_taskID = GVAR(TaskStore) call ["findTaskEntityOwner", ["ieds", _explosive]];
|
|
};
|
|
|
|
if (_taskID isEqualTo "") exitWith {
|
|
["WARNING", format [
|
|
"ACE Defuse Event Ignored: No assignedTask found. Explosive=%1, Type=%2, NetID=%3",
|
|
_explosive,
|
|
typeOf _explosive,
|
|
netId _explosive
|
|
]] call EFUNC(common,log);
|
|
};
|
|
|
|
GVAR(TaskStore) call ["incrementDefuseCount", [_taskID]];
|
|
}] call CFUNC(addEventHandler);
|
|
[] call FUNC(missionManager);
|