< Summary

Class:DCL.AvatarLODController
Assembly:AvatarLODController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarLOD/AvatarLODController/AvatarLODController.cs
Covered lines:28
Uncovered lines:10
Coverable lines:38
Total lines:85
Line coverage:73.6% (28 of 38)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AvatarLODController(...)0%4.054085.71%
SetLOD0()0%440100%
SetLOD1()0%440100%
SetLOD2()0%440100%
SetInvisible()0%4.134080%
SetAnimationThrottling(...)0%2100%
SetNameVisible(...)0%20400%
UpdateImpostorTint(...)0%2100%
Dispose()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarLOD/AvatarLODController/AvatarLODController.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using UnityEngine;
 4
 5namespace DCL
 6{
 7    //TODO Rename to IAvatar (not now to avoid conflicts)
 8    public interface IAvatarLODController : IDisposable
 9    {
 10        Player player { get; }
 11        void SetLOD0();
 12        void SetLOD1();
 13        void SetLOD2();
 14        public void SetAnimationThrottling(int framesBetweenUpdates);
 15        void SetInvisible();
 16        void UpdateImpostorTint(float distanceToMainPlayer);
 17        void SetNameVisible(bool visible);
 18    }
 19
 20    public class AvatarLODController : IAvatarLODController
 21    {
 822        private string VISIBILITY_CONSTRAIN = "behind_camera_or_out_of_limits";
 023        public Player player { get; }
 24
 825        public AvatarLODController(Player player)
 26        {
 827            this.player = player;
 828            if (player?.avatar == null)
 029                return;
 830            player.avatar.SetLODLevel(0);
 831        }
 32
 33        public void SetLOD0()
 34        {
 335            if (player?.avatar == null)
 136                return;
 37
 238            player.onPointerDownCollider.SetColliderEnabled(true);
 239            player.avatar.SetLODLevel(0);
 240            player.avatar.RemoveVisibilityConstrain(VISIBILITY_CONSTRAIN);
 241        }
 42
 43        public void SetLOD1()
 44        {
 245            if (player?.avatar == null)
 146                return;
 47
 148            player.onPointerDownCollider.SetColliderEnabled(true);
 149            player.avatar.SetLODLevel(1);
 150            player.avatar.RemoveVisibilityConstrain(VISIBILITY_CONSTRAIN);
 151        }
 52
 53        public void SetLOD2()
 54        {
 255            if (player?.avatar == null)
 156                return;
 57
 158            player.onPointerDownCollider.SetColliderEnabled(false);
 159            player.avatar.SetLODLevel(2);
 160            player.avatar.RemoveVisibilityConstrain(VISIBILITY_CONSTRAIN);
 161        }
 62
 63        public void SetInvisible()
 64        {
 165            if (player?.avatar == null)
 066                return;
 67
 168            player.avatar.AddVisibilityConstrain(VISIBILITY_CONSTRAIN);
 169            player.onPointerDownCollider.SetColliderEnabled(false);
 170        }
 71
 072        public void SetAnimationThrottling(int framesBetweenUpdates) { player.avatar.SetAnimationThrottling(framesBetwee
 73
 74        public void SetNameVisible(bool visible)
 75        {
 076            if (visible)
 077                player?.playerName.Show();
 78            else
 079                player?.playerName.Hide();
 080        }
 081        public void UpdateImpostorTint(float distanceToMainPlayer) { player.avatar.SetImpostorTint(AvatarRendererHelpers
 82
 083        public void Dispose() { }
 84    }
 85}