Azlier
Old World Ghost
- Reaction score
- 461
Small update. Doesn't use the trigger attachment anymore, thanks to an idea from Vex.
call PauseTimer(ClickTimer[Id])
library YourLib // Just copy the contents in and use the functions mentioned at the bottom.
private struct QueueNode
QueueNode next
QueueNode prev
integer playerNumber
method attachEnd takes integer playerNumber returns QueueNode
local QueueNode new=QueueNode.allocate()
set new.next=0
set new.prev=this
set this.next=new
return new
endmethod
private method onDestroy takes nothing returns nothing
set this.next.prev=this.prev
set this.prev.next=this.next
set this.playerNumber=0
endmethod
endstruct
globals
private QueueNode First=0
private QueueNode Last=0
private QueueNode array PlayersNode
endglobals
private function AddToQueue takes integer playerNumber returns nothing
set Last=Last.attachEnd()
if First==0 then
set First=Last
endif
set Last.playerNumber=playerNumber
set PlayersNode[playerNumber]=Last
endfunction
private function RemoveNode takes QueueNode n returns nothing
if First==n then
set First=First.next
endif
if Last==n then
set Last=Last.prev
endif
call n.destroy()
endfunction
private function RemoveFromQueue takes integer playerNumber returns nothing
if PlayersNode[playerNumber].playerNumber!=playerNumber then
return // Fail
endif
call RemoveNode(PlayersNode[playerNumber])
endfunction
private function Dequeue takes nothing returns integer
local integer playerNumber=First.playerNumber
call RemoveNode(First)
return playerNumber
endfunction
// Use AddToQueue(playerNumber) when starting a timer.
// Use RemoveFromQueue(playerNumber) when stopping (pausing) a timer.
// Use Dequeue() to get the player number for the expiring timer.
endlibrary
library DoubleClick initializer Init requires Event