您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
 
 
 

95 行
2.0 KiB

  1. using System;
  2. using CIGEnums;
  3. using SUISSEngine;
  4. using UnityEngine;
  5. public class HUDViewStateListener : MonoBehaviour
  6. {
  7. protected void Awake()
  8. {
  9. this._combinedStates = (HUDViewState)0;
  10. foreach (HUDViewState hudviewState in this.visibleStates)
  11. {
  12. this._combinedStates |= hudviewState;
  13. }
  14. }
  15. protected void Start()
  16. {
  17. if (this.hudView != null && !this._registered)
  18. {
  19. this.hudView.viewStateChangedEvent += this.OnViewStateChanged;
  20. this._registered = true;
  21. }
  22. if (this.hudView != null)
  23. {
  24. this._stateVisible = ((this.hudView.ViewState & this._combinedStates) != (HUDViewState)0);
  25. }
  26. if (this._stateVisible != base.gameObject.activeSelf)
  27. {
  28. base.gameObject.SetActive(this._stateVisible);
  29. }
  30. }
  31. protected void OnDestroy()
  32. {
  33. if (this.hudView != null && this._registered)
  34. {
  35. this.hudView.viewStateChangedEvent -= this.OnViewStateChanged;
  36. this._registered = false;
  37. }
  38. }
  39. protected void OnViewStateChanged(HUDViewState oldState, HUDViewState newState)
  40. {
  41. bool flag = (newState & this._combinedStates) != (HUDViewState)0;
  42. if (this._stateVisible != flag)
  43. {
  44. this._stateVisible = flag;
  45. if (!this._override)
  46. {
  47. base.gameObject.SetActive(this._stateVisible);
  48. }
  49. }
  50. }
  51. public void SetOverride(bool visible)
  52. {
  53. bool flag = (!this._override) ? this._stateVisible : this._overrideVisible;
  54. this._override = true;
  55. this._overrideVisible = visible;
  56. if (flag != visible)
  57. {
  58. base.gameObject.SetActive(this._overrideVisible);
  59. }
  60. }
  61. public void ClearOverride()
  62. {
  63. if (this._override)
  64. {
  65. this._override = false;
  66. if (this._overrideVisible != this._stateVisible)
  67. {
  68. base.gameObject.SetActive(this._stateVisible);
  69. }
  70. }
  71. }
  72. public HUDViewState[] visibleStates;
  73. [SerializeField]
  74. [ParentReference]
  75. protected HUDView hudView;
  76. protected bool _registered;
  77. protected HUDViewState _combinedStates;
  78. protected bool _stateVisible;
  79. protected bool _override;
  80. protected bool _overrideVisible;
  81. }