RenderTextureInfo.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. local RenderTextureInfo = class("RenderTextureInfo")
  2. function RenderTextureInfo:ctor(data)
  3. self._time = data.time or 0
  4. self._func = data.func
  5. self._isInvalid = false
  6. self._curTime = 0
  7. self._count = data.count or -1
  8. self._id = data.id or -1
  9. end
  10. function RenderTextureInfo:Tick(dt)
  11. if not self:IsInvalid() then
  12. self._curTime = self._curTime + dt
  13. if self._curTime >= self._time and (self._count == -1 or self._count > 0) then
  14. if self._count > 0 then
  15. self._count = self._count - 1
  16. end
  17. if self._count == 0 then
  18. global.RenderTextureManager:RmvDrawFunc(self._id)
  19. end
  20. self._curTime = 0
  21. if self._func then
  22. self._func()
  23. end
  24. end
  25. end
  26. end
  27. function RenderTextureInfo:Reset(data)
  28. self._time = data.time or 0
  29. self._func = data.func
  30. self._isInvalid = false
  31. self._curTime = 0
  32. self._count = data.count or -1
  33. self._id = data.id or -1
  34. end
  35. function RenderTextureInfo:IsInvalid()
  36. return self._isInvalid
  37. end
  38. function RenderTextureInfo:SetInvalid(invalid)
  39. self._isInvalid = invalid
  40. end
  41. function RenderTextureInfo:GetID()
  42. return self._id
  43. end
  44. function RenderTextureInfo:GetCount()
  45. return self._count
  46. end
  47. return RenderTextureInfo