share/hedgewars/Data/Scripts/Animate.lua
changeset 7438 195f9cbd6df6
parent 7263 644eabbc9218
child 7448 d0521a3a4358
equal deleted inserted replaced
7436:4802191f6a09 7438:195f9cbd6df6
     1 local animPos, lastx, lasty, jumpTypes, jumpTimes, moveDirs, jumpStarted
     1 local animPos, lastx, lasty, jumpTypes, jumpTimes, moveDirs, jumpStarted
     2 local backJumped, jTimer, awTime, globalWait, stageEvents, seNum
     2 local backJumped, jTimer, awTime, globalWait, stageEvents, seNum, curEvent
       
     3 local needtoDecrease
     3 local AnimList, AnimListNum
     4 local AnimList, AnimListNum
     4 local FunctionList, FunctionListNum
     5 local FunctionList, FunctionListNum
     5 local skipFuncList
     6 local skipFuncList
     6 local skipping
     7 local skipping
     7 --------------------------------Animation---------------------------------
     8 --------------------------------Animation---------------------------------
    61   jTimer = 0
    62   jTimer = 0
    62   awTime = 0
    63   awTime = 0
    63   globalWait = 0
    64   globalWait = 0
    64   stageEvents = {}
    65   stageEvents = {}
    65   seNum = 0
    66   seNum = 0
       
    67   curEvent = 0
       
    68   needToDecrease = 0
    66   AnimList = {}
    69   AnimList = {}
    67   AnimListNum = 0
    70   AnimListNum = 0
    68   FunctionList = {}
    71   FunctionList = {}
    69   FunctionListNum = 0
    72   FunctionListNum = 0
    70   skipping = false
    73   skipping = false
   337 
   340 
   338 function RemoveEvent(evNum)
   341 function RemoveEvent(evNum)
   339   if stageEvents[evNum] ~= nil then
   342   if stageEvents[evNum] ~= nil then
   340     seNum = seNum - 1
   343     seNum = seNum - 1
   341     table.remove(stageEvents, evNum)
   344     table.remove(stageEvents, evNum)
   342   end
   345     if evNum < curEvent then
   343 end
   346       return true
   344 
   347     end
   345 function RemoveEventFunc(cFunc)
   348   end
       
   349   if evNum < curEvent then
       
   350     needToDecrease = needToDecrease + 1
       
   351   end
       
   352 end
       
   353 
       
   354 function RemoveEventFunc(cFunc, cArgs)
   346   local i = 1
   355   local i = 1
   347   while i <= seNum do
   356   while i <= seNum do
   348     if stageEvents[i].cFunc == cFunc then
   357     if stageEvents[i].cFunc == cFunc and (cArgs == nil or cArgs == stageEvents[i].cArgs) then
   349       RemoveEvent(i)
   358       RemoveEvent(i)
   350       i = i - 1
   359       i = i - 1
   351     end
   360     end
   352     i = i + 1
   361     i = i + 1
   353   end
   362   end
   355 
   364 
   356 
   365 
   357 function CheckEvents()
   366 function CheckEvents()
   358   local i = 1
   367   local i = 1
   359   while i <= seNum do
   368   while i <= seNum do
       
   369     curEvent = i
   360     if stageEvents[i].cFunc(unpack(stageEvents[i].cArgs)) then
   370     if stageEvents[i].cFunc(unpack(stageEvents[i].cArgs)) then
   361       stageEvents[i].dFunc(unpack(stageEvents[i].dArgs))
   371       stageEvents[i].dFunc(unpack(stageEvents[i].dArgs))
       
   372       if needToDecrease > 0 then
       
   373         i = i - needToDecrease
       
   374         needToDecrease = 0
       
   375       end
   362       if stageEvents[i].evType ~= 1 then 
   376       if stageEvents[i].evType ~= 1 then 
   363         RemoveEvent(i)
   377         RemoveEvent(i)
   364         i = i - 1
   378         i = i - 1
   365       end
   379       end
   366     end
   380     end
   367     i = i + 1
   381     i = i + 1
   368   end
   382   end
       
   383   curEvent = 0
   369 end
   384 end
   370 
   385 
   371 -------------------------------------Misc---------------------------------
   386 -------------------------------------Misc---------------------------------
   372 
   387 
   373 function StoppedGear(gear)
   388 function StoppedGear(gear)