< Summary

Class:AvatarSystem.Visibility
Assembly:AvatarSystem
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/Visibility.cs
Covered lines:32
Uncovered lines:12
Coverable lines:44
Total lines:96
Line coverage:72.7% (32 of 44)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Visibility()0%110100%
Bind(...)0%110100%
AddGlobalConstrain(...)0%110100%
RemoveGlobalConstrain(...)0%110100%
AddCombinedRendererConstrain(...)0%2100%
RemoveCombinedRendererConstrain(...)0%2100%
AddFacialFeaturesConstrain(...)0%2100%
RemoveFacialFeaturesConstrain(...)0%2100%
UpdateCombinedRendererVisibility()0%330100%
UpdateFacialFeatureVisibility()0%440100%
Dispose()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/Visibility.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using UnityEngine;
 3
 4namespace AvatarSystem
 5{
 6    public class Visibility : IVisibility
 7    {
 13308        internal readonly HashSet<string> globalConstrains = new HashSet<string>();
 13309        internal readonly HashSet<string> combinedRendererConstrains = new HashSet<string>();
 133010        internal readonly HashSet<string> facialFeaturesConstrains = new HashSet<string>();
 11
 12        private Renderer combinedRenderer = null;
 13        private List<Renderer> facialFeatures = null;
 14
 15        /// <summary>
 16        /// Bind a set of renderers, previous renderers enabled wont be modified
 17        /// </summary>
 18        /// <param name="combinedRenderer"></param>
 19        /// <param name="facialFeatures"></param>
 20        public void Bind(Renderer combinedRenderer, List<Renderer> facialFeatures)
 21        {
 2622            this.combinedRenderer = combinedRenderer;
 2623            this.facialFeatures = facialFeatures;
 2624            UpdateCombinedRendererVisibility();
 2625            UpdateFacialFeatureVisibility();
 2626        }
 27
 28        public void AddGlobalConstrain(string key)
 29        {
 11530            globalConstrains.Add(key);
 11531            UpdateCombinedRendererVisibility();
 11532            UpdateFacialFeatureVisibility();
 11533        }
 34
 35        public void RemoveGlobalConstrain(string key)
 36        {
 537            globalConstrains.Remove(key);
 538            UpdateCombinedRendererVisibility();
 539            UpdateFacialFeatureVisibility();
 540        }
 41
 42        public void AddCombinedRendererConstrain(string key)
 43        {
 044            combinedRendererConstrains.Add(key);
 045            UpdateCombinedRendererVisibility();
 046        }
 47
 48        public void RemoveCombinedRendererConstrain(string key)
 49        {
 050            combinedRendererConstrains.Remove(key);
 051            UpdateCombinedRendererVisibility();
 052        }
 53
 54        public void AddFacialFeaturesConstrain(string key)
 55        {
 056            facialFeaturesConstrains.Add(key);
 057            UpdateFacialFeatureVisibility();
 058        }
 59
 60        public void RemoveFacialFeaturesConstrain(string key)
 61        {
 062            facialFeaturesConstrains.Remove(key);
 063            UpdateFacialFeatureVisibility();
 064        }
 65
 66        internal void UpdateCombinedRendererVisibility()
 67        {
 15968            if (combinedRenderer == null)
 12069                return;
 70
 3971            combinedRenderer.enabled = globalConstrains.Count == 0 && combinedRendererConstrains.Count == 0;
 3972        }
 73
 74        internal void UpdateFacialFeatureVisibility()
 75        {
 15976            if (facialFeatures == null)
 12077                return;
 78
 3979            bool facialFeaturesVisibility = globalConstrains.Count == 0 && facialFeaturesConstrains.Count == 0;
 31280            for (int i = 0; i < facialFeatures.Count; i++)
 81            {
 11782                facialFeatures[i].enabled = facialFeaturesVisibility;
 83            }
 3984        }
 85
 86        public void Dispose()
 87        {
 140588            globalConstrains.Clear();
 140589            combinedRendererConstrains.Clear();
 140590            facialFeaturesConstrains.Clear();
 91
 140592            combinedRenderer = null;
 140593            facialFeatures = null;
 140594        }
 95    }
 96}