< Summary

Class:DCL.Main
Assembly:Main
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Scene/Main/Main.cs
Covered lines:22
Uncovered lines:16
Coverable lines:38
Total lines:116
Line coverage:57.8% (22 of 38)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%7.095056.25%
SetupEnvironment()0%2100%
MessagingContextBuilder()0%2100%
PlatformContextBuilder()0%2100%
WorldRuntimeContextBuilder()0%2100%
HUDContextBuilder()0%2100%
Start()0%110100%
Update()0%330100%
LateUpdate()0%220100%
OnDestroy()0%5.024060%
OnGUI()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Scene/Main/Main.cs

#LineLine coverage
 1using System;
 2using DCL.Components;
 3using DCL.Controllers;
 4using DCL.Helpers;
 5using UnityEngine;
 6using UnityEngine.Serialization;
 7
 8namespace DCL
 9{
 10    /// <summary>
 11    /// This is the InitialScene entry point.
 12    /// Most of the application subsystems should be initialized from this class Awake() event.
 13    /// </summary>
 14    public class Main : MonoBehaviour
 15    {
 016        public static Main i { get; private set; }
 17
 18        public PoolableComponentFactory componentFactory;
 19
 20        private PerformanceMetricsController performanceMetricsController;
 21        private IKernelCommunication kernelCommunication;
 22
 23        private PluginSystem pluginSystem;
 24
 25        protected virtual void Awake()
 26        {
 12327            if (i != null)
 28            {
 029                Utils.SafeDestroy(this);
 030                return;
 31            }
 32
 12333            i = this;
 34
 12335            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 36            {
 037                performanceMetricsController = new PerformanceMetricsController();
 038                RenderProfileManifest.i.Initialize();
 039                SetupEnvironment();
 40            }
 41
 12342            pluginSystem = new PluginSystem();
 43
 44#if UNITY_WEBGL && !UNITY_EDITOR
 45            Debug.Log("DCL Unity Build Version: " + DCL.Configuration.ApplicationSettings.version);
 46            Debug.unityLogger.logEnabled = false;
 47
 48            kernelCommunication = new NativeBridgeCommunication(Environment.i.world.sceneController);
 49#else
 50            // TODO(Brian): Remove this branching once we finish migrating all tests out of the
 51            //              IntegrationTestSuite_Legacy base class.
 12352            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 53            {
 054                kernelCommunication = new WebSocketCommunication();
 55            }
 56#endif
 57
 58            // TODO(Brian): This is a temporary fix to address elevators issue in the xmas event.
 59            // We should re-enable this later as produces a performance regression.
 12360            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 061                Environment.i.platform.cullingController.SetAnimationCulling(false);
 62
 63            // this event should be the last one to be executed after initialization
 64            // it is used by the kernel to signal "EngineReady" or something like that
 65            // to prevent race conditions like "SceneController is not an object",
 66            // aka sending events before unity is ready
 12367            DCL.Interface.WebInterface.SendSystemInfoReport();
 68
 69            // We trigger the Decentraland logic once everything is initialized.
 12370            DCL.Interface.WebInterface.StartDecentraland();
 12371        }
 72
 73        protected virtual void SetupEnvironment()
 74        {
 075            Environment.SetupWithBuilders(
 76                messagingBuilder: MessagingContextBuilder,
 77                platformBuilder: PlatformContextBuilder,
 78                worldRuntimeBuilder: WorldRuntimeContextBuilder,
 79                hudBuilder: HUDContextBuilder);
 080        }
 81
 082        protected virtual MessagingContext MessagingContextBuilder() { return MessagingContextFactory.CreateDefault(); }
 83
 084        protected virtual PlatformContext PlatformContextBuilder() { return PlatformContextFactory.CreateDefault(); }
 85
 086        protected virtual WorldRuntimeContext WorldRuntimeContextBuilder() { return WorldRuntimeContextFactory.CreateDef
 87
 088        protected virtual HUDContext HUDContextBuilder() { return HUDContextFactory.CreateDefault(); }
 89
 24690        private void Start() { Environment.i.world.sceneController.Start(); }
 91
 92        private void Update()
 93        {
 2125394            Environment.i.platform.Update();
 2125395            Environment.i.world.sceneController.Update();
 2125396            performanceMetricsController?.Update();
 2125397            pluginSystem?.Update();
 2125398        }
 99
 100        private void LateUpdate()
 101        {
 21252102            Environment.i.world.sceneController.LateUpdate();
 21252103            pluginSystem?.LateUpdate();
 21252104        }
 105
 106        protected virtual void OnDestroy()
 107        {
 122108            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 0109                Environment.Dispose();
 122110            pluginSystem?.OnDestroy();
 122111            kernelCommunication?.Dispose();
 0112        }
 113
 6756114        private void OnGUI() { pluginSystem?.OnGUI(); }
 115    }
 116}