< Summary

Class:MainScripts.DCL.Controllers.HUD.Preloading.PreloadingController
Assembly:Preloading
File(s):/tmp/workspace/explorer-desktop/unity-renderer-desktop/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Preloading/PreloadingController.cs
Covered lines:0
Uncovered lines:24
Coverable lines:24
Total lines:57
Line coverage:0% (0 of 24)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PreloadingController()0%2100%
OnDecoupledLoadingScreenVisibilityChange(...)0%6200%
GetView()0%2100%
Dispose()0%6200%
OnMessageChange(...)0%6200%
SignUpFlowChanged(...)0%6200%

File(s)

/tmp/workspace/explorer-desktop/unity-renderer-desktop/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Preloading/PreloadingController.cs

#LineLine coverage
 1using System;
 2using DCL;
 3using UnityEngine;
 4using Object = UnityEngine.Object;
 5
 6namespace MainScripts.DCL.Controllers.HUD.Preloading
 7{
 8    public class PreloadingController : IDisposable
 9    {
 10        private GameObject view;
 11        private readonly DataStoreRef<DataStore_LoadingScreen> loadingScreenRef;
 12
 013        private BaseVariable<bool> isSignUpFlow => DataStore.i.common.isSignUpFlow;
 14        private bool isDisposed = false;
 15
 016        public PreloadingController()
 17        {
 018            view = Object.Instantiate(GetView());
 019            loadingScreenRef.Ref.loadingHUD.message.OnChange += OnMessageChange;
 020            loadingScreenRef.Ref.decoupledLoadingHUD.visible.OnChange += OnDecoupledLoadingScreenVisibilityChange;
 021            isSignUpFlow.OnChange += SignUpFlowChanged;
 022        }
 23
 24        private void OnDecoupledLoadingScreenVisibilityChange(bool current, bool _)
 25        {
 026            if(current)
 027                Dispose();
 028        }
 29
 30        private GameObject GetView()
 31        {
 032            return Resources.Load<GameObject>("Preloading");
 33        }
 34
 35        public void Dispose()
 36        {
 037            if (isDisposed) return;
 038            isDisposed = true;
 039            loadingScreenRef.Ref.loadingHUD.message.OnChange -= OnMessageChange;
 040            loadingScreenRef.Ref.decoupledLoadingHUD.visible.OnChange -= OnDecoupledLoadingScreenVisibilityChange;
 041            isSignUpFlow.OnChange -= SignUpFlowChanged;
 042            Object.Destroy(view.gameObject);
 043        }
 44
 45        private void OnMessageChange(string current, string previous)
 46        {
 047            if (current.Contains("%"))
 048                Dispose();
 049        }
 50
 51        private void SignUpFlowChanged(bool current, bool previous)
 52        {
 053            if (current)
 054                Dispose();
 055        }
 56    }
 57}