< Summary

Class:OwnPlayerGetAnchorPointsHandler
Assembly:AvatarAttach
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/AvatarAttach/AnchorPointsGetterHandlers/OwnPlayerGetAnchorPointsHandler.cs
Covered lines:18
Uncovered lines:1
Coverable lines:19
Total lines:52
Line coverage:94.7% (18 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetAnchorPoints(...)0%660100%
CleanUp()0%110100%
Dispose()0%110100%
OnOwnPlayerChanged(...)0%3.073080%

File(s)

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

#LineLine coverage
 1using System;
 2using DCL;
 3
 4internal class OwnPlayerGetAnchorPointsHandler : IAnchorPointsGetterHandler
 5{
 6    public event Action<string> OnAvatarRemoved;
 7    public event Action<string, IAvatarAnchorPoints> OnAvatarFound;
 8
 139    private IBaseVariable<Player> ownPlayer => DataStore.i.player.ownPlayer;
 10    private string avatarId;
 11
 12    public void GetAnchorPoints(string id)
 13    {
 214        avatarId = id;
 215        string ownPlayerId = ownPlayer.Get()?.id;
 16
 17        // NOTE: ownPlayerId null means player avatar is not loaded yet
 18        // so we subscribe to the event for when player avatar is set.
 219        if (string.IsNullOrEmpty(ownPlayerId))
 20        {
 121            ownPlayer.OnChange -= OnOwnPlayerChanged;
 122            ownPlayer.OnChange += OnOwnPlayerChanged;
 123            return;
 24        }
 25
 126        if (id == ownPlayerId)
 27        {
 128            OnAvatarFound?.Invoke(id, ownPlayer.Get().anchorPoints);
 29        }
 130    }
 31
 32    public void CleanUp()
 33    {
 734        ownPlayer.OnChange -= OnOwnPlayerChanged;
 735    }
 36
 37    public void Dispose()
 38    {
 739        CleanUp();
 740    }
 41
 42    private void OnOwnPlayerChanged(Player player, Player prev)
 43    {
 144        if (player.id != avatarId)
 45        {
 046            return;
 47        }
 48
 149        ownPlayer.OnChange -= OnOwnPlayerChanged;
 150        OnAvatarFound?.Invoke(player.id, player.anchorPoints);
 151    }
 52}