#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Assigns an IED to a task and starts countdown timer
 *
 * Arguments:
 * 0: The object <OBJECT>
 * 1: ID of the task <STRING>
 * 2: The Countdown Timer <NUMBER>
 *
 * Return Value:
 * None
 *
 * Example:
 * [this, "task_name", 30] spawn forge_client_task_fnc_makeIED;
 *
 * Public: Yes
 */

params [["_entity", objNull, [objNull]], ["_taskID", "", [""]], ["_time", 0, [0]]];

if (isNull _entity) exitWith { diag_log "ERROR: Attempt to create entity from null object"; };
if (_taskID == "") exitWith { diag_log "ERROR: No task ID provided for entity"; };
if (_time < 0) exitWith { diag_log "ERROR: Invalid time provided for IED"; };

diag_log format ["[FORGE] Make IED: %1", _this];

SETVAR(_entity,assignedTask,_taskID);
GVAR(allIEDs) pushBackUnique _entity;

if (alive _entity) then { [_entity, "ied", _time] spawn FUNC(heartBeat); };