< 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:24
Uncovered lines:14
Coverable lines:38
Total lines:111
Line coverage:63.1% (24 of 38)
Covered branches:0
Total branches:0

Metrics

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

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        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_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
 12350            kernelCommunication = new WebSocketCommunication();
 51#endif
 52
 53            // TODO(Brian): This is a temporary fix to address elevators issue in the xmas event.
 54            // We should re-enable this later as produces a performance regression.
 12355            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 056                Environment.i.platform.cullingController.SetAnimationCulling(false);
 57
 58            // this event should be the last one to be executed after initialization
 59            // it is used by the kernel to signal "EngineReady" or something like that
 60            // to prevent race conditions like "SceneController is not an object",
 61            // aka sending events before unity is ready
 12362            DCL.Interface.WebInterface.SendSystemInfoReport();
 12363        }
 64
 65        protected virtual void SetupEnvironment()
 66        {
 067            Environment.SetupWithBuilders(
 68                messagingBuilder: MessagingContextBuilder,
 69                platformBuilder: PlatformContextBuilder,
 70                worldRuntimeBuilder: WorldRuntimeContextBuilder,
 71                hudBuilder: HUDContextBuilder);
 072        }
 73
 074        protected virtual MessagingContext MessagingContextBuilder() { return MessagingContextFactory.CreateDefault(); }
 75
 076        protected virtual PlatformContext PlatformContextBuilder() { return PlatformContextFactory.CreateDefault(); }
 77
 078        protected virtual WorldRuntimeContext WorldRuntimeContextBuilder() { return WorldRuntimeContextFactory.CreateDef
 79
 080        protected virtual HUDContext HUDContextBuilder() { return HUDContextFactory.CreateDefault(); }
 81
 82        private void Start()
 83        {
 12384            Environment.i.world.sceneController.Start();
 12385            pluginSystem?.Start();
 12386        }
 87
 88        private void Update()
 89        {
 1876690            Environment.i.platform.Update();
 1876691            Environment.i.world.sceneController.Update();
 1876692            performanceMetricsController?.Update();
 1876693            pluginSystem.Update();
 1876694        }
 95
 96        private void LateUpdate()
 97        {
 1876598            Environment.i.world.sceneController.LateUpdate();
 1876599            pluginSystem.LateUpdate();
 18765100        }
 101
 102        private void OnDestroy()
 103        {
 122104            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 0105                Environment.Dispose();
 122106            pluginSystem?.OnDestroy();
 122107            kernelCommunication.Dispose();
 122108        }
 7244109        private void OnGUI() { pluginSystem.OnGUI(); }
 110    }
 111}