library DelayedOrder uses TimerIndex
globals
unit array udg_DelayedOrder_WhichUnit
integer array udg_DelayedOrder_OrderId
real array udg_DelayedOrder_TargetPoint_X
real array udg_DelayedOrder_TargetPoint_Y
widget array udg_DelayedOrder_TargetWidget
endglobals
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function IssueImmediateOrderByIdCallback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetTimerData(t)
call ReleaseIndexedTimer(t)
call IssueImmediateOrderById(udg_DelayedOrder_WhichUnit[id], udg_DelayedOrder_OrderId[id])
set udg_DelayedOrder_WhichUnit[id] = null
set udg_DelayedOrder_OrderId[id] = 0
endfunction
function IssueImmediateOrderByIdDelayed takes unit whichUnit, integer order, real delay returns nothing
local timer t = NewIndexedTimer()
local integer id = GetTimerData(t)
set udg_DelayedOrder_WhichUnit[id] = whichUnit
set udg_DelayedOrder_OrderId[id] = order
call TimerStart(t, delay, false, function IssueImmediateOrderByIdCallback)
set t = null
endfunction
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function IssuePointOrderByIdCallback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetTimerData(t)
call ReleaseIndexedTimer(t)
call IssuePointOrderById(udg_DelayedOrder_WhichUnit[id], udg_DelayedOrder_OrderId[id], udg_DelayedOrder_TargetPoint_X[id], udg_DelayedOrder_TargetPoint_Y[id])
set udg_DelayedOrder_WhichUnit[id] = null
set udg_DelayedOrder_OrderId[id] = 0
set udg_DelayedOrder_TargetPoint_X[id] = 0.
set udg_DelayedOrder_TargetPoint_Y[id] = 0.
endfunction
function IssuePointOrderByIdDelayed takes unit whichUnit, integer order, real x, real y, real delay returns nothing
local timer t = NewIndexedTimer()
local integer id = GetTimerData(t)
set udg_DelayedOrder_WhichUnit[id] = whichUnit
set udg_DelayedOrder_OrderId[id] = order
set udg_DelayedOrder_TargetPoint_X[id] = x
set udg_DelayedOrder_TargetPoint_Y[id] = y
call TimerStart(t, delay, false, function IssuePointOrderByIdCallback)
set t = null
endfunction
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function IssueTargetOrderByIdCallback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetTimerData(t)
call ReleaseIndexedTimer(t)
call IssueTargetOrderById(udg_DelayedOrder_WhichUnit[id], udg_DelayedOrder_OrderId[id], udg_DelayedOrder_TargetWidget[id])
set udg_DelayedOrder_WhichUnit[id] = null
set udg_DelayedOrder_OrderId[id] = 0
set udg_DelayedOrder_TargetWidget[id] = null
endfunction
function IssueTargetOrderByIdDelayed takes unit whichUnit, integer order, widget targetWidget, real delay returns nothing
local timer t = NewIndexedTimer()
local integer id = GetTimerData(t)
set udg_DelayedOrder_WhichUnit[id] = whichUnit
set udg_DelayedOrder_OrderId[id] = order
set udg_DelayedOrder_TargetWidget[id] = targetWidget
call TimerStart(t, delay, false, function IssueTargetOrderByIdCallback)
set t = null
endfunction
endlibrary