JASS:
library YourLibrary // maybe you need an initializer and requirements; add them here
globals
private constant real TICK = 1./32
endglobals
private struct Data
// your struct members go here
private integer i
private static thistype array Structs
private static timer T=CreateTimer()
private static integer Count=0
method onDestroy takes nothing returns nothing
// clean your struct here
set thistype.Count=thistype.Count-1
set thistype.Structs[.i]=thistype.Structs[thistype.Count]
set thistype.Structs[.i].i=.i
if thistype.Count==0 then
call PauseTimer(thistype.T)
endif
endmethod
private static method Callback takes nothing returns nothing
local integer i=thistype.Count-1
local thistype s
loop
exitwhen i<0
set s=thistype.Structs[i]
// do your things here, dont forget to call s.destroy() somewhen
set i=i-1
endloop
endmethod
static method create takes nothing returns thistype
local thistype s=thistype.allocate()
// initialize the struct here
set thistype.Structs[thistype.Count]=s
set s.i=thistype.Count
if thistype.Count==0 then
call TimerStart(thistype.T, TICK, true, function thistype.Callback)
endif
set thistype.Count=thistype.Count+1
return s
endmethod
endstruct
endlibrary
If you are looking for a way to execute code related to structs many times per second, use this template as a base.
Last edited: