< Summary

Class:DCL.Tutorial.TutorialController
Assembly:Onboarding
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/TutorialController.cs
Covered lines:208
Uncovered lines:72
Coverable lines:280
Total lines:701
Line coverage:74.2% (208 of 280)
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.019095.24%
SetTutorialDisabled()0%990100%
StartTutorialFromStep()0%17.1217092.59%
ShowTeacher3DModel(...)0%330100%
SetTeacherPosition(...)0%4.054085.71%
PlayTeacherAnimation(...)0%220100%
SetTeacherCanvasSortingOrder(...)0%2.062075%
SkipTutorial(...)0%7.336066.67%
GoToSpecificStep(...)0%90900%
SetNextSkippedSteps(...)0%2100%
SetEagleEyeCameraActive(...)0%440100%
OnRenderingStateChanged(...)0%5.035088.89%
ExecuteSteps()0%26.8126089.36%
SetUserTutorialStepAsCompleted(...)0%110100%
MoveTeacher()0%6.736072.73%
IsSettingsHUDInitialized_OnChange(...)0%20400%
OnRestartTutorial()0%2100%
IsPlayerInScene()0%3.143075%
IsPlayerInsideGenesisPlaza()0%7.237083.33%
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
 4176        public TutorialController ()
 77        {
 4178            tutorialView = CreateTutorialView();
 4179            SetConfiguration(tutorialView.configuration);
 4180        }
 81
 82        internal TutorialView CreateTutorialView()
 83        {
 4184            GameObject tutorialGO = GameObject.Instantiate(Resources.Load<GameObject>("TutorialView"));
 4185            tutorialGO.name = "TutorialController";
 4186            TutorialView tutorialView = tutorialGO.GetComponent<TutorialView>();
 4187            tutorialView.ConfigureView(this);
 88
 4189            return tutorialView;
 90        }
 91
 92        public void SetConfiguration(TutorialSettings configuration)
 93        {
 8294            this.configuration = configuration;
 95
 8296            i = this;
 8297            ShowTeacher3DModel(false);
 98
 8299            if (DataStore.i.settings.isInitialized.Get())
 0100                IsSettingsHUDInitialized_OnChange(true, false);
 101            else
 82102                DataStore.i.settings.isInitialized.OnChange += IsSettingsHUDInitialized_OnChange;
 103
 82104            if (configuration.debugRunTutorial)
 105            {
 0106                SetTutorialEnabled(JsonUtility.ToJson(new TutorialInitializationMessage
 107                {
 108                    fromDeepLink = configuration.debugOpenedFromDeepLink.ToString(),
 109                    enableNewTutorialCamera = false.ToString()
 110                }));
 111            }
 82112        }
 113
 114        public void Dispose()
 115        {
 41116            SetTutorialDisabled();
 117
 41118            DataStore.i.settings.isInitialized.OnChange -= IsSettingsHUDInitialized_OnChange;
 119
 41120            if (hudController != null &&
 121                hudController.settingsPanelHud != null)
 122            {
 0123                hudController.settingsPanelHud.OnRestartTutorial -= OnRestartTutorial;
 124            }
 125
 41126            NotificationsController.disableWelcomeNotification = false;
 127
 41128            if (tutorialView != null)
 41129                GameObject.Destroy(tutorialView.gameObject);
 41130        }
 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        {
 3156            if (DataStore.i.common.isTutorialRunning.Get())
 0157                return;
 158
 3159            if (Convert.ToBoolean(enableNewTutorialCamera))
 160            {
 3161                configuration.eagleCamInitPosition = new Vector3(15, 115, -30);
 3162                configuration.eagleCamInitLookAtPoint = new Vector3(16, 105, 6);
 3163                configuration.eagleCamRotationActived = false;
 164            }
 165
 3166            DataStore.i.common.isTutorialRunning.Set(true);
 3167            this.userAlreadyDidTheTutorial = userAlreadyDidTheTutorial;
 3168            CommonScriptableObjects.allUIHidden.Set(false);
 3169            CommonScriptableObjects.tutorialActive.Set(true);
 3170            openedFromDeepLink = Convert.ToBoolean(fromDeepLink);
 3171            this.tutorialType = tutorialType;
 172
 3173            hudController?.settingsPanelHud?.SetTutorialButtonEnabled(false);
 3174            hudController?.profileHud?.HideProfileMenu();
 175
 3176            NotificationsController.disableWelcomeNotification = true;
 177
 3178            WebInterface.SetDelightedSurveyEnabled(false);
 179
 3180            if (!CommonScriptableObjects.rendererState.Get())
 1181                CommonScriptableObjects.rendererState.OnChange += OnRenderingStateChanged;
 182            else
 2183                OnRenderingStateChanged(true, false);
 184
 3185            OnTutorialEnabled?.Invoke();
 1186        }
 187
 188        /// <summary>
 189        /// Stop and disables the tutorial controller.
 190        /// </summary>
 191        public void SetTutorialDisabled()
 192        {
 68193            CommonScriptableObjects.featureKeyTriggersBlocked.Set(false);
 194
 68195            if (executeStepsCoroutine != null)
 196            {
 2197                CoroutineStarter.Stop(executeStepsCoroutine);
 2198                executeStepsCoroutine = null;
 199            }
 200
 68201            if (runningStep != null)
 202            {
 2203                UnityEngine.Object.Destroy(runningStep.gameObject);
 2204                runningStep = null;
 205            }
 206
 68207            if (teacherMovementCoroutine != null)
 208            {
 1209                CoroutineStarter.Stop(teacherMovementCoroutine);
 1210                teacherMovementCoroutine = null;
 211            }
 212
 68213            tutorialReset = false;
 68214            DataStore.i.common.isTutorialRunning.Set(false);
 68215            tutorialView.tutorialMusicHandler.StopTutorialMusic();
 68216            ShowTeacher3DModel(false);
 68217            WebInterface.SetDelightedSurveyEnabled(true);
 218
 68219            if (Environment.i != null && Environment.i.world != null)
 220            {
 68221                WebInterface.SendSceneExternalActionEvent(Environment.i.world.state.currentSceneId, "tutorial", "end");
 222            }
 223
 68224            NotificationsController.disableWelcomeNotification = false;
 225
 68226            hudController?.settingsPanelHud?.SetTutorialButtonEnabled(true);
 227
 68228            CommonScriptableObjects.tutorialActive.Set(false);
 229
 68230            CommonScriptableObjects.rendererState.OnChange -= OnRenderingStateChanged;
 231
 68232            OnTutorialDisabled?.Invoke();
 2233        }
 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        {
 29241            if (!DataStore.i.common.isTutorialRunning.Get())
 2242                yield break;
 243
 27244            if (runningStep != null)
 245            {
 10246                runningStep.OnStepFinished();
 10247                GameObject.Destroy(runningStep.gameObject);
 10248                runningStep = null;
 249            }
 250
 27251            yield return new WaitUntil(IsPlayerInScene);
 252
 27253            playerIsInGenesisPlaza = IsPlayerInsideGenesisPlaza();
 254
 27255            switch (tutorialType)
 256            {
 257                case TutorialType.Initial:
 45258                    if(playerIsInGenesisPlaza) tutorialView.tutorialMusicHandler.TryPlayingMusic();
 25259                    if (userAlreadyDidTheTutorial)
 260                    {
 2261                        yield return ExecuteSteps(TutorialPath.FromUserThatAlreadyDidTheTutorial, stepIndex);
 2262                    }
 23263                    else if (tutorialReset)
 264                    {
 2265                        yield return ExecuteSteps(TutorialPath.FromResetTutorial, stepIndex);
 2266                    }
 21267                    else if (playerIsInGenesisPlaza)
 268                    {
 18269                        yield return ExecuteSteps(TutorialPath.FromGenesisPlaza, stepIndex);
 17270                    }
 3271                    else if (openedFromDeepLink)
 272                    {
 3273                        yield return ExecuteSteps(TutorialPath.FromDeepLink, stepIndex);
 2274                    }
 275                    else
 276                    {
 0277                        SetTutorialDisabled();
 0278                        yield break;
 279                    }
 280                    break;
 281                case TutorialType.BuilderInWorld:
 2282                    yield return ExecuteSteps(TutorialPath.FromBuilderInWorld, stepIndex);
 283                    break;
 284            }
 25285        }
 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        {
 169293            if (configuration.teacherCamera != null)
 169294                configuration.teacherCamera.enabled = active;
 295
 169296            if (configuration.teacherRawImage != null)
 123297                configuration.teacherRawImage.gameObject.SetActive(active);
 169298        }
 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        {
 23307            if (teacherMovementCoroutine != null)
 0308                CoroutineStarter.Stop(teacherMovementCoroutine);
 309
 23310            if (configuration.teacherRawImage != null)
 311            {
 3312                if (animated)
 1313                    teacherMovementCoroutine = CoroutineStarter.Start(MoveTeacher(destinationPosition));
 314                else
 2315                    configuration.teacherRawImage.rectTransform.position = new Vector3(destinationPosition.x, destinatio
 316            }
 22317        }
 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        {
 46325            if (configuration.teacher == null)
 17326                return;
 327
 29328            configuration.teacher.PlayAnimation(animation);
 29329        }
 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        {
 14337            if (configuration.teacherCanvas == null)
 0338                return;
 339
 14340            configuration.teacherCanvas.sortingOrder = sortOrder;
 14341        }
 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        {
 5348            if (!ignoreStatsSending && !configuration.debugRunTutorial && configuration.sendStats)
 349            {
 0350                SendSkipTutorialSegmentStats(
 351                    configuration.tutorialVersion,
 352                    runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""));
 353            }
 354
 5355            int skipIndex = configuration.stepsOnGenesisPlaza.Count +
 356                            configuration.stepsFromDeepLink.Count +
 357                            configuration.stepsFromReset.Count +
 358                            configuration.stepsFromBuilderInWorld.Count +
 359                            configuration.stepsFromUserThatAlreadyDidTheTutorial.Count;
 360
 5361            CoroutineStarter.Start(StartTutorialFromStep(skipIndex));
 362
 5363            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        {
 6421            configuration.eagleEyeCamera.gameObject.SetActive(isActive);
 6422            CoroutineStarter.Start(BlockPlayerCameraUntilBlendingIsFinished(isActive));
 423
 6424            if (isActive)
 425            {
 3426                configuration.eagleEyeCamera.transform.position = configuration.eagleCamInitPosition;
 3427                configuration.eagleEyeCamera.transform.LookAt(configuration.eagleCamInitLookAtPoint);
 428
 3429                if (configuration.eagleCamRotationActived)
 2430                    eagleEyeRotationCoroutine = CoroutineStarter.Start(EagleEyeCameraRotation(configuration.eagleCamRota
 2431            }
 3432            else if (eagleEyeRotationCoroutine != null)
 433            {
 2434                CoroutineStarter.Stop(eagleEyeRotationCoroutine);
 435            }
 4436        }
 437
 438        internal void OnRenderingStateChanged(bool renderingEnabled, bool prevState)
 439        {
 4440            if (!renderingEnabled)
 0441                return;
 442
 4443            CommonScriptableObjects.rendererState.OnChange -= OnRenderingStateChanged;
 444
 4445            if (configuration.debugRunTutorial)
 1446                currentStepIndex = configuration.debugStartingStepIndex >= 0 ? configuration.debugStartingStepIndex : 0;
 447            else
 3448                currentStepIndex = 0;
 449
 4450            PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.Reset);
 4451            executeStepsCoroutine = CoroutineStarter.Start(StartTutorialFromStep(currentStepIndex));
 4452        }
 453
 454        private IEnumerator ExecuteSteps(TutorialPath tutorialPath, int startingStepIndex)
 455        {
 27456            List<TutorialStep> steps = new List<TutorialStep>();
 457
 458            switch (tutorialPath)
 459            {
 460                case TutorialPath.FromGenesisPlaza:
 18461                    steps = configuration.stepsOnGenesisPlaza;
 18462                    break;
 463                case TutorialPath.FromDeepLink:
 3464                    steps = configuration.stepsFromDeepLink;
 3465                    break;
 466                case TutorialPath.FromResetTutorial:
 2467                    steps = configuration.stepsFromReset;
 2468                    break;
 469                case TutorialPath.FromBuilderInWorld:
 2470                    steps = configuration.stepsFromBuilderInWorld;
 2471                    break;
 472                case TutorialPath.FromUserThatAlreadyDidTheTutorial:
 2473                    steps = configuration.stepsFromUserThatAlreadyDidTheTutorial;
 474                    break;
 475            }
 476
 27477            currentPath = tutorialPath;
 478
 27479            elapsedTimeInCurrentStep = 0f;
 134480            for (int i = startingStepIndex; i < steps.Count; i++)
 481            {
 41482                if (nextStepsToSkip > 0)
 483                {
 0484                    nextStepsToSkip--;
 0485                    continue;
 486                }
 487
 41488                var stepPrefab = steps[i];
 489
 490                // TODO (Santi): This a TEMPORAL fix. It will be removed when we refactorize the tutorial system in orde
 41491                if (stepPrefab is TutorialStep_Tooltip_ExploreButton &&
 492                    !DataStore.i.exploreV2.isInitialized.Get())
 493                    continue;
 494
 41495                if (stepPrefab.letInstantiation)
 16496                    runningStep = GameObject.Instantiate(stepPrefab, tutorialView.transform).GetComponent<TutorialStep>(
 497                else
 25498                    runningStep = steps[i];
 499
 41500                runningStep.gameObject.name = runningStep.gameObject.name.Replace("(Clone)", "");
 41501                currentStepIndex = i;
 502
 41503                elapsedTimeInCurrentStep = Time.realtimeSinceStartup;
 41504                currentStepNumber = i + 1;
 505
 41506                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
 41515                runningStep.OnStepStart();
 41516                yield return runningStep.OnStepExecute();
 40517                if (i < steps.Count - 1)
 20518                    PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.StepCompleted);
 519                else
 20520                    PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.QuickGoodbye);
 521
 40522                yield return runningStep.OnStepPlayHideAnimation();
 40523                runningStep.OnStepFinished();
 40524                elapsedTimeInCurrentStep = Time.realtimeSinceStartup - elapsedTimeInCurrentStep;
 525
 40526                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
 40538                GameObject.Destroy(runningStep.gameObject);
 539
 40540                if (i < steps.Count - 1 && configuration.timeBetweenSteps > 0)
 0541                    yield return new WaitForSeconds(configuration.timeBetweenSteps);
 542            }
 543
 26544            if (!configuration.debugRunTutorial &&
 545                tutorialPath != TutorialPath.FromBuilderInWorld &&
 546                tutorialPath != TutorialPath.FromUserThatAlreadyDidTheTutorial)
 547            {
 22548                SetUserTutorialStepAsCompleted(TutorialFinishStep.NewTutorialFinished);
 549            }
 550
 26551            runningStep = null;
 552
 26553            SetTutorialDisabled();
 26554        }
 555
 44556        private void SetUserTutorialStepAsCompleted(TutorialFinishStep finishStepType) { WebInterface.SaveUserTutorialSt
 557
 558        internal IEnumerator MoveTeacher(Vector3 toPosition)
 559        {
 2560            if (configuration.teacherRawImage == null)
 0561                yield break;
 562
 2563            float t = 0f;
 564
 2565            Vector3 fromPosition = configuration.teacherRawImage.rectTransform.position;
 566
 3567            while (Vector3.Distance(configuration.teacherRawImage.rectTransform.position, toPosition) > 0)
 568            {
 3569                t += configuration.teacherMovementSpeed * Time.deltaTime;
 3570                if (t <= 1.0f)
 3571                    configuration.teacherRawImage.rectTransform.position = Vector3.Lerp(fromPosition, toPosition, config
 572                else
 0573                    configuration.teacherRawImage.rectTransform.position = toPosition;
 3574                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        {
 27602            IWorldState worldState = Environment.i.world.state;
 603
 27604            if (worldState == null || worldState.currentSceneId == null)
 0605                return false;
 606
 27607            return true;
 608        }
 609
 610        internal static bool IsPlayerInsideGenesisPlaza()
 611        {
 27612            if (Environment.i.world == null)
 0613                return false;
 614
 27615            IWorldState worldState = Environment.i.world.state;
 616
 27617            if (worldState == null || worldState.currentSceneId == null)
 0618                return false;
 619
 27620            Vector2Int genesisPlazaBaseCoords = new Vector2Int(-9, -9);
 621
 27622            IParcelScene currentScene = null;
 27623            if (worldState.loadedScenes != null)
 27624                currentScene = worldState.loadedScenes[worldState.currentSceneId];
 625
 27626            if (currentScene != null && currentScene.IsInsideSceneBoundaries(genesisPlazaBaseCoords))
 22627                return true;
 628
 5629            return false;
 630        }
 631
 632        private void SendStepStartedSegmentStats(int version, TutorialPath tutorialPath, int stepNumber, string stepName
 633        {
 0634            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 635            {
 636                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 637                new WebInterface.AnalyticsPayload.Property("path", tutorialPath.ToString()),
 638                new WebInterface.AnalyticsPayload.Property("step number", stepNumber.ToString()),
 639                new WebInterface.AnalyticsPayload.Property("step name", stepName)
 640            };
 0641            WebInterface.ReportAnalyticsEvent("tutorial step started", properties);
 0642        }
 643
 644        private void SendStepCompletedSegmentStats(int version, TutorialPath tutorialPath, int stepNumber, string stepNa
 645        {
 0646            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 647            {
 648                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 649                new WebInterface.AnalyticsPayload.Property("path", tutorialPath.ToString()),
 650                new WebInterface.AnalyticsPayload.Property("step number", stepNumber.ToString()),
 651                new WebInterface.AnalyticsPayload.Property("step name", stepName),
 652                new WebInterface.AnalyticsPayload.Property("elapsed time", elapsedTime.ToString("0.00"))
 653            };
 0654            WebInterface.ReportAnalyticsEvent("tutorial step completed", properties);
 0655        }
 656
 657        private void SendSkipTutorialSegmentStats(int version, string stepName)
 658        {
 0659            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 660            {
 661                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 662                new WebInterface.AnalyticsPayload.Property("path", currentPath.ToString()),
 663                new WebInterface.AnalyticsPayload.Property("step number", currentStepNumber.ToString()),
 664                new WebInterface.AnalyticsPayload.Property("step name", stepName),
 665                new WebInterface.AnalyticsPayload.Property("elapsed time", (Time.realtimeSinceStartup - elapsedTimeInCur
 666            };
 0667            WebInterface.ReportAnalyticsEvent("tutorial skipped", properties);
 0668        }
 669
 670        internal IEnumerator EagleEyeCameraRotation(float rotationSpeed)
 671        {
 2672            while (true)
 673            {
 4674                configuration.eagleEyeCamera.transform.Rotate(Vector3.up * Time.deltaTime * rotationSpeed, Space.World);
 4675                yield return null;
 676            }
 677        }
 678
 679        private IEnumerator BlockPlayerCameraUntilBlendingIsFinished(bool hideUIs)
 680        {
 6681            if (hideUIs)
 682            {
 3683                hudController?.minimapHud?.SetVisibility(false);
 3684                hudController?.profileHud?.SetVisibility(false);
 685            }
 686
 6687            CommonScriptableObjects.cameraBlocked.Set(true);
 688
 6689            yield return null;
 12690            yield return new WaitUntil(() => !CommonScriptableObjects.cameraIsBlending.Get());
 691
 6692            CommonScriptableObjects.cameraBlocked.Set(false);
 693
 6694            if (!hideUIs)
 695            {
 3696                hudController?.minimapHud?.SetVisibility(true);
 3697                hudController?.profileHud?.SetVisibility(true);
 698            }
 6699        }
 700    }
 701}

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()