I'm creating a little respawn system for a extremely new GUI user so he can setup unit respawns by unit type, respawn time, removal time, current/initial positioning and unit owner through setting GUI variables.
I've setup a struct like this:
When I do the following using TimerUtilsEx to attach timer data it tells me I can't use the dot syntax.
Am I missing something?
I've setup a struct like this:
JASS:
struct respawnUnit extends array
unit u
integer conf
integer id
real posX
real posY
private static integer instanceCount = 0
private static thistype recycle = 0
private thistype recycleNext
method destroy takes nothing returns nothing
set .u = null
set recycleNext = recycle
set recycle = this
endmethod
static method create takes unit u, integer conf, integer id returns thistype
local thistype this
if (recycle == 0) then
set instanceCount = instanceCount + 1
set this = instanceCount
else
set this = recycle
set recycle = recycle.recycleNext
endif
set .u = u
set .posX = GetUnitX(u)
set .posY = GetUnitY(u)
set .id = id
set .conf = conf
return this
endmethod
endstruct
When I do the following using TimerUtilsEx to attach timer data it tells me I can't use the dot syntax.
Am I missing something?
JASS:
private function respawnUnit takes nothing returns nothing
local timer t = GetExpiredTimer()
local respawnUnit u = GetTimerData(t)
//Can't use dot syntax here
if udg_CreepRespawnCurrentPosition[u.conf] then
call CreateUnit(udg_CreepOwner[u.conf], udg_CreepType[u.conf], u.posX, u.posY, CreepFace[u.id])
else
call CreateUnit(udg_CreepOwner[u.conf], udg_CreepType[u.conf], CreepPositionX[u.id], CreepPositionY[u.id], CreepFace[u.id])
endif
call u.destroy()
call ReleaseTimer(t)
endfunction
private function removeUnit takes nothing returns nothing
local timer t = GetExpiredTimer()
local respawnUnit u = GetTimerData(t)
local timer respawnTime = NewTimer()
//haven't tested if I can use dot syntax here
call RemoveUnit(u.u)
set u.u = null
call TimerStart(respawnTime, udg_CreepRespawnTime[u.conf], false, function respawnUnit)
call SetTimerData(respawnTime, u)
call ReleaseTimer(t)
endfunction
private function respawnUnitActions takes nothing returns boolean
local unit u = GetTriggerUnit()
local respawnUnit sendUnit
local integer id = GetUnitUserData(u)
local integer i = 1
local timer deathTime = NewTimer()
loop
exitwhen i > udg_lastIndex
if GetUnitTypeId(u) == udg_CreepType[i] then
if isIndexed(u, id) then
set sendUnit = sendUnit.create(u, id, i)
call TimerStart(deathTime, udg_CreepRemovalTime[i], false, function removeUnit)
call SetTimerData(deathTime, sendUnit)
endif
endif
endloop
return false
endfunction