| | 1 | | using System.Collections.Generic; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.SocialPlatforms.Impl; |
| | 4 | |
|
| | 5 | | namespace DCL |
| | 6 | | { |
| | 7 | | public static class MainSceneFactory |
| | 8 | | { |
| | 9 | | public static List<GameObject> CreatePlayerSystems() |
| | 10 | | { |
| 597 | 11 | | List<GameObject> result = new List<GameObject>(); |
| 597 | 12 | | GameObject playerGo = LoadAndInstantiate("Player"); |
| 597 | 13 | | var playerReferences = playerGo.GetComponent<PlayerReferences>(); |
| 597 | 14 | | SceneReferences.i.playerAvatarController = playerReferences.avatarController; |
| 597 | 15 | | SceneReferences.i.biwCameraParent = playerReferences.biwCameraRoot; |
| 597 | 16 | | SceneReferences.i.inputController = playerReferences.inputController; |
| 597 | 17 | | SceneReferences.i.cursorCanvas = playerReferences.cursorCanvas; |
| 597 | 18 | | SceneReferences.i.cameraController = playerReferences.cameraController; |
| 597 | 19 | | SceneReferences.i.mainCamera = playerReferences.mainCamera; |
| 597 | 20 | | SceneReferences.i.thirdPersonCamera = playerReferences.thirdPersonCamera; |
| 597 | 21 | | 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). |
| 597 | 26 | | result.Add( playerReferences.cursorCanvas.gameObject ); |
| 597 | 27 | | result.Add( playerReferences.cameraController.gameObject ); |
| 597 | 28 | | result.Add( playerReferences.inputController.gameObject ); |
| 597 | 29 | | result.Add( playerReferences.avatarController.gameObject ); |
| 597 | 30 | | result.Add( playerGo ); |
| | 31 | |
|
| 597 | 32 | | return result; |
| | 33 | | } |
| | 34 | |
|
| | 35 | | public static GameObject CreateMouseCatcher() |
| | 36 | | { |
| 57 | 37 | | GameObject result = LoadAndInstantiate("MouseCatcher"); |
| 57 | 38 | | MouseCatcher mouseCatcher = result.GetComponent<MouseCatcher>(); |
| 57 | 39 | | SceneReferences.i.mouseCatcher = mouseCatcher; |
| 57 | 40 | | return result; |
| | 41 | | } |
| | 42 | |
|
| 51 | 43 | | public static GameObject CreateHudController() => LoadAndInstantiate("HUDController"); |
| | 44 | |
|
| 51 | 45 | | public static GameObject CreateAudioHandler() => LoadAndInstantiate("HUDAudioHandler"); |
| | 46 | |
|
| 53 | 47 | | public static GameObject CreateNavMap() => LoadAndInstantiate("NavMap"); |
| | 48 | |
|
| 76 | 49 | | public static GameObject CreateSettingsController() => LoadAndInstantiate("SettingsController"); |
| | 50 | |
|
| | 51 | | public static GameObject CreateEnvironment(string prefabPath = "Environment") |
| | 52 | | { |
| 142 | 53 | | GameObject result = LoadAndInstantiate(prefabPath); |
| 142 | 54 | | var env = result.GetComponent<EnvironmentReferences>(); |
| 142 | 55 | | SceneReferences.i.environmentLight = env.environmentLight; |
| 142 | 56 | | SceneReferences.i.postProcessVolume = env.postProcessVolume; |
| 142 | 57 | | SceneReferences.i.groundVisual = env.ground; |
| 142 | 58 | | return result; |
| | 59 | | } |
| | 60 | |
|
| | 61 | | public static GameObject CreateBridges() |
| | 62 | | { |
| 54 | 63 | | if (SceneReferences.i.bridgeGameObject == null) |
| | 64 | | { |
| 52 | 65 | | var bridges = LoadAndInstantiate("Bridges"); |
| 52 | 66 | | SceneReferences.i.bridgeGameObject = bridges; |
| 52 | 67 | | return bridges; |
| | 68 | | } |
| | 69 | |
|
| 2 | 70 | | return SceneReferences.i.bridgeGameObject; |
| | 71 | | } |
| | 72 | |
|
| 125 | 73 | | public static GameObject CreateEventSystem() => LoadAndInstantiate("EventSystem"); |
| | 74 | |
|
| 89 | 75 | | public static GameObject CreateInteractionHoverCanvas() => LoadAndInstantiate("InteractionHoverCanvas"); |
| | 76 | |
|
| | 77 | | public static BuilderInWorldBridge CreateBuilderInWorldBridge(GameObject gameObject = null) |
| | 78 | | { |
| 38 | 79 | | if (gameObject == null) |
| 38 | 80 | | gameObject = new GameObject("BuilderInWorldBridge"); |
| | 81 | |
|
| 38 | 82 | | var instance = gameObject.AddComponent<BuilderInWorldBridge>(); |
| 38 | 83 | | SceneReferences.i.biwBridgeGameObject = instance.gameObject; |
| 38 | 84 | | return instance; |
| | 85 | | } |
| | 86 | |
|
| | 87 | | private static GameObject LoadAndInstantiate(string name) |
| | 88 | | { |
| 1293 | 89 | | GameObject instance = UnityEngine.Object.Instantiate(Resources.Load(name)) as GameObject; |
| 1293 | 90 | | instance.name = name; |
| 1293 | 91 | | return instance; |
| | 92 | | } |
| | 93 | | } |
| | 94 | | } |