< Summary

Class:DCL.Huds.QuestsPanel.QuestsPanelSection
Assembly:QuestsPanelHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsPanelHUD/QuestsPanelSection.cs
Covered lines:15
Uncovered lines:4
Coverable lines:19
Total lines:48
Line coverage:78.9% (15 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Populate(...)0%440100%
CreateTask(...)0%3.333066.67%
CleanUpTasksList()0%2.262060%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsPanelHUD/QuestsPanelSection.cs

#LineLine coverage
 1using System.Linq;
 2using TMPro;
 3using UnityEngine;
 4
 5namespace DCL.Huds.QuestsPanel
 6{
 7    public class QuestsPanelSection : MonoBehaviour
 8    {
 9        [SerializeField] internal TextMeshProUGUI sectionName;
 10        [SerializeField] internal RectTransform titleContainer;
 11        [SerializeField] internal RectTransform tasksContainer;
 12        [SerializeField] internal QuestsPanelTaskFactory factory;
 13
 14        public void Populate(QuestModel quest, QuestSection section)
 15        {
 716            CleanUpTasksList();
 717            titleContainer.gameObject.SetActive(!string.IsNullOrEmpty(section.name));
 718            sectionName.text = section.name;
 2119            var orderedTasks = section.tasks.OrderBy(x => x.progress >= 1).ThenBy(x => x.completionTime).ToArray();
 2820            foreach (QuestTask task in orderedTasks)
 21            {
 722                CreateTask(quest, task);
 23            }
 724        }
 25
 26        internal void CreateTask(QuestModel quest, QuestTask task)
 27        {
 728            if (task.status == QuestsLiterals.Status.BLOCKED)
 029                return;
 30
 731            GameObject prefab = factory.GetPrefab(task.type);
 732            if (prefab == null)
 33            {
 034                Debug.LogError($"Type: {task.type} was not found in QuestTaskFactory");
 035                return;
 36            }
 37
 738            var taskUIEntry = Instantiate(prefab, tasksContainer).GetComponent<IQuestsPanelTask>();
 739            taskUIEntry.Populate(quest, task);
 740        }
 41
 42        internal void CleanUpTasksList()
 43        {
 1444            for (int i = tasksContainer.childCount - 1; i >= 0; i--)
 045                Destroy(tasksContainer.GetChild(i).gameObject);
 746        }
 47    }
 48}