< Summary

Class:DCL.Tutorial.TutorialStep_OpenControlsPanel
Assembly:Onboarding
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/Steps/Initial/TutorialStep_OpenControlsPanel.cs
Covered lines:22
Uncovered lines:4
Coverable lines:26
Total lines:72
Line coverage:84.6% (22 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
OnStepStart()0%5.395075%
OnStepExecute()0%330100%
OnStepFinished()0%5.585071.43%
ControlsHud_OnControlsOpened()0%660100%
ControlsHud_OnControlsClosed()0%330100%

File(s)

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

#LineLine coverage
 1using System.Collections;
 2using UnityEngine;
 3
 4namespace DCL.Tutorial
 5{
 6    /// <summary>
 7    /// Class that represents the onboarding tutorial step related to how to open the controls panel.
 8    /// </summary>
 9    public class TutorialStep_OpenControlsPanel : TutorialStep
 10    {
 11        [SerializeField] AudioEvent audioEventSuccess;
 12        [SerializeField] private InputAction_Trigger toggleControlsHud;
 13
 14        private bool controlsHasBeenOpened = false;
 15        private bool controlsHasBeenClosed = false;
 16        private BooleanVariable originalControlsTriggerIsBlocked;
 17
 18        public override void OnStepStart()
 19        {
 120            base.OnStepStart();
 21
 122            originalControlsTriggerIsBlocked = toggleControlsHud.isTriggerBlocked;
 123            if (toggleControlsHud != null)
 124                toggleControlsHud.isTriggerBlocked = null;
 25
 126            if (tutorialController != null &&
 27                tutorialController.hudController != null &&
 28                tutorialController.hudController.controlsHud != null)
 29            {
 030                tutorialController.hudController.controlsHud.OnControlsOpened += ControlsHud_OnControlsOpened;
 031                tutorialController.hudController.controlsHud.OnControlsClosed += ControlsHud_OnControlsClosed;
 32            }
 133        }
 34
 35        public override IEnumerator OnStepExecute()
 36        {
 437            yield return new WaitUntil(() => controlsHasBeenOpened && controlsHasBeenClosed);
 138            audioEventSuccess.Play(true);
 139        }
 40
 41        public override void OnStepFinished()
 42        {
 143            base.OnStepFinished();
 44
 145            if (tutorialController != null &&
 46                tutorialController.hudController != null &&
 47                tutorialController.hudController.controlsHud != null)
 48            {
 049                tutorialController.hudController.controlsHud.OnControlsOpened -= ControlsHud_OnControlsOpened;
 050                tutorialController.hudController.controlsHud.OnControlsClosed -= ControlsHud_OnControlsClosed;
 51            }
 52
 153            if (toggleControlsHud != null)
 154                toggleControlsHud.isTriggerBlocked = originalControlsTriggerIsBlocked;
 155        }
 56
 57        internal void ControlsHud_OnControlsOpened()
 58        {
 159            if (!controlsHasBeenOpened && mainSection.activeSelf)
 160                controlsHasBeenOpened = true;
 61
 162            tutorialController?.hudController?.taskbarHud?.SetVisibility(true);
 163            CommonScriptableObjects.featureKeyTriggersBlocked.Set(false);
 164        }
 65
 66        internal void ControlsHud_OnControlsClosed()
 67        {
 168            if (controlsHasBeenOpened && mainSection.activeSelf)
 169                controlsHasBeenClosed = true;
 170        }
 71    }
 72}