您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

62 行
1.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using SUISS.Core;
  4. using UnityEngine;
  5. using UnityEngine.SceneManagement;
  6. public class CIGSessionRestarter : SingletonMonobehaviour<CIGSessionRestarter>
  7. {
  8. public void RestartNow()
  9. {
  10. if (SingletonMonobehaviour<PopupManager>.Instance.PopupIsOpen())
  11. {
  12. SingletonMonobehaviour<PopupManager>.Instance.CloseRecursive(false);
  13. }
  14. CIGLoadingScreen.MarkReturnToLoadingScreen();
  15. SceneManager.LoadScene("LoadingScreen");
  16. }
  17. public bool ApplicationPause(bool isPaused)
  18. {
  19. if (isPaused)
  20. {
  21. this._pauseTime = DateTime.UtcNow;
  22. this._isPaused = true;
  23. }
  24. else if (this._isPaused)
  25. {
  26. this._isPaused = false;
  27. if (this._criticalProcesses.Count == 0 && (DateTime.UtcNow - this._pauseTime).TotalSeconds > (double)this.SessionIdleSeconds)
  28. {
  29. this.RestartNow();
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. public void RegisterCriticalProcess(object process)
  36. {
  37. this._criticalProcesses.Add(process);
  38. }
  39. public void UnregisterCriticalProcess(object process)
  40. {
  41. this._criticalProcesses.Remove(process);
  42. }
  43. public float SessionIdleSeconds
  44. {
  45. get
  46. {
  47. return (!Debug.isDebugBuild) ? 900f : 60f;
  48. }
  49. }
  50. private DateTime _pauseTime;
  51. private bool _isPaused;
  52. private List<object> _criticalProcesses = new List<object>();
  53. }