using System; using System.Collections.Generic; using CIG.Extensions; using Engine.DependencyTree; using SUISS.Core; using UnityEngine; using UnityEngine.UI; public abstract class QuestTabContentView : MonoBehaviour { protected void OnDestroy() { this.DeinitView(); } public void InitView() { this.DeinitView(); SingletonMonobehaviour.Instance.DependencyActiveChangedEvent += this.OnDependencyActiveChanged; this.RefreshQuests(); this._scrollRect.normalizedPosition = Vector2.zero; this.InvokeNextFrame(delegate { this._scrollRect.normalizedPosition = Vector2.zero; }); } public void DeinitView() { if (SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.DependencyActiveChangedEvent -= this.OnDependencyActiveChanged; } this.OnDeinit(); } protected bool HasQuest(Dependency dependency) { return this._quests != null && this._quests.Contains(dependency); } protected abstract void RefreshQuests(); protected virtual void OnDeinit() { } private void OnDependencyActiveChanged(Dependency dependency, bool active) { if (this.HasQuest(dependency)) { this.RefreshQuests(); } } [SerializeField] private ScrollRect _scrollRect; protected List _quests = new List(); }