< Summary

Class:DCL.Controllers.BlockerAnimationHandler
Assembly:WorldBlockersController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BlockerController/BlockerAnimationHandler.cs
Covered lines:5
Uncovered lines:15
Coverable lines:20
Total lines:61
Line coverage:25% (5 of 20)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FadeIn(...)0%110100%
FadeOut(...)0%2100%
FadeInCoroutine()0%5.264057.14%
FadeOutCoroutine()0%56700%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BlockerController/BlockerAnimationHandler.cs

#LineLine coverage
 1using System.Collections;
 2using DCL.Helpers;
 3using UnityEngine;
 4
 5namespace DCL.Controllers
 6{
 7    public interface IBlockerAnimationHandler
 8    {
 9        void FadeIn(GameObject go);
 10        void FadeOut(GameObject go, System.Action OnFinish);
 11    }
 12
 13    /// <summary>
 14    /// This class is in charge of handling the FadeIn/FadeOut animation
 15    /// of blockers.
 16    /// </summary>
 17    public class BlockerAnimationHandler : IBlockerAnimationHandler
 18    {
 3219        public void FadeIn(GameObject go) { CoroutineStarter.Start(FadeInCoroutine(go)); }
 20
 021        public void FadeOut(GameObject go, System.Action OnFinish) { CoroutineStarter.Start(FadeOutCoroutine(go, OnFinis
 22
 23        IEnumerator FadeInCoroutine(GameObject go)
 24        {
 1625            Renderer rend = go.GetComponent<Renderer>();
 26
 1627            Color color = rend.material.GetColor(ShaderUtils.BaseColor);
 28
 1629            while (color.a < 0.5f)
 30            {
 031                color.a += Time.deltaTime;
 032                rend.material.SetColor(ShaderUtils.BaseColor, color);
 033                yield return null;
 34            }
 1635        }
 36
 37        IEnumerator FadeOutCoroutine(GameObject go, System.Action OnFinish)
 38        {
 39#if UNITY_STANDALONE || UNITY_EDITOR
 040            if (DataStore.i.common.isApplicationQuitting.Get())
 041                yield break;
 42#endif
 43
 044            Renderer rend = go.GetComponent<Renderer>();
 45
 046            Color color = rend.material.GetColor(ShaderUtils.BaseColor);
 47
 048            while (color.a > 0)
 49            {
 050                if (rend == null)
 51                    break;
 52
 053                color.a -= Time.deltaTime;
 054                rend.material.SetColor(ShaderUtils.BaseColor, color);
 055                yield return null;
 56            }
 57
 058            OnFinish?.Invoke();
 059        }
 60    }
 61}