< Summary

Class:DCL.Tutorial.TutorialController
Assembly:Onboarding
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/TutorialController.cs
Covered lines:194
Uncovered lines:77
Coverable lines:271
Total lines:686
Line coverage:71.5% (194 of 271)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TutorialController()0%110100%
CreateTutorialView()0%110100%
SetConfiguration(...)0%3.13077.78%
Dispose()0%4.034087.5%
SetTutorialEnabled(...)0%2100%
SetTutorialEnabledForUsersThatAlreadyDidTheTutorial(...)0%6200%
SetBuilderInWorldTutorialEnabled()0%2100%
SetupTutorial(...)0%9.069090.91%
SetTutorialDisabled()0%8.068090%
StartTutorialFromStep()0%16.1716091.3%
ShowTeacher3DModel(...)0%330100%
SetTeacherPosition(...)0%4.374071.43%
PlayTeacherAnimation(...)0%220100%
SetTeacherCanvasSortingOrder(...)0%2.062075%
SkipTutorial(...)0%7.336066.67%
GoToSpecificStep(...)0%90900%
SetNextSkippedSteps(...)0%2100%
SetEagleEyeCameraActive(...)0%440100%
OnRenderingStateChanged(...)0%5.025090%
ExecuteSteps()0%26.8126089.36%
SetUserTutorialStepAsCompleted(...)0%110100%
MoveTeacher()0%6.976070%
IsSettingsHUDInitialized_OnChange(...)0%20400%
OnRestartTutorial()0%2100%
IsPlayerInsideGenesisPlaza()0%8.817066.67%
SendStepStartedSegmentStats(...)0%2100%
SendStepCompletedSegmentStats(...)0%2100%
SendSkipTutorialSegmentStats(...)0%2100%
EagleEyeCameraRotation()0%330100%
BlockPlayerCameraUntilBlendingIsFinished()0%15150100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/TutorialController.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Helpers;
 3using DCL.Interface;
 4using System;
 5using System.Collections;
 6using System.Collections.Generic;
 7using UnityEngine;
 8
 9namespace DCL.Tutorial
 10{
 11    /// <summary>
 12    /// Controller that handles all the flow related to the onboarding tutorial.
 13    /// </summary>
 14    public class TutorialController : IPlugin
 15    {
 16        [Serializable]
 17        public class TutorialInitializationMessage
 18        {
 19            public string fromDeepLink;
 20            public string enableNewTutorialCamera;
 21        }
 22
 23        [Flags]
 24        public enum TutorialFinishStep
 25        {
 26            None = 0,
 27            OldTutorialValue = 99, // NOTE: old tutorial set tutorialStep to 99 when finished
 28            EmailRequested = 128, // NOTE: old email prompt set tutorialStep to 128 when finished
 29            NewTutorialFinished = 256
 30        }
 31
 32        public enum TutorialType
 33        {
 34            Initial,
 35            BuilderInWorld
 36        }
 37
 38        internal enum TutorialPath
 39        {
 40            FromGenesisPlaza,
 41            FromDeepLink,
 42            FromResetTutorial,
 43            FromBuilderInWorld,
 44            FromUserThatAlreadyDidTheTutorial
 45        }
 46
 1047        public static TutorialController i { get; private set; }
 48
 049        public HUDController hudController { get => HUDController.i; }
 50
 051        public int currentStepIndex { get; internal set; }
 52        public event Action OnTutorialEnabled;
 53        public event Action OnTutorialDisabled;
 54
 55        private const string PLAYER_PREFS_START_MENU_SHOWED = "StartMenuFeatureShowed";
 56
 57        internal TutorialSettings configuration;
 58        internal TutorialView tutorialView;
 59
 60        internal bool openedFromDeepLink = false;
 61        internal bool playerIsInGenesisPlaza = false;
 62        internal TutorialStep runningStep = null;
 63        internal bool tutorialReset = false;
 64        internal float elapsedTimeInCurrentStep = 0f;
 65        internal TutorialPath currentPath;
 66        internal int currentStepNumber;
 67        internal TutorialType tutorialType = TutorialType.Initial;
 68        internal int nextStepsToSkip = 0;
 69
 70        private Coroutine executeStepsCoroutine;
 71        private Coroutine teacherMovementCoroutine;
 72        private Coroutine eagleEyeRotationCoroutine;
 73
 074        internal bool userAlreadyDidTheTutorial { get; set; }
 75
 3976        public TutorialController ()
 77        {
 3978            tutorialView = CreateTutorialView();
 3979            SetConfiguration(tutorialView.configuration);
 3980        }
 81
 82        internal TutorialView CreateTutorialView()
 83        {
 3984            GameObject tutorialGO = GameObject.Instantiate(Resources.Load<GameObject>("TutorialView"));
 3985            tutorialGO.name = "TutorialController";
 3986            TutorialView tutorialView = tutorialGO.GetComponent<TutorialView>();
 3987            tutorialView.ConfigureView(this);
 88
 3989            return tutorialView;
 90        }
 91
 92        public void SetConfiguration(TutorialSettings configuration)
 93        {
 7894            this.configuration = configuration;
 95
 7896            i = this;
 7897            ShowTeacher3DModel(false);
 98
 7899            if (DataStore.i.settings.isInitialized.Get())
 0100                IsSettingsHUDInitialized_OnChange(true, false);
 101            else
 78102                DataStore.i.settings.isInitialized.OnChange += IsSettingsHUDInitialized_OnChange;
 103
 78104            if (configuration.debugRunTutorial)
 105            {
 0106                SetTutorialEnabled(JsonUtility.ToJson(new TutorialInitializationMessage
 107                {
 108                    fromDeepLink = configuration.debugOpenedFromDeepLink.ToString(),
 109                    enableNewTutorialCamera = false.ToString()
 110                }));
 111            }
 78112        }
 113
 114        public void Dispose()
 115        {
 39116            SetTutorialDisabled();
 117
 39118            DataStore.i.settings.isInitialized.OnChange -= IsSettingsHUDInitialized_OnChange;
 119
 39120            if (hudController != null &&
 121                hudController.settingsPanelHud != null)
 122            {
 0123                hudController.settingsPanelHud.OnRestartTutorial -= OnRestartTutorial;
 124            }
 125
 39126            NotificationsController.disableWelcomeNotification = false;
 127
 39128            if (tutorialView != null)
 39129                GameObject.Destroy(tutorialView.gameObject);
 39130        }
 131
 132        public void SetTutorialEnabled(string json)
 133        {
 0134            TutorialInitializationMessage msg = JsonUtility.FromJson<TutorialInitializationMessage>(json);
 0135            SetupTutorial(msg.fromDeepLink, msg.enableNewTutorialCamera, TutorialType.Initial);
 0136        }
 137
 138        public void SetTutorialEnabledForUsersThatAlreadyDidTheTutorial(string json)
 139        {
 0140            TutorialInitializationMessage msg = JsonUtility.FromJson<TutorialInitializationMessage>(json);
 141
 142            // TODO (Santi): This a TEMPORAL fix. It will be removed when we refactorize the tutorial system in order to
 0143            if (PlayerPrefsUtils.GetInt(PLAYER_PREFS_START_MENU_SHOWED) == 1)
 0144                return;
 145
 0146            SetupTutorial(false.ToString(), msg.enableNewTutorialCamera, TutorialType.Initial, true);
 0147        }
 148
 0149        public void SetBuilderInWorldTutorialEnabled() { SetupTutorial(false.ToString(), false.ToString(), TutorialType.
 150
 151        /// <summary>
 152        /// Enables the tutorial controller and waits for the RenderingState is enabled to start to execute the correspo
 153        /// </summary>
 154        internal void SetupTutorial(string fromDeepLink, string enableNewTutorialCamera, TutorialType tutorialType, bool
 155        {
 1156            if (DataStore.i.common.isTutorialRunning.Get())
 0157                return;
 158
 1159            if (Convert.ToBoolean(enableNewTutorialCamera))
 160            {
 1161                configuration.eagleCamInitPosition = new Vector3(15, 115, -30);
 1162                configuration.eagleCamInitLookAtPoint = new Vector3(16, 105, 6);
 1163                configuration.eagleCamRotationActived = false;
 164            }
 165
 1166            DataStore.i.common.isTutorialRunning.Set(true);
 1167            DataStore.i.virtualAudioMixer.sceneSFXVolume.Set(0f);
 1168            this.userAlreadyDidTheTutorial = userAlreadyDidTheTutorial;
 1169            CommonScriptableObjects.allUIHidden.Set(false);
 1170            CommonScriptableObjects.tutorialActive.Set(true);
 1171            openedFromDeepLink = Convert.ToBoolean(fromDeepLink);
 1172            this.tutorialType = tutorialType;
 173
 1174            hudController?.settingsPanelHud?.SetTutorialButtonEnabled(false);
 1175            hudController?.profileHud?.HideProfileMenu();
 176
 1177            NotificationsController.disableWelcomeNotification = true;
 178
 1179            WebInterface.SetDelightedSurveyEnabled(false);
 180
 1181            if (!CommonScriptableObjects.rendererState.Get())
 1182                CommonScriptableObjects.rendererState.OnChange += OnRenderingStateChanged;
 183            else
 0184                OnRenderingStateChanged(true, false);
 185
 1186            OnTutorialEnabled?.Invoke();
 1187        }
 188
 189        /// <summary>
 190        /// Stop and disables the tutorial controller.
 191        /// </summary>
 192        public void SetTutorialDisabled()
 193        {
 65194            CommonScriptableObjects.featureKeyTriggersBlocked.Set(false);
 195
 65196            if (executeStepsCoroutine != null)
 197            {
 0198                CoroutineStarter.Stop(executeStepsCoroutine);
 0199                executeStepsCoroutine = null;
 200            }
 201
 65202            if (runningStep != null)
 203            {
 1204                UnityEngine.Object.Destroy(runningStep.gameObject);
 1205                runningStep = null;
 206            }
 207
 65208            tutorialReset = false;
 65209            DataStore.i.common.isTutorialRunning.Set(false);
 65210            DataStore.i.virtualAudioMixer.sceneSFXVolume.Set(1f);
 65211            ShowTeacher3DModel(false);
 65212            WebInterface.SetDelightedSurveyEnabled(true);
 213
 65214            if (Environment.i != null && Environment.i.world != null)
 215            {
 65216                WebInterface.SendSceneExternalActionEvent(Environment.i.world.state.currentSceneId, "tutorial", "end");
 217            }
 218
 65219            NotificationsController.disableWelcomeNotification = false;
 220
 65221            hudController?.settingsPanelHud?.SetTutorialButtonEnabled(true);
 222
 65223            CommonScriptableObjects.tutorialActive.Set(false);
 224
 65225            CommonScriptableObjects.rendererState.OnChange -= OnRenderingStateChanged;
 226
 65227            OnTutorialDisabled?.Invoke();
 2228        }
 229
 230        /// <summary>
 231        /// Starts to execute the tutorial from a specific step (It is needed to call SetTutorialEnabled() before).
 232        /// </summary>
 233        /// <param name="stepIndex">First step to be executed.</param>
 234        public IEnumerator StartTutorialFromStep(int stepIndex)
 235        {
 27236            if (!DataStore.i.common.isTutorialRunning.Get())
 2237                yield break;
 238
 25239            if (runningStep != null)
 240            {
 10241                runningStep.OnStepFinished();
 10242                GameObject.Destroy(runningStep.gameObject);
 10243                runningStep = null;
 244            }
 245
 25246            switch (tutorialType)
 247            {
 248                case TutorialType.Initial:
 23249                    if (userAlreadyDidTheTutorial)
 250                    {
 2251                        yield return ExecuteSteps(TutorialPath.FromUserThatAlreadyDidTheTutorial, stepIndex);
 2252                    }
 21253                    else if (playerIsInGenesisPlaza || tutorialReset)
 254                    {
 19255                        if (tutorialReset)
 256                        {
 2257                            yield return ExecuteSteps(TutorialPath.FromResetTutorial, stepIndex);
 2258                        }
 259                        else
 260                        {
 17261                            yield return ExecuteSteps(TutorialPath.FromGenesisPlaza, stepIndex);
 262                        }
 17263                    }
 2264                    else if (openedFromDeepLink)
 265                    {
 2266                        yield return ExecuteSteps(TutorialPath.FromDeepLink, stepIndex);
 2267                    }
 268                    else
 269                    {
 0270                        SetTutorialDisabled();
 0271                        yield break;
 272                    }
 273
 274                    break;
 275                case TutorialType.BuilderInWorld:
 2276                    yield return ExecuteSteps(TutorialPath.FromBuilderInWorld, stepIndex);
 277                    break;
 278            }
 25279        }
 280
 281        /// <summary>
 282        /// Shows the teacher that will be guiding along the tutorial.
 283        /// </summary>
 284        /// <param name="active">True for show the teacher.</param>
 285        public void ShowTeacher3DModel(bool active)
 286        {
 160287            if (configuration.teacherCamera != null)
 160288                configuration.teacherCamera.enabled = active;
 289
 160290            if (configuration.teacherRawImage != null)
 115291                configuration.teacherRawImage.gameObject.SetActive(active);
 160292        }
 293
 294        /// <summary>
 295        /// Move the tutorial teacher to a specific position.
 296        /// </summary>
 297        /// <param name="position">Target position.</param>
 298        /// <param name="animated">True for apply a smooth movement.</param>
 299        public void SetTeacherPosition(Vector2 position, bool animated = true)
 300        {
 22301            if (teacherMovementCoroutine != null)
 0302                CoroutineStarter.Stop(teacherMovementCoroutine);
 303
 22304            if (configuration.teacherRawImage != null)
 305            {
 2306                if (animated)
 0307                    teacherMovementCoroutine = CoroutineStarter.Start(MoveTeacher(configuration.teacherRawImage.rectTran
 308                else
 2309                    configuration.teacherRawImage.rectTransform.position = position;
 310            }
 22311        }
 312
 313        /// <summary>
 314        /// Plays a specific animation on the tutorial teacher.
 315        /// </summary>
 316        /// <param name="animation">Animation to apply.</param>
 317        public void PlayTeacherAnimation(TutorialTeacher.TeacherAnimation animation)
 318        {
 44319            if (configuration.teacher == null)
 17320                return;
 321
 27322            configuration.teacher.PlayAnimation(animation);
 27323        }
 324
 325        /// <summary>
 326        /// Set sort order for canvas containing teacher RawImage
 327        /// </summary>
 328        /// <param name="sortOrder"></param>
 329        public void SetTeacherCanvasSortingOrder(int sortOrder)
 330        {
 14331            if (configuration.teacherCanvas == null)
 0332                return;
 333
 14334            configuration.teacherCanvas.sortingOrder = sortOrder;
 14335        }
 336
 337        /// <summary>
 338        /// Finishes the current running step, skips all the next ones and completes the tutorial.
 339        /// </summary>
 340        public void SkipTutorial(bool ignoreStatsSending = false)
 341        {
 5342            if (!ignoreStatsSending && !configuration.debugRunTutorial && configuration.sendStats)
 343            {
 0344                SendSkipTutorialSegmentStats(
 345                    configuration.tutorialVersion,
 346                    runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""));
 347            }
 348
 5349            int skipIndex = configuration.stepsOnGenesisPlaza.Count +
 350                            configuration.stepsFromDeepLink.Count +
 351                            configuration.stepsFromReset.Count +
 352                            configuration.stepsFromBuilderInWorld.Count +
 353                            configuration.stepsFromUserThatAlreadyDidTheTutorial.Count;
 354
 5355            CoroutineStarter.Start(StartTutorialFromStep(skipIndex));
 356
 5357            hudController?.taskbarHud?.SetVisibility(true);
 0358        }
 359
 360        /// <summary>
 361        /// Jump to a specific step.
 362        /// </summary>
 363        /// <param name="stepIndex">Step to jump.</param>
 364        public void GoToSpecificStep(string stepName)
 365        {
 0366            int stepIndex = 0;
 0367            switch (tutorialType)
 368            {
 369                case TutorialType.Initial:
 0370                    if (userAlreadyDidTheTutorial)
 371                    {
 0372                        stepIndex = configuration.stepsFromUserThatAlreadyDidTheTutorial.FindIndex(x => x.name == stepNa
 0373                    }
 0374                    else if (playerIsInGenesisPlaza || tutorialReset)
 375                    {
 0376                        if (tutorialReset)
 377                        {
 0378                            stepIndex = configuration.stepsFromReset.FindIndex(x => x.name == stepName);
 0379                        }
 380                        else
 381                        {
 0382                            stepIndex = configuration.stepsOnGenesisPlaza.FindIndex(x => x.name == stepName);
 383                        }
 0384                    }
 0385                    else if (openedFromDeepLink)
 386                    {
 0387                        stepIndex = configuration.stepsFromDeepLink.FindIndex(x => x.name == stepName);
 388                    }
 0389                    break;
 390                case TutorialType.BuilderInWorld:
 0391                    stepIndex = configuration.stepsFromBuilderInWorld.FindIndex(x => x.name == stepName);
 392                    break;
 393            }
 394
 0395            nextStepsToSkip = 0;
 396
 0397            if (stepIndex >= 0)
 0398                CoroutineStarter.Start(StartTutorialFromStep(stepIndex));
 399            else
 0400                SkipTutorial(true);
 0401        }
 402
 403        /// <summary>
 404        /// Set the number of steps that will be skipped in the next iteration.
 405        /// </summary>
 406        /// <param name="skippedSteps">Number of steps to skip.</param>
 0407        public void SetNextSkippedSteps(int skippedSteps) { nextStepsToSkip = skippedSteps; }
 408
 409        /// <summary>
 410        /// Activate/deactivate the eagle eye camera.
 411        /// </summary>
 412        /// <param name="isActive">True for activate the eagle eye camera.</param>
 413        public void SetEagleEyeCameraActive(bool isActive)
 414        {
 6415            configuration.eagleEyeCamera.gameObject.SetActive(isActive);
 6416            CoroutineStarter.Start(BlockPlayerCameraUntilBlendingIsFinished(isActive));
 417
 6418            if (isActive)
 419            {
 3420                configuration.eagleEyeCamera.transform.position = configuration.eagleCamInitPosition;
 3421                configuration.eagleEyeCamera.transform.LookAt(configuration.eagleCamInitLookAtPoint);
 422
 3423                if (configuration.eagleCamRotationActived)
 2424                    eagleEyeRotationCoroutine = CoroutineStarter.Start(EagleEyeCameraRotation(configuration.eagleCamRota
 2425            }
 3426            else if (eagleEyeRotationCoroutine != null)
 427            {
 2428                CoroutineStarter.Stop(eagleEyeRotationCoroutine);
 429            }
 4430        }
 431
 432        internal void OnRenderingStateChanged(bool renderingEnabled, bool prevState)
 433        {
 2434            if (!renderingEnabled)
 0435                return;
 436
 2437            CommonScriptableObjects.rendererState.OnChange -= OnRenderingStateChanged;
 438
 2439            playerIsInGenesisPlaza = IsPlayerInsideGenesisPlaza();
 440
 2441            if (configuration.debugRunTutorial)
 1442                currentStepIndex = configuration.debugStartingStepIndex >= 0 ? configuration.debugStartingStepIndex : 0;
 443            else
 1444                currentStepIndex = 0;
 445
 2446            PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.Reset);
 2447            executeStepsCoroutine = CoroutineStarter.Start(StartTutorialFromStep(currentStepIndex));
 2448        }
 449
 450        private IEnumerator ExecuteSteps(TutorialPath tutorialPath, int startingStepIndex)
 451        {
 25452            List<TutorialStep> steps = new List<TutorialStep>();
 453
 454            switch (tutorialPath)
 455            {
 456                case TutorialPath.FromGenesisPlaza:
 17457                    steps = configuration.stepsOnGenesisPlaza;
 17458                    break;
 459                case TutorialPath.FromDeepLink:
 2460                    steps = configuration.stepsFromDeepLink;
 2461                    break;
 462                case TutorialPath.FromResetTutorial:
 2463                    steps = configuration.stepsFromReset;
 2464                    break;
 465                case TutorialPath.FromBuilderInWorld:
 2466                    steps = configuration.stepsFromBuilderInWorld;
 2467                    break;
 468                case TutorialPath.FromUserThatAlreadyDidTheTutorial:
 2469                    steps = configuration.stepsFromUserThatAlreadyDidTheTutorial;
 470                    break;
 471            }
 472
 25473            currentPath = tutorialPath;
 474
 25475            elapsedTimeInCurrentStep = 0f;
 130476            for (int i = startingStepIndex; i < steps.Count; i++)
 477            {
 40478                if (nextStepsToSkip > 0)
 479                {
 0480                    nextStepsToSkip--;
 0481                    continue;
 482                }
 483
 40484                var stepPrefab = steps[i];
 485
 486                // TODO (Santi): This a TEMPORAL fix. It will be removed when we refactorize the tutorial system in orde
 40487                if (stepPrefab is TutorialStep_Tooltip_ExploreButton &&
 488                    !DataStore.i.exploreV2.isInitialized.Get())
 489                    continue;
 490
 40491                if (stepPrefab.letInstantiation)
 15492                    runningStep = GameObject.Instantiate(stepPrefab, tutorialView.transform).GetComponent<TutorialStep>(
 493                else
 25494                    runningStep = steps[i];
 495
 40496                runningStep.gameObject.name = runningStep.gameObject.name.Replace("(Clone)", "");
 40497                currentStepIndex = i;
 498
 40499                elapsedTimeInCurrentStep = Time.realtimeSinceStartup;
 40500                currentStepNumber = i + 1;
 501
 40502                if (!configuration.debugRunTutorial && configuration.sendStats)
 503                {
 0504                    SendStepStartedSegmentStats(
 505                        configuration.tutorialVersion,
 506                        tutorialPath,
 507                        i + 1,
 508                        runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""));
 509                }
 510
 40511                runningStep.OnStepStart();
 40512                yield return runningStep.OnStepExecute();
 40513                if (i < steps.Count - 1)
 20514                    PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.StepCompleted);
 515                else
 20516                    PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.QuickGoodbye);
 517
 40518                yield return runningStep.OnStepPlayHideAnimation();
 40519                runningStep.OnStepFinished();
 40520                elapsedTimeInCurrentStep = Time.realtimeSinceStartup - elapsedTimeInCurrentStep;
 521
 40522                if (!configuration.debugRunTutorial &&
 523                    configuration.sendStats &&
 524                    tutorialPath != TutorialPath.FromUserThatAlreadyDidTheTutorial)
 525                {
 0526                    SendStepCompletedSegmentStats(
 527                        configuration.tutorialVersion,
 528                        tutorialPath,
 529                        i + 1,
 530                        runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""),
 531                        elapsedTimeInCurrentStep);
 532                }
 533
 40534                GameObject.Destroy(runningStep.gameObject);
 535
 40536                if (i < steps.Count - 1 && configuration.timeBetweenSteps > 0)
 0537                    yield return new WaitForSeconds(configuration.timeBetweenSteps);
 538            }
 539
 25540            if (!configuration.debugRunTutorial &&
 541                tutorialPath != TutorialPath.FromBuilderInWorld &&
 542                tutorialPath != TutorialPath.FromUserThatAlreadyDidTheTutorial)
 543            {
 21544                SetUserTutorialStepAsCompleted(TutorialFinishStep.NewTutorialFinished);
 545            }
 546
 25547            runningStep = null;
 548
 25549            SetTutorialDisabled();
 25550        }
 551
 42552        private void SetUserTutorialStepAsCompleted(TutorialFinishStep finishStepType) { WebInterface.SaveUserTutorialSt
 553
 554        internal IEnumerator MoveTeacher(Vector2 fromPosition, Vector2 toPosition)
 555        {
 1556            if (configuration.teacherRawImage == null)
 0557                yield break;
 558
 1559            float t = 0f;
 560
 2561            while (Vector2.Distance(configuration.teacherRawImage.rectTransform.position, toPosition) > 0)
 562            {
 2563                t += configuration.teacherMovementSpeed * Time.deltaTime;
 2564                if (t <= 1.0f)
 2565                    configuration.teacherRawImage.rectTransform.position = Vector2.Lerp(fromPosition, toPosition, config
 566                else
 0567                    configuration.teacherRawImage.rectTransform.position = toPosition;
 568
 2569                yield return null;
 570            }
 0571        }
 572
 573        private void IsSettingsHUDInitialized_OnChange(bool current, bool previous)
 574        {
 0575            if (current &&
 576                hudController != null &&
 577                hudController.settingsPanelHud != null)
 578            {
 0579                hudController.settingsPanelHud.OnRestartTutorial -= OnRestartTutorial;
 0580                hudController.settingsPanelHud.OnRestartTutorial += OnRestartTutorial;
 581            }
 0582        }
 583
 584        internal void OnRestartTutorial()
 585        {
 0586            SetTutorialDisabled();
 0587            tutorialReset = true;
 0588            SetTutorialEnabled(JsonUtility.ToJson(new TutorialInitializationMessage
 589            {
 590                fromDeepLink = false.ToString(),
 591                enableNewTutorialCamera = false.ToString()
 592            }));
 0593        }
 594
 595        internal static bool IsPlayerInsideGenesisPlaza()
 596        {
 2597            if (Environment.i.world == null)
 0598                return false;
 599
 2600            IWorldState worldState = Environment.i.world.state;
 601
 2602            if (worldState == null || worldState.currentSceneId == null)
 0603                return false;
 604
 2605            Vector2Int genesisPlazaBaseCoords = new Vector2Int(-9, -9);
 606
 2607            IParcelScene currentScene = null;
 2608            if (worldState.loadedScenes != null)
 0609                currentScene = worldState.loadedScenes[worldState.currentSceneId];
 610
 2611            if (currentScene != null && currentScene.IsInsideSceneBoundaries(genesisPlazaBaseCoords))
 0612                return true;
 613
 2614            return false;
 615        }
 616
 617        private void SendStepStartedSegmentStats(int version, TutorialPath tutorialPath, int stepNumber, string stepName
 618        {
 0619            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 620            {
 621                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 622                new WebInterface.AnalyticsPayload.Property("path", tutorialPath.ToString()),
 623                new WebInterface.AnalyticsPayload.Property("step number", stepNumber.ToString()),
 624                new WebInterface.AnalyticsPayload.Property("step name", stepName)
 625            };
 0626            WebInterface.ReportAnalyticsEvent("tutorial step started", properties);
 0627        }
 628
 629        private void SendStepCompletedSegmentStats(int version, TutorialPath tutorialPath, int stepNumber, string stepNa
 630        {
 0631            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 632            {
 633                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 634                new WebInterface.AnalyticsPayload.Property("path", tutorialPath.ToString()),
 635                new WebInterface.AnalyticsPayload.Property("step number", stepNumber.ToString()),
 636                new WebInterface.AnalyticsPayload.Property("step name", stepName),
 637                new WebInterface.AnalyticsPayload.Property("elapsed time", elapsedTime.ToString("0.00"))
 638            };
 0639            WebInterface.ReportAnalyticsEvent("tutorial step completed", properties);
 0640        }
 641
 642        private void SendSkipTutorialSegmentStats(int version, string stepName)
 643        {
 0644            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 645            {
 646                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 647                new WebInterface.AnalyticsPayload.Property("path", currentPath.ToString()),
 648                new WebInterface.AnalyticsPayload.Property("step number", currentStepNumber.ToString()),
 649                new WebInterface.AnalyticsPayload.Property("step name", stepName),
 650                new WebInterface.AnalyticsPayload.Property("elapsed time", (Time.realtimeSinceStartup - elapsedTimeInCur
 651            };
 0652            WebInterface.ReportAnalyticsEvent("tutorial skipped", properties);
 0653        }
 654
 655        internal IEnumerator EagleEyeCameraRotation(float rotationSpeed)
 656        {
 4657            while (true)
 658            {
 6659                configuration.eagleEyeCamera.transform.Rotate(Vector3.up * Time.deltaTime * rotationSpeed, Space.World);
 6660                yield return null;
 661            }
 662        }
 663
 664        private IEnumerator BlockPlayerCameraUntilBlendingIsFinished(bool hideUIs)
 665        {
 6666            if (hideUIs)
 667            {
 3668                hudController?.minimapHud?.SetVisibility(false);
 3669                hudController?.profileHud?.SetVisibility(false);
 670            }
 671
 6672            CommonScriptableObjects.cameraBlocked.Set(true);
 673
 6674            yield return null;
 12675            yield return new WaitUntil(() => !CommonScriptableObjects.cameraIsBlending.Get());
 676
 6677            CommonScriptableObjects.cameraBlocked.Set(false);
 678
 6679            if (!hideUIs)
 680            {
 3681                hudController?.minimapHud?.SetVisibility(true);
 3682                hudController?.profileHud?.SetVisibility(true);
 683            }
 6684        }
 685    }
 686}

Methods/Properties

i()
i(DCL.Tutorial.TutorialController)
hudController()
currentStepIndex()
currentStepIndex(System.Int32)
userAlreadyDidTheTutorial()
userAlreadyDidTheTutorial(System.Boolean)
TutorialController()
CreateTutorialView()
SetConfiguration(DCL.Tutorial.TutorialSettings)
Dispose()
SetTutorialEnabled(System.String)
SetTutorialEnabledForUsersThatAlreadyDidTheTutorial(System.String)
SetBuilderInWorldTutorialEnabled()
SetupTutorial(System.String, System.String, DCL.Tutorial.TutorialController/TutorialType, System.Boolean)
SetTutorialDisabled()
StartTutorialFromStep()
ShowTeacher3DModel(System.Boolean)
SetTeacherPosition(UnityEngine.Vector2, System.Boolean)
PlayTeacherAnimation(DCL.Tutorial.TutorialTeacher/TeacherAnimation)
SetTeacherCanvasSortingOrder(System.Int32)
SkipTutorial(System.Boolean)
GoToSpecificStep(System.String)
SetNextSkippedSteps(System.Int32)
SetEagleEyeCameraActive(System.Boolean)
OnRenderingStateChanged(System.Boolean, System.Boolean)
ExecuteSteps()
SetUserTutorialStepAsCompleted(DCL.Tutorial.TutorialController/TutorialFinishStep)
MoveTeacher()
IsSettingsHUDInitialized_OnChange(System.Boolean, System.Boolean)
OnRestartTutorial()
IsPlayerInsideGenesisPlaza()
SendStepStartedSegmentStats(System.Int32, DCL.Tutorial.TutorialController/TutorialPath, System.Int32, System.String)
SendStepCompletedSegmentStats(System.Int32, DCL.Tutorial.TutorialController/TutorialPath, System.Int32, System.String, System.Single)
SendSkipTutorialSegmentStats(System.Int32, System.String)
EagleEyeCameraRotation()
BlockPlayerCameraUntilBlendingIsFinished()