< Summary

Class:OtherPlayerGetAnchorPointsHandler
Assembly:AvatarAttach
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/AvatarAttach/AnchorPointsGetterHandlers/OtherPlayerGetAnchorPointsHandler.cs
Covered lines:24
Uncovered lines:2
Coverable lines:26
Total lines:61
Line coverage:92.3% (24 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
OtherPlayerGetAnchorPointsHandler()0%110100%
GetAnchorPoints(...)0%330100%
CleanUp()0%110100%
Dispose()0%110100%
OnOtherPlayersAdded(...)0%3.073080%
OnOtherPlayersRemoved(...)0%3.143075%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/AvatarAttach/AnchorPointsGetterHandlers/OtherPlayerGetAnchorPointsHandler.cs

#LineLine coverage
 1using System;
 2using DCL;
 3
 4internal class OtherPlayerGetAnchorPointsHandler : IAnchorPointsGetterHandler
 5{
 6    public event Action<string> OnAvatarRemoved;
 7    public event Action<string, IAvatarAnchorPoints> OnAvatarFound;
 8
 529    private IBaseDictionary<string, Player> otherPlayers => DataStore.i.player.otherPlayers;
 10    private string avatarId;
 11
 1512    public OtherPlayerGetAnchorPointsHandler()
 13    {
 1514        otherPlayers.OnRemoved += OnOtherPlayersRemoved;
 1515    }
 16
 17    public void GetAnchorPoints(string id)
 18    {
 819        avatarId = id;
 20
 821        if (otherPlayers.TryGetValue(avatarId, out Player player))
 22        {
 623            OnAvatarFound?.Invoke(avatarId, player.anchorPoints);
 624            return;
 25        }
 26
 227        otherPlayers.OnAdded -= OnOtherPlayersAdded;
 228        otherPlayers.OnAdded += OnOtherPlayersAdded;
 229    }
 30
 31    public void CleanUp()
 32    {
 1733        avatarId = null;
 1734        otherPlayers.OnAdded -= OnOtherPlayersAdded;
 1735    }
 36
 37    public void Dispose()
 38    {
 739        CleanUp();
 740        otherPlayers.OnRemoved -= OnOtherPlayersRemoved;
 741    }
 42
 43    private void OnOtherPlayersAdded(string id, Player player)
 44    {
 145        if (id != avatarId)
 46        {
 047            return;
 48        }
 149        OnAvatarFound?.Invoke(avatarId, player.anchorPoints);
 150        otherPlayers.OnAdded -= OnOtherPlayersAdded;
 151    }
 52
 53    private void OnOtherPlayersRemoved(string id, Player player)
 54    {
 255        if (id != avatarId)
 56        {
 057            return;
 58        }
 259        OnAvatarRemoved?.Invoke(avatarId);
 260    }
 61}