源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 regels
1.1 KiB

4 weken geleden
  1. LuaFPS = LuaFPS or {}
  2. local LuaFPS = LuaFPS
  3. LuaFPS.FPS = 0
  4. LuaFPS.total_frames = 0
  5. LuaFPS.total_time = 0
  6. LuaFPS.FIXED_FPS = 0
  7. LuaFPS.fixed_total_frames = 0
  8. LuaFPS.fixed_total_time = 0
  9. local Time = Time
  10. function LuaFPS.Update()
  11. LuaFPS.total_frames = LuaFPS.total_frames + 1
  12. LuaFPS.total_time = LuaFPS.total_time + Time.unscaledDeltaTime
  13. if LuaFPS.total_time >= 1 then
  14. LuaFPS.SetFPS()
  15. end
  16. end
  17. function LuaFPS.FixedUpdate()
  18. LuaFPS.fixed_total_frames = LuaFPS.fixed_total_frames + 1
  19. LuaFPS.fixed_total_time = LuaFPS.fixed_total_time + Time.fixedDeltaTime / Time.timeScale
  20. if LuaFPS.fixed_total_time >= 1 then
  21. LuaFPS.SetFixedFPS()
  22. end
  23. end
  24. function LuaFPS.SetFPS()
  25. LuaFPS.FPS = LuaFPS.total_frames
  26. LuaFPS.total_frames = 0
  27. LuaFPS.total_time = 0
  28. GlobalEventSystem:Fire(EventName.SET_FPS,LuaFPS.FPS)
  29. end
  30. function LuaFPS.SetFixedFPS()
  31. LuaFPS.FIXED_FPS = LuaFPS.fixed_total_frames
  32. LuaFPS.fixed_total_frames = 0
  33. LuaFPS.fixed_total_time = 0
  34. GlobalEventSystem:Fire(EventName.SET_FIXED_FPS,LuaFPS.FIXED_FPS)
  35. end
  36. UpdateBeat:Add(LuaFPS.Update)
  37. -- FixedUpdateBeat:Add(LuaFPS.FixedUpdate)