using System; using System.Collections.Generic; using CIG; using SUISS.Core; using SUISSEngine; using UnityEngine; public class CIGLocalNotificationManager : SingletonMonobehaviour { protected override void Awake() { base.Awake(); this.CancelAllNotifications(); } private void OnApplicationPause(bool paused) { if (!paused) { this.CancelAllNotifications(); } else { this.SetNotifications(); } } protected override void OnApplicationQuit() { base.OnApplicationQuit(); this.SetNotifications(); } public void HasNotification(IHasNotification hasNotification) { this._hasNotifications.Add(hasNotification); } public void NoLongerHasNotification(IHasNotification hasNoNotifiaction) { if (this._hasNotifications.Contains(hasNoNotifiaction)) { this._hasNotifications.Remove(hasNoNotifiaction); } else { UnityEngine.Debug.LogWarning("HasNotifications doesn't contain this IHasNotification!"); } } public void RequestPermissions() { } public void CancelAllNotifications() { } public bool AreNotificationsAllowed { get { return SingletonMonobehaviour.IsAvailable && SingletonMonobehaviour.IsAvailable && SingletonMonobehaviour.Instance.IsFinished && SingletonMonobehaviour.Instance.TimesCollected >= 5; } } private void SetNotifications() { if (!Singleton.Instance.NotificationsEnabled || !this.AreNotificationsAllowed) { return; } this.CancelAllNotifications(); List list = this.CollectNotifications(); int count = list.Count; } private List CollectNotifications() { List list = new List(); int count = this._hasNotifications.Count; for (int i = 0; i < count; i++) { PlannedNotification[] notifications = this._hasNotifications[i].GetNotifications(); int num = notifications.Length; for (int j = 0; j < num; j++) { PlannedNotification plannedNotification = notifications[j]; if (plannedNotification.IsValid) { list.Add(plannedNotification); } } } list.Sort((PlannedNotification a, PlannedNotification b) => a.Seconds.CompareTo(b.Seconds)); return list; } private List _hasNotifications = new List(); }