< Summary

Class:DCL.Tutorial.TutorialStep_Tooltip_SocialFeatures
Assembly:Onboarding
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/Steps/Initial/TutorialStep_Tooltip_SocialFeatures.cs
Covered lines:35
Uncovered lines:9
Coverable lines:44
Total lines:115
Line coverage:79.5% (35 of 44)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
OnStepStart()0%7.487078.57%
OnStepFinished()0%6.566075%
SetTooltipPosition()0%6.65060%
WorldChatWindowHud_OnOpen()0%2100%
FriendsHud_OnFriendsOpened()0%110100%
FriendsHud_OnFriendsClosed()0%110100%
VoiceChatAction_OnStarted(...)0%110100%
VoiceChatAction_OnFinished(...)0%110100%
SocialFeatureIsOpen(...)0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/Steps/Initial/TutorialStep_Tooltip_SocialFeatures.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL.Tutorial
 4{
 5    /// <summary>
 6    /// Class that represents the onboarding tutorial step related to show the social features available in the taskbar.
 7    /// </summary>
 8    public class TutorialStep_Tooltip_SocialFeatures : TutorialStep_Tooltip
 9    {
 10        private const int TEACHER_CANVAS_SORT_ORDER_START = 4;
 11
 12        [SerializeField] InputAction_Hold voiceChatAction;
 13
 14        private int defaultTeacherCanvasSortOrder;
 15
 16        public override void OnStepStart()
 17        {
 318            base.OnStepStart();
 19
 320            if (tutorialController.configuration.teacherCanvas != null)
 321                defaultTeacherCanvasSortOrder = tutorialController.configuration.teacherCanvas.sortingOrder;
 22
 323            tutorialController.SetTeacherCanvasSortingOrder(TEACHER_CANVAS_SORT_ORDER_START);
 24
 325            if (tutorialController != null &&
 26                tutorialController.hudController != null)
 27            {
 328                if (tutorialController.hudController.worldChatWindowHud != null)
 29                {
 030                    tutorialController.hudController.worldChatWindowHud.OnOpen += WorldChatWindowHud_OnOpen;
 31                }
 32
 333                if (tutorialController.hudController.friendsHud != null)
 34                {
 035                    tutorialController.hudController.friendsHud.OnFriendsOpened += FriendsHud_OnFriendsOpened;
 036                    tutorialController.hudController.friendsHud.OnFriendsClosed += FriendsHud_OnFriendsClosed;
 37                }
 38
 339                if (voiceChatAction != null)
 40                {
 341                    voiceChatAction.OnStarted += VoiceChatAction_OnStarted;
 342                    voiceChatAction.OnFinished += VoiceChatAction_OnFinished;
 43                }
 44            }
 345        }
 46
 47        public override void OnStepFinished()
 48        {
 349            base.OnStepFinished();
 50
 351            tutorialController.SetTeacherCanvasSortingOrder(defaultTeacherCanvasSortOrder);
 52
 353            if (tutorialController != null &&
 54                tutorialController.hudController != null)
 55            {
 356                if (tutorialController.hudController.worldChatWindowHud != null)
 57                {
 058                    tutorialController.hudController.worldChatWindowHud.OnOpen -= WorldChatWindowHud_OnOpen;
 59                }
 60
 361                if (tutorialController.hudController.friendsHud != null)
 62                {
 063                    tutorialController.hudController.friendsHud.OnFriendsOpened -= FriendsHud_OnFriendsOpened;
 064                    tutorialController.hudController.friendsHud.OnFriendsClosed -= FriendsHud_OnFriendsClosed;
 65                }
 66
 367                if (voiceChatAction != null)
 68                {
 369                    voiceChatAction.OnStarted -= VoiceChatAction_OnStarted;
 370                    voiceChatAction.OnFinished -= VoiceChatAction_OnFinished;
 71                }
 72            }
 373        }
 74
 75        protected override void SetTooltipPosition()
 76        {
 377            base.SetTooltipPosition();
 78
 379            if (tutorialController != null &&
 80                tutorialController.hudController != null &&
 81                tutorialController.hudController.taskbarHud != null)
 82            {
 083                if (tutorialController.hudController.taskbarHud.socialTooltipReference)
 84                {
 085                    tooltipTransform.position =
 86                        tutorialController.hudController.taskbarHud.socialTooltipReference.position;
 87                }
 88            }
 389        }
 90
 091        internal void WorldChatWindowHud_OnOpen() { stepIsFinished = true; }
 92
 293        internal void FriendsHud_OnFriendsOpened() { SocialFeatureIsOpen(true); }
 94
 295        internal void FriendsHud_OnFriendsClosed() { SocialFeatureIsOpen(false); }
 96
 297        internal void VoiceChatAction_OnStarted(DCLAction_Hold action) { SocialFeatureIsOpen(true); }
 98
 299        internal void VoiceChatAction_OnFinished(DCLAction_Hold action) { SocialFeatureIsOpen(false); }
 100
 101        private void SocialFeatureIsOpen(bool isOpen)
 102        {
 4103            if (isOpen)
 104            {
 2105                isRelatedFeatureActived = true;
 2106                stepIsFinished = true;
 2107                tutorialController.PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.QuickGoodbye);
 2108            }
 2109            else if (isRelatedFeatureActived)
 110            {
 2111                isRelatedFeatureActived = false;
 112            }
 2113        }
 114    }
 115}