< Summary

Class:AvatarNamesHUD.AvatarNamesHUDController
Assembly:AvatarNamesHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AvatarNamesHUD/AvatarNamesHUDController.cs
Covered lines:24
Uncovered lines:1
Coverable lines:25
Total lines:55
Line coverage:96% (24 of 25)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AvatarNamesHUDController()0%110100%
CreateView()0%110100%
Initialize()0%440100%
OnOtherPlayersStatusAdded(...)0%330100%
OnOtherPlayersStatusRemoved(...)0%330100%
SetVisibility(...)0%220100%
Dispose()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AvatarNamesHUD/AvatarNamesHUDController.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using DCL;
 3
 4namespace AvatarNamesHUD
 5{
 6    public class AvatarNamesHUDController : IHUD
 7    {
 08        private BaseDictionary<string, Player> otherPlayers => DataStore.i.player.otherPlayers;
 9
 10        internal IAvatarNamesHUDView view;
 611        internal readonly HashSet<string> trackingPlayers = new HashSet<string>();
 12
 113        internal virtual IAvatarNamesHUDView CreateView() { return AvatarNamesHUDView.CreateView(); }
 14
 15        public void Initialize()
 16        {
 617            view = CreateView();
 618            view?.Initialize();
 19
 620            otherPlayers.OnAdded += OnOtherPlayersStatusAdded;
 621            otherPlayers.OnRemoved += OnOtherPlayersStatusRemoved;
 622            using var enumerator = otherPlayers.Get().GetEnumerator();
 1023            while (enumerator.MoveNext())
 24            {
 425                OnOtherPlayersStatusAdded(enumerator.Current.Key, enumerator.Current.Value);
 26            }
 1227        }
 28
 29        internal void OnOtherPlayersStatusAdded(string userId, Player player)
 30        {
 1031            if (trackingPlayers.Contains(userId))
 232                return;
 33
 834            trackingPlayers.Add(userId);
 835            view?.TrackPlayer(player);
 836        }
 37
 38        internal void OnOtherPlayersStatusRemoved(string userId, Player player)
 39        {
 340            if (!trackingPlayers.Remove(userId))
 141                return;
 42
 243            view?.UntrackPlayer(userId);
 244        }
 45
 246        public void SetVisibility(bool visible) { view?.SetVisibility(visible); }
 47
 48        public void Dispose()
 49        {
 150            otherPlayers.OnAdded -= OnOtherPlayersStatusAdded;
 151            otherPlayers.OnRemoved -= OnOtherPlayersStatusRemoved;
 152            view?.Dispose();
 153        }
 54    }
 55}