< Summary

Class:BuilderInWorldLoadingController
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/BuilderInWorldLoadingController.cs
Covered lines:23
Uncovered lines:9
Coverable lines:32
Total lines:95
Line coverage:71.8% (23 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BuilderInWorldLoadingController()0%2100%
Initialize()0%110100%
Initialize(...)0%110100%
AssignMainView(...)0%220100%
CreateView()0%110100%
Dispose()0%330100%
Show()0%2.062075%
SetLoadingType(...)0%2100%
Hide(...)0%4.123050%
SetPercentage(...)0%2.062075%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/BuilderInWorldLoadingController.cs

#LineLine coverage
 1using System;
 2using DCL;
 3using DCL.Builder;
 4using UnityEngine;
 5
 6public interface IBuilderInWorldLoadingController
 7{
 8    bool isActive { get; }
 9
 10    void Initialize();
 11    void Dispose();
 12    void Show();
 13
 14    /// <summary>
 15    /// This will change the way the builder is loaded, this should be called before show or hide to work properly
 16    /// </summary>
 17    /// <param name="sceneType"></param>
 18    void SetLoadingType(ISceneManager.SceneType sceneType);
 19
 20    void Hide(bool forzeHidding = false, Action onHideAction = null);
 21    void SetPercentage(float newValue);
 22}
 23
 24public class BuilderInWorldLoadingController : IBuilderInWorldLoadingController
 25{
 026    public bool isActive => initialLoadingView != null && initialLoadingView.isActive;
 27
 28    internal IBuilderInWorldLoadingView initialLoadingView;
 29
 30    private const string VIEW_PATH = "BuilderInWorldLoadingView";
 031    private ISceneManager.SceneType sceneType = ISceneManager.SceneType.DEPLOYED;
 32
 2833    public void Initialize() { AssignMainView(CreateView()); }
 34
 635    public void Initialize(IBuilderInWorldLoadingView view) { AssignMainView(view); }
 36
 37    internal void AssignMainView(IBuilderInWorldLoadingView view)
 38    {
 1739        initialLoadingView = view;
 40
 1741        if (initialLoadingView.gameObject != null)
 1442            initialLoadingView.gameObject.SetActive(false);
 1743    }
 44
 45    private IBuilderInWorldLoadingView CreateView()
 46    {
 1447        var view = UnityEngine.Object.Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<IBuilderInWorldLoa
 1448        view.gameObject.name = "_BuildModeLoadingHUD";
 49
 1450        return view;
 51    }
 52
 53    public void Dispose()
 54    {
 1755        if ( initialLoadingView == null || initialLoadingView.gameObject == null )
 356            return;
 57
 1458        initialLoadingView.Dispose();
 1459        UnityEngine.Object.Destroy(initialLoadingView.gameObject);
 1460    }
 61
 62    public void Show()
 63    {
 164        if(sceneType == ISceneManager.SceneType.PROJECT)
 065            DataStore.i.HUDs.loadingHUD.visible.Set(true);
 66        else
 167            initialLoadingView.Show();
 168    }
 69
 70    public void SetLoadingType(ISceneManager.SceneType sceneType)
 71    {
 072        this.sceneType = sceneType;
 073    }
 74
 75    public void Hide(bool forzeHidding = false, Action onHideAction = null)
 76    {
 177        if (sceneType == ISceneManager.SceneType.PROJECT)
 78        {
 079            DataStore.i.HUDs.loadingHUD.visible.Set(false);
 080            onHideAction?.Invoke();
 081        }
 82        else
 83        {
 184            initialLoadingView.Hide(forzeHidding, onHideAction);
 85        }
 186    }
 87
 88    public void SetPercentage(float newValue)
 89    {
 190        if(sceneType == ISceneManager.SceneType.PROJECT)
 091            DataStore.i.HUDs.loadingHUD.percentage.Set(newValue);
 92        else
 193            initialLoadingView.SetPercentage(newValue);
 194    }
 95}