< Summary

Class:DCL.Tutorial.TutorialController
Assembly:Onboarding
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/TutorialController.cs
Covered lines:1
Uncovered lines:277
Coverable lines:278
Total lines:699
Line coverage:0.3% (1 of 278)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TutorialController()0%2100%
CreateTutorialView()0%2100%
SetConfiguration(...)0%12300%
Dispose()0%20400%
SetTutorialEnabled(...)0%2100%
SetTutorialEnabledForUsersThatAlreadyDidTheTutorial(...)0%6200%
SetBuilderInWorldTutorialEnabled()0%2100%
SetupTutorial(...)0%90900%
SetTutorialDisabled()0%90900%
StartTutorialFromStep()0%3061700%
ShowTeacher3DModel(...)0%12300%
SetTeacherPosition(...)0%20400%
PlayTeacherAnimation(...)0%6200%
SetTeacherCanvasSortingOrder(...)0%6200%
SkipTutorial(...)0%42600%
GoToSpecificStep(...)0%90900%
SetNextSkippedSteps(...)0%2100%
SetEagleEyeCameraActive(...)0%20400%
OnRenderingStateChanged(...)0%30500%
ExecuteSteps()0%7022600%
SetUserTutorialStepAsCompleted(...)0%2100%
MoveTeacher()0%42600%
IsSettingsHUDInitialized_OnChange(...)0%20400%
OnRestartTutorial()0%2100%
IsPlayerInScene()0%12300%
IsPlayerInsideGenesisPlaza()0%42600%
SendStepStartedSegmentStats(...)0%2100%
SendStepCompletedSegmentStats(...)0%2100%
SendSkipTutorialSegmentStats(...)0%2100%
EagleEyeCameraRotation()0%12300%
BlockPlayerCameraUntilBlendingIsFinished()0%2401500%

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
 076        public TutorialController ()
 77        {
 078            tutorialView = CreateTutorialView();
 079            SetConfiguration(tutorialView.configuration);
 080        }
 81
 82        internal TutorialView CreateTutorialView()
 83        {
 084            GameObject tutorialGO = GameObject.Instantiate(Resources.Load<GameObject>("TutorialView"));
 085            tutorialGO.name = "TutorialController";
 086            TutorialView tutorialView = tutorialGO.GetComponent<TutorialView>();
 087            tutorialView.ConfigureView(this);
 88
 089            return tutorialView;
 90        }
 91
 92        public void SetConfiguration(TutorialSettings configuration)
 93        {
 094            this.configuration = configuration;
 95
 096            i = this;
 097            ShowTeacher3DModel(false);
 98
 099            if (DataStore.i.settings.isInitialized.Get())
 0100                IsSettingsHUDInitialized_OnChange(true, false);
 101            else
 0102                DataStore.i.settings.isInitialized.OnChange += IsSettingsHUDInitialized_OnChange;
 103
 0104            if (configuration.debugRunTutorial)
 105            {
 0106                SetTutorialEnabled(JsonUtility.ToJson(new TutorialInitializationMessage
 107                {
 108                    fromDeepLink = configuration.debugOpenedFromDeepLink.ToString(),
 109                    enableNewTutorialCamera = false.ToString()
 110                }));
 111            }
 0112        }
 113
 114        public void Dispose()
 115        {
 0116            SetTutorialDisabled();
 117
 0118            DataStore.i.settings.isInitialized.OnChange -= IsSettingsHUDInitialized_OnChange;
 119
 0120            if (hudController != null &&
 121                hudController.settingsPanelHud != null)
 122            {
 0123                hudController.settingsPanelHud.OnRestartTutorial -= OnRestartTutorial;
 124            }
 125
 0126            NotificationsController.disableWelcomeNotification = false;
 127
 0128            if (tutorialView != null)
 0129                GameObject.Destroy(tutorialView.gameObject);
 0130        }
 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        {
 0156            if (DataStore.i.common.isTutorialRunning.Get())
 0157                return;
 158
 0159            if (Convert.ToBoolean(enableNewTutorialCamera))
 160            {
 0161                configuration.eagleCamInitPosition = new Vector3(15, 115, -30);
 0162                configuration.eagleCamInitLookAtPoint = new Vector3(16, 105, 6);
 0163                configuration.eagleCamRotationActived = false;
 164            }
 165
 0166            DataStore.i.common.isTutorialRunning.Set(true);
 0167            this.userAlreadyDidTheTutorial = userAlreadyDidTheTutorial;
 0168            CommonScriptableObjects.allUIHidden.Set(false);
 0169            CommonScriptableObjects.tutorialActive.Set(true);
 0170            openedFromDeepLink = Convert.ToBoolean(fromDeepLink);
 0171            this.tutorialType = tutorialType;
 172
 0173            hudController?.settingsPanelHud?.SetTutorialButtonEnabled(false);
 0174            hudController?.profileHud?.HideProfileMenu();
 175
 0176            NotificationsController.disableWelcomeNotification = true;
 177
 0178            WebInterface.SetDelightedSurveyEnabled(false);
 179
 0180            if (!CommonScriptableObjects.rendererState.Get())
 0181                CommonScriptableObjects.rendererState.OnChange += OnRenderingStateChanged;
 182            else
 0183                OnRenderingStateChanged(true, false);
 184
 0185            OnTutorialEnabled?.Invoke();
 0186        }
 187
 188        /// <summary>
 189        /// Stop and disables the tutorial controller.
 190        /// </summary>
 191        public void SetTutorialDisabled()
 192        {
 0193            CommonScriptableObjects.featureKeyTriggersBlocked.Set(false);
 194
 0195            if (executeStepsCoroutine != null)
 196            {
 0197                CoroutineStarter.Stop(executeStepsCoroutine);
 0198                executeStepsCoroutine = null;
 199            }
 200
 0201            if (runningStep != null)
 202            {
 0203                UnityEngine.Object.Destroy(runningStep.gameObject);
 0204                runningStep = null;
 205            }
 206
 0207            if (teacherMovementCoroutine != null)
 208            {
 0209                CoroutineStarter.Stop(teacherMovementCoroutine);
 0210                teacherMovementCoroutine = null;
 211            }
 212
 0213            tutorialReset = false;
 0214            DataStore.i.common.isTutorialRunning.Set(false);
 0215            tutorialView.tutorialMusicHandler.StopTutorialMusic();
 0216            ShowTeacher3DModel(false);
 0217            WebInterface.SetDelightedSurveyEnabled(true);
 218
 0219            if (Environment.i != null && Environment.i.world != null)
 220            {
 0221                WebInterface.SendSceneExternalActionEvent(Environment.i.world.state.GetCurrentSceneId(), "tutorial", "en
 222            }
 223
 0224            NotificationsController.disableWelcomeNotification = false;
 225
 0226            hudController?.settingsPanelHud?.SetTutorialButtonEnabled(true);
 227
 0228            CommonScriptableObjects.tutorialActive.Set(false);
 229
 0230            CommonScriptableObjects.rendererState.OnChange -= OnRenderingStateChanged;
 231
 0232            OnTutorialDisabled?.Invoke();
 0233        }
 234
 235        /// <summary>
 236        /// Starts to execute the tutorial from a specific step (It is needed to call SetTutorialEnabled() before).
 237        /// </summary>
 238        /// <param name="stepIndex">First step to be executed.</param>
 239        public IEnumerator StartTutorialFromStep(int stepIndex)
 240        {
 0241            if (!DataStore.i.common.isTutorialRunning.Get())
 0242                yield break;
 243
 0244            if (runningStep != null)
 245            {
 0246                runningStep.OnStepFinished();
 0247                GameObject.Destroy(runningStep.gameObject);
 0248                runningStep = null;
 249            }
 250
 0251            yield return new WaitUntil(IsPlayerInScene);
 252
 0253            playerIsInGenesisPlaza = IsPlayerInsideGenesisPlaza();
 254
 0255            switch (tutorialType)
 256            {
 257                case TutorialType.Initial:
 0258                    if(playerIsInGenesisPlaza) tutorialView.tutorialMusicHandler.TryPlayingMusic();
 0259                    if (userAlreadyDidTheTutorial)
 260                    {
 0261                        yield return ExecuteSteps(TutorialPath.FromUserThatAlreadyDidTheTutorial, stepIndex);
 0262                    }
 0263                    else if (tutorialReset)
 264                    {
 0265                        yield return ExecuteSteps(TutorialPath.FromResetTutorial, stepIndex);
 0266                    }
 0267                    else if (playerIsInGenesisPlaza)
 268                    {
 0269                        yield return ExecuteSteps(TutorialPath.FromGenesisPlaza, stepIndex);
 0270                    }
 0271                    else if (openedFromDeepLink)
 272                    {
 0273                        yield return ExecuteSteps(TutorialPath.FromDeepLink, stepIndex);
 0274                    }
 275                    else
 276                    {
 0277                        SetTutorialDisabled();
 0278                        yield break;
 279                    }
 280                    break;
 281                case TutorialType.BuilderInWorld:
 0282                    yield return ExecuteSteps(TutorialPath.FromBuilderInWorld, stepIndex);
 283                    break;
 284            }
 0285        }
 286
 287        /// <summary>
 288        /// Shows the teacher that will be guiding along the tutorial.
 289        /// </summary>
 290        /// <param name="active">True for show the teacher.</param>
 291        public void ShowTeacher3DModel(bool active)
 292        {
 0293            if (configuration.teacherCamera != null)
 0294                configuration.teacherCamera.enabled = active;
 295
 0296            if (configuration.teacherRawImage != null)
 0297                configuration.teacherRawImage.gameObject.SetActive(active);
 0298        }
 299
 300        /// <summary>
 301        /// Move the tutorial teacher to a specific position.
 302        /// </summary>
 303        /// <param name="destinationPosition">Target position.</param>
 304        /// <param name="animated">True for apply a smooth movement.</param>
 305        public void SetTeacherPosition(Vector3 destinationPosition, bool animated = true)
 306        {
 0307            if (teacherMovementCoroutine != null)
 0308                CoroutineStarter.Stop(teacherMovementCoroutine);
 309
 0310            if (configuration.teacherRawImage != null)
 311            {
 0312                if (animated)
 0313                    teacherMovementCoroutine = CoroutineStarter.Start(MoveTeacher(destinationPosition));
 314                else
 0315                    configuration.teacherRawImage.rectTransform.position = new Vector3(destinationPosition.x, destinatio
 316            }
 0317        }
 318
 319        /// <summary>
 320        /// Plays a specific animation on the tutorial teacher.
 321        /// </summary>
 322        /// <param name="animation">Animation to apply.</param>
 323        public void PlayTeacherAnimation(TutorialTeacher.TeacherAnimation animation)
 324        {
 0325            if (configuration.teacher == null)
 0326                return;
 327
 0328            configuration.teacher.PlayAnimation(animation);
 0329        }
 330
 331        /// <summary>
 332        /// Set sort order for canvas containing teacher RawImage
 333        /// </summary>
 334        /// <param name="sortOrder"></param>
 335        public void SetTeacherCanvasSortingOrder(int sortOrder)
 336        {
 0337            if (configuration.teacherCanvas == null)
 0338                return;
 339
 0340            configuration.teacherCanvas.sortingOrder = sortOrder;
 0341        }
 342
 343        /// <summary>
 344        /// Finishes the current running step, skips all the next ones and completes the tutorial.
 345        /// </summary>
 346        public void SkipTutorial(bool ignoreStatsSending = false)
 347        {
 0348            if (!ignoreStatsSending && !configuration.debugRunTutorial && configuration.sendStats)
 349            {
 0350                SendSkipTutorialSegmentStats(
 351                    configuration.tutorialVersion,
 352                    runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""));
 353            }
 354
 0355            int skipIndex = configuration.stepsOnGenesisPlaza.Count +
 356                            configuration.stepsFromDeepLink.Count +
 357                            configuration.stepsFromReset.Count +
 358                            configuration.stepsFromBuilderInWorld.Count +
 359                            configuration.stepsFromUserThatAlreadyDidTheTutorial.Count;
 360
 0361            CoroutineStarter.Start(StartTutorialFromStep(skipIndex));
 362
 0363            hudController?.taskbarHud?.SetVisibility(true);
 0364        }
 365
 366        /// <summary>
 367        /// Jump to a specific step.
 368        /// </summary>
 369        /// <param name="stepIndex">Step to jump.</param>
 370        public void GoToSpecificStep(string stepName)
 371        {
 0372            int stepIndex = 0;
 0373            switch (tutorialType)
 374            {
 375                case TutorialType.Initial:
 0376                    if (userAlreadyDidTheTutorial)
 377                    {
 0378                        stepIndex = configuration.stepsFromUserThatAlreadyDidTheTutorial.FindIndex(x => x.name == stepNa
 0379                    }
 0380                    else if (playerIsInGenesisPlaza || tutorialReset)
 381                    {
 0382                        if (tutorialReset)
 383                        {
 0384                            stepIndex = configuration.stepsFromReset.FindIndex(x => x.name == stepName);
 0385                        }
 386                        else
 387                        {
 0388                            stepIndex = configuration.stepsOnGenesisPlaza.FindIndex(x => x.name == stepName);
 389                        }
 0390                    }
 0391                    else if (openedFromDeepLink)
 392                    {
 0393                        stepIndex = configuration.stepsFromDeepLink.FindIndex(x => x.name == stepName);
 394                    }
 0395                    break;
 396                case TutorialType.BuilderInWorld:
 0397                    stepIndex = configuration.stepsFromBuilderInWorld.FindIndex(x => x.name == stepName);
 398                    break;
 399            }
 400
 0401            nextStepsToSkip = 0;
 402
 0403            if (stepIndex >= 0)
 0404                CoroutineStarter.Start(StartTutorialFromStep(stepIndex));
 405            else
 0406                SkipTutorial(true);
 0407        }
 408
 409        /// <summary>
 410        /// Set the number of steps that will be skipped in the next iteration.
 411        /// </summary>
 412        /// <param name="skippedSteps">Number of steps to skip.</param>
 0413        public void SetNextSkippedSteps(int skippedSteps) { nextStepsToSkip = skippedSteps; }
 414
 415        /// <summary>
 416        /// Activate/deactivate the eagle eye camera.
 417        /// </summary>
 418        /// <param name="isActive">True for activate the eagle eye camera.</param>
 419        public void SetEagleEyeCameraActive(bool isActive)
 420        {
 0421            configuration.eagleEyeCamera.gameObject.SetActive(isActive);
 0422            CoroutineStarter.Start(BlockPlayerCameraUntilBlendingIsFinished(isActive));
 423
 0424            if (isActive)
 425            {
 0426                configuration.eagleEyeCamera.transform.position = configuration.eagleCamInitPosition;
 0427                configuration.eagleEyeCamera.transform.LookAt(configuration.eagleCamInitLookAtPoint);
 428
 0429                if (configuration.eagleCamRotationActived)
 0430                    eagleEyeRotationCoroutine = CoroutineStarter.Start(EagleEyeCameraRotation(configuration.eagleCamRota
 0431            }
 0432            else if (eagleEyeRotationCoroutine != null)
 433            {
 0434                CoroutineStarter.Stop(eagleEyeRotationCoroutine);
 435            }
 0436        }
 437
 438        internal void OnRenderingStateChanged(bool renderingEnabled, bool prevState)
 439        {
 0440            if (!renderingEnabled)
 0441                return;
 442
 0443            CommonScriptableObjects.rendererState.OnChange -= OnRenderingStateChanged;
 444
 0445            if (configuration.debugRunTutorial)
 0446                currentStepIndex = configuration.debugStartingStepIndex >= 0 ? configuration.debugStartingStepIndex : 0;
 447            else
 0448                currentStepIndex = 0;
 449
 0450            PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.Reset);
 0451            executeStepsCoroutine = CoroutineStarter.Start(StartTutorialFromStep(currentStepIndex));
 0452        }
 453
 454        private IEnumerator ExecuteSteps(TutorialPath tutorialPath, int startingStepIndex)
 455        {
 0456            List<TutorialStep> steps = new List<TutorialStep>();
 457
 458            switch (tutorialPath)
 459            {
 460                case TutorialPath.FromGenesisPlaza:
 0461                    steps = configuration.stepsOnGenesisPlaza;
 0462                    break;
 463                case TutorialPath.FromDeepLink:
 0464                    steps = configuration.stepsFromDeepLink;
 0465                    break;
 466                case TutorialPath.FromResetTutorial:
 0467                    steps = configuration.stepsFromReset;
 0468                    break;
 469                case TutorialPath.FromBuilderInWorld:
 0470                    steps = configuration.stepsFromBuilderInWorld;
 0471                    break;
 472                case TutorialPath.FromUserThatAlreadyDidTheTutorial:
 0473                    steps = configuration.stepsFromUserThatAlreadyDidTheTutorial;
 474                    break;
 475            }
 476
 0477            currentPath = tutorialPath;
 478
 0479            elapsedTimeInCurrentStep = 0f;
 0480            for (int i = startingStepIndex; i < steps.Count; i++)
 481            {
 0482                if (nextStepsToSkip > 0)
 483                {
 0484                    nextStepsToSkip--;
 0485                    continue;
 486                }
 487
 0488                var stepPrefab = steps[i];
 489
 490                // TODO (Santi): This a TEMPORAL fix. It will be removed when we refactorize the tutorial system in orde
 0491                if (stepPrefab is TutorialStep_Tooltip_ExploreButton &&
 492                    !DataStore.i.exploreV2.isInitialized.Get())
 493                    continue;
 494
 0495                if (stepPrefab.letInstantiation)
 0496                    runningStep = GameObject.Instantiate(stepPrefab, tutorialView.transform).GetComponent<TutorialStep>(
 497                else
 0498                    runningStep = steps[i];
 499
 0500                runningStep.gameObject.name = runningStep.gameObject.name.Replace("(Clone)", "");
 0501                currentStepIndex = i;
 502
 0503                elapsedTimeInCurrentStep = Time.realtimeSinceStartup;
 0504                currentStepNumber = i + 1;
 505
 0506                if (!configuration.debugRunTutorial && configuration.sendStats)
 507                {
 0508                    SendStepStartedSegmentStats(
 509                        configuration.tutorialVersion,
 510                        tutorialPath,
 511                        i + 1,
 512                        runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""));
 513                }
 514
 0515                runningStep.OnStepStart();
 0516                yield return runningStep.OnStepExecute();
 0517                if (i < steps.Count - 1)
 0518                    PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.StepCompleted);
 519                else
 0520                    PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.QuickGoodbye);
 521
 0522                yield return runningStep.OnStepPlayHideAnimation();
 0523                runningStep.OnStepFinished();
 0524                elapsedTimeInCurrentStep = Time.realtimeSinceStartup - elapsedTimeInCurrentStep;
 525
 0526                if (!configuration.debugRunTutorial &&
 527                    configuration.sendStats &&
 528                    tutorialPath != TutorialPath.FromUserThatAlreadyDidTheTutorial)
 529                {
 0530                    SendStepCompletedSegmentStats(
 531                        configuration.tutorialVersion,
 532                        tutorialPath,
 533                        i + 1,
 534                        runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""),
 535                        elapsedTimeInCurrentStep);
 536                }
 537
 0538                GameObject.Destroy(runningStep.gameObject);
 539
 0540                if (i < steps.Count - 1 && configuration.timeBetweenSteps > 0)
 0541                    yield return new WaitForSeconds(configuration.timeBetweenSteps);
 542            }
 543
 0544            if (!configuration.debugRunTutorial &&
 545                tutorialPath != TutorialPath.FromBuilderInWorld &&
 546                tutorialPath != TutorialPath.FromUserThatAlreadyDidTheTutorial)
 547            {
 0548                SetUserTutorialStepAsCompleted(TutorialFinishStep.NewTutorialFinished);
 549            }
 550
 0551            runningStep = null;
 552
 0553            SetTutorialDisabled();
 0554        }
 555
 0556        private void SetUserTutorialStepAsCompleted(TutorialFinishStep finishStepType) { WebInterface.SaveUserTutorialSt
 557
 558        internal IEnumerator MoveTeacher(Vector3 toPosition)
 559        {
 0560            if (configuration.teacherRawImage == null)
 0561                yield break;
 562
 0563            float t = 0f;
 564
 0565            Vector3 fromPosition = configuration.teacherRawImage.rectTransform.position;
 566
 0567            while (Vector3.Distance(configuration.teacherRawImage.rectTransform.position, toPosition) > 0)
 568            {
 0569                t += configuration.teacherMovementSpeed * Time.deltaTime;
 0570                if (t <= 1.0f)
 0571                    configuration.teacherRawImage.rectTransform.position = Vector3.Lerp(fromPosition, toPosition, config
 572                else
 0573                    configuration.teacherRawImage.rectTransform.position = toPosition;
 0574                yield return null;
 575            }
 0576        }
 577
 578        private void IsSettingsHUDInitialized_OnChange(bool current, bool previous)
 579        {
 0580            if (current &&
 581                hudController != null &&
 582                hudController.settingsPanelHud != null)
 583            {
 0584                hudController.settingsPanelHud.OnRestartTutorial -= OnRestartTutorial;
 0585                hudController.settingsPanelHud.OnRestartTutorial += OnRestartTutorial;
 586            }
 0587        }
 588
 589        internal void OnRestartTutorial()
 590        {
 0591            SetTutorialDisabled();
 0592            tutorialReset = true;
 0593            SetTutorialEnabled(JsonUtility.ToJson(new TutorialInitializationMessage
 594            {
 595                fromDeepLink = false.ToString(),
 596                enableNewTutorialCamera = false.ToString()
 597            }));
 0598        }
 599
 600        internal bool IsPlayerInScene()
 601        {
 0602            IWorldState worldState = Environment.i.world.state;
 603
 0604            if (worldState == null || worldState.GetCurrentSceneId() == null)
 0605                return false;
 606
 0607            return true;
 608        }
 609
 610        internal static bool IsPlayerInsideGenesisPlaza()
 611        {
 0612            if (Environment.i.world == null)
 0613                return false;
 614
 0615            IWorldState worldState = Environment.i.world.state;
 616
 0617            if (worldState == null || worldState.GetCurrentSceneId() == null)
 0618                return false;
 619
 0620            Vector2Int genesisPlazaBaseCoords = new Vector2Int(-9, -9);
 621
 0622            var currentScene = worldState.GetScene(worldState.GetCurrentSceneId());
 623
 0624            if (currentScene != null && currentScene.IsInsideSceneBoundaries(genesisPlazaBaseCoords))
 0625                return true;
 626
 0627            return false;
 628        }
 629
 630        private void SendStepStartedSegmentStats(int version, TutorialPath tutorialPath, int stepNumber, string stepName
 631        {
 0632            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 633            {
 634                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 635                new WebInterface.AnalyticsPayload.Property("path", tutorialPath.ToString()),
 636                new WebInterface.AnalyticsPayload.Property("step number", stepNumber.ToString()),
 637                new WebInterface.AnalyticsPayload.Property("step name", stepName)
 638            };
 0639            WebInterface.ReportAnalyticsEvent("tutorial step started", properties);
 0640        }
 641
 642        private void SendStepCompletedSegmentStats(int version, TutorialPath tutorialPath, int stepNumber, string stepNa
 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", tutorialPath.ToString()),
 648                new WebInterface.AnalyticsPayload.Property("step number", stepNumber.ToString()),
 649                new WebInterface.AnalyticsPayload.Property("step name", stepName),
 650                new WebInterface.AnalyticsPayload.Property("elapsed time", elapsedTime.ToString("0.00"))
 651            };
 0652            WebInterface.ReportAnalyticsEvent("tutorial step completed", properties);
 0653        }
 654
 655        private void SendSkipTutorialSegmentStats(int version, string stepName)
 656        {
 0657            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 658            {
 659                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 660                new WebInterface.AnalyticsPayload.Property("path", currentPath.ToString()),
 661                new WebInterface.AnalyticsPayload.Property("step number", currentStepNumber.ToString()),
 662                new WebInterface.AnalyticsPayload.Property("step name", stepName),
 663                new WebInterface.AnalyticsPayload.Property("elapsed time", (Time.realtimeSinceStartup - elapsedTimeInCur
 664            };
 0665            WebInterface.ReportAnalyticsEvent("tutorial skipped", properties);
 0666        }
 667
 668        internal IEnumerator EagleEyeCameraRotation(float rotationSpeed)
 669        {
 0670            while (true)
 671            {
 0672                configuration.eagleEyeCamera.transform.Rotate(Vector3.up * Time.deltaTime * rotationSpeed, Space.World);
 0673                yield return null;
 674            }
 675        }
 676
 677        private IEnumerator BlockPlayerCameraUntilBlendingIsFinished(bool hideUIs)
 678        {
 0679            if (hideUIs)
 680            {
 0681                hudController?.minimapHud?.SetVisibility(false);
 0682                hudController?.profileHud?.SetVisibility(false);
 683            }
 684
 0685            CommonScriptableObjects.cameraBlocked.Set(true);
 686
 0687            yield return null;
 0688            yield return new WaitUntil(() => !CommonScriptableObjects.cameraIsBlending.Get());
 689
 0690            CommonScriptableObjects.cameraBlocked.Set(false);
 691
 0692            if (!hideUIs)
 693            {
 0694                hudController?.minimapHud?.SetVisibility(true);
 0695                hudController?.profileHud?.SetVisibility(true);
 696            }
 0697        }
 698    }
 699}

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.Vector3, 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()
IsPlayerInScene()
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()