< Summary

Class:DCL.MainSceneFactory
Assembly:InitialSceneReferences
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/InitialSceneReferences/MainSceneFactory.cs
Covered lines:46
Uncovered lines:0
Coverable lines:46
Total lines:94
Line coverage:100% (46 of 46)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CreatePlayerSystems()0%110100%
CreateMouseCatcher()0%110100%
CreateHudController()0%110100%
CreateAudioHandler()0%110100%
CreateNavMap()0%110100%
CreateSettingsController()0%110100%
CreateEnvironment(...)0%110100%
CreateBridges()0%220100%
CreateEventSystem()0%110100%
CreateInteractionHoverCanvas()0%110100%
CreateBuilderInWorldBridge(...)0%220100%
LoadAndInstantiate(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/InitialSceneReferences/MainSceneFactory.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using UnityEngine;
 3using UnityEngine.SocialPlatforms.Impl;
 4
 5namespace DCL
 6{
 7    public static class MainSceneFactory
 8    {
 9        public static List<GameObject> CreatePlayerSystems()
 10        {
 59711            List<GameObject> result = new List<GameObject>();
 59712            GameObject playerGo = LoadAndInstantiate("Player");
 59713            var playerReferences = playerGo.GetComponent<PlayerReferences>();
 59714            SceneReferences.i.playerAvatarController = playerReferences.avatarController;
 59715            SceneReferences.i.biwCameraParent = playerReferences.biwCameraRoot;
 59716            SceneReferences.i.inputController = playerReferences.inputController;
 59717            SceneReferences.i.cursorCanvas = playerReferences.cursorCanvas;
 59718            SceneReferences.i.cameraController = playerReferences.cameraController;
 59719            SceneReferences.i.mainCamera = playerReferences.mainCamera;
 59720            SceneReferences.i.thirdPersonCamera = playerReferences.thirdPersonCamera;
 59721            SceneReferences.i.firstPersonCamera = playerReferences.firstPersonCamera;
 22
 23            // Why we don't just add the playerGo?
 24            // This happens because the characterController reparents itself.
 25            // (and any of our systems may do this as well).
 59726            result.Add( playerReferences.cursorCanvas.gameObject );
 59727            result.Add( playerReferences.cameraController.gameObject );
 59728            result.Add( playerReferences.inputController.gameObject );
 59729            result.Add( playerReferences.avatarController.gameObject );
 59730            result.Add( playerGo );
 31
 59732            return result;
 33        }
 34
 35        public static GameObject CreateMouseCatcher()
 36        {
 5737            GameObject result = LoadAndInstantiate("MouseCatcher");
 5738            MouseCatcher mouseCatcher = result.GetComponent<MouseCatcher>();
 5739            SceneReferences.i.mouseCatcher = mouseCatcher;
 5740            return result;
 41        }
 42
 5143        public static GameObject CreateHudController() => LoadAndInstantiate("HUDController");
 44
 5145        public static GameObject CreateAudioHandler() => LoadAndInstantiate("HUDAudioHandler");
 46
 5347        public static GameObject CreateNavMap() => LoadAndInstantiate("NavMap");
 48
 7649        public static GameObject CreateSettingsController() => LoadAndInstantiate("SettingsController");
 50
 51        public static GameObject CreateEnvironment(string prefabPath = "Environment")
 52        {
 14253            GameObject result = LoadAndInstantiate(prefabPath);
 14254            var env = result.GetComponent<EnvironmentReferences>();
 14255            SceneReferences.i.environmentLight = env.environmentLight;
 14256            SceneReferences.i.postProcessVolume = env.postProcessVolume;
 14257            SceneReferences.i.groundVisual = env.ground;
 14258            return result;
 59        }
 60
 61        public static GameObject CreateBridges()
 62        {
 5463            if (SceneReferences.i.bridgeGameObject == null)
 64            {
 5265                var bridges = LoadAndInstantiate("Bridges");
 5266                SceneReferences.i.bridgeGameObject = bridges;
 5267                return bridges;
 68            }
 69
 270            return SceneReferences.i.bridgeGameObject;
 71        }
 72
 12573        public static GameObject CreateEventSystem() => LoadAndInstantiate("EventSystem");
 74
 8975        public static GameObject CreateInteractionHoverCanvas() => LoadAndInstantiate("InteractionHoverCanvas");
 76
 77        public static BuilderInWorldBridge CreateBuilderInWorldBridge(GameObject gameObject = null)
 78        {
 3879            if (gameObject == null)
 3880                gameObject = new GameObject("BuilderInWorldBridge");
 81
 3882            var instance = gameObject.AddComponent<BuilderInWorldBridge>();
 3883            SceneReferences.i.biwBridgeGameObject = instance.gameObject;
 3884            return instance;
 85        }
 86
 87        private static GameObject LoadAndInstantiate(string name)
 88        {
 129389            GameObject instance = UnityEngine.Object.Instantiate(Resources.Load(name)) as GameObject;
 129390            instance.name = name;
 129391            return instance;
 92        }
 93    }
 94}