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.
|
- using System;
- using CIGEnums;
- using SUISSEngine;
- using UnityEngine;
-
- public class HUDViewStateListener : MonoBehaviour
- {
- protected void Awake()
- {
- this._combinedStates = (HUDViewState)0;
- foreach (HUDViewState hudviewState in this.visibleStates)
- {
- this._combinedStates |= hudviewState;
- }
- }
-
- protected void Start()
- {
- if (this.hudView != null && !this._registered)
- {
- this.hudView.viewStateChangedEvent += this.OnViewStateChanged;
- this._registered = true;
- }
- if (this.hudView != null)
- {
- this._stateVisible = ((this.hudView.ViewState & this._combinedStates) != (HUDViewState)0);
- }
- if (this._stateVisible != base.gameObject.activeSelf)
- {
- base.gameObject.SetActive(this._stateVisible);
- }
- }
-
- protected void OnDestroy()
- {
- if (this.hudView != null && this._registered)
- {
- this.hudView.viewStateChangedEvent -= this.OnViewStateChanged;
- this._registered = false;
- }
- }
-
- protected void OnViewStateChanged(HUDViewState oldState, HUDViewState newState)
- {
- bool flag = (newState & this._combinedStates) != (HUDViewState)0;
- if (this._stateVisible != flag)
- {
- this._stateVisible = flag;
- if (!this._override)
- {
- base.gameObject.SetActive(this._stateVisible);
- }
- }
- }
-
- public void SetOverride(bool visible)
- {
- bool flag = (!this._override) ? this._stateVisible : this._overrideVisible;
- this._override = true;
- this._overrideVisible = visible;
- if (flag != visible)
- {
- base.gameObject.SetActive(this._overrideVisible);
- }
- }
-
- public void ClearOverride()
- {
- if (this._override)
- {
- this._override = false;
- if (this._overrideVisible != this._stateVisible)
- {
- base.gameObject.SetActive(this._stateVisible);
- }
- }
- }
-
- public HUDViewState[] visibleStates;
-
- [SerializeField]
- [ParentReference]
- protected HUDView hudView;
-
- protected bool _registered;
-
- protected HUDViewState _combinedStates;
-
- protected bool _stateVisible;
-
- protected bool _override;
-
- protected bool _overrideVisible;
- }
|