< Summary

Class:DCL.Huds.QuestsTracker.QuestsNotificationsController
Assembly:QuestsTrackerHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsTrackerHUD/QuestsNotificationsController.cs
Covered lines:18
Uncovered lines:12
Coverable lines:30
Total lines:71
Line coverage:60% (18 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
QuestsNotificationsController()0%110100%
QuestsNotificationsController()0%110100%
Create()0%2100%
Awake()0%110100%
ShowQuestCompleted(...)0%110100%
ShowRewardObtained(...)0%2100%
SetVisibility(...)0%2100%
Dispose()0%6200%
OnDestroy()0%110100%
ProcessSectionsNotificationQueue()0%550100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsTrackerHUD/QuestsNotificationsController.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using DCL.Huds.QuestsTracker;
 4using UnityEngine;
 5
 6namespace DCL.Huds.QuestsTracker
 7{
 8    public class QuestsNotificationsController : MonoBehaviour
 9    {
 110        internal static float NOTIFICATIONS_SEPARATION { get; set; } = 0.5f;
 111        public static float DEFAULT_NOTIFICATION_DURATION { get; set; } = 2.5f;
 12
 1613        internal readonly Queue<IQuestNotification> notificationsQueue = new Queue<IQuestNotification>();
 14
 15        [SerializeField] private GameObject questCompletedPrefab;
 16        [SerializeField] private GameObject rewardObtainedPrefab;
 17        private bool isDestroyed = false;
 18
 19        internal static QuestsNotificationsController Create()
 20        {
 021            QuestsNotificationsController view = Instantiate(Resources.Load<GameObject>("QuestsNotificationsHUD")).GetCo
 22#if UNITY_EDITOR
 023            view.gameObject.name = "_QuestsNotificationsHUDView";
 24#endif
 025            return view;
 26        }
 27
 2828        private void Awake() { StartCoroutine(ProcessSectionsNotificationQueue()); }
 29
 30        public void ShowQuestCompleted(QuestModel quest)
 31        {
 332            var questNotification = Instantiate(questCompletedPrefab, transform).GetComponent<QuestNotification_QuestCom
 333            questNotification.Populate(quest);
 334            questNotification.gameObject.SetActive(false);
 335            notificationsQueue.Enqueue(questNotification);
 336        }
 37
 38        public void ShowRewardObtained(QuestReward reward)
 39        {
 040            var questNotification = Instantiate(rewardObtainedPrefab, transform).GetComponent<QuestNotification_RewardOb
 041            questNotification.Populate(reward);
 042            questNotification.gameObject.SetActive(false);
 043            notificationsQueue.Enqueue(questNotification);
 044        }
 45
 046        public void SetVisibility(bool visible) { gameObject.SetActive(visible); }
 47        public void Dispose()
 48        {
 049            if (!isDestroyed)
 050                Destroy(gameObject);
 051        }
 52
 2853        private void OnDestroy() { isDestroyed = true; }
 54
 55        private IEnumerator ProcessSectionsNotificationQueue()
 56        {
 1657            while (true)
 58            {
 3059                if (notificationsQueue.Count > 0)
 60                {
 261                    IQuestNotification notification = notificationsQueue.Dequeue();
 262                    notification.Show();
 263                    yield return notification.Waiter();
 264                    notification.Dispose();
 265                }
 66
 3067                yield return WaitForSecondsCache.Get(NOTIFICATIONS_SEPARATION);
 68            }
 69        }
 70    }
 71}