| | 1 | | using System; |
| | 2 | | using System.ComponentModel; |
| | 3 | | using DCL.Controllers; |
| | 4 | | using UnityEngine.SceneManagement; |
| | 5 | |
|
| | 6 | | namespace DCL |
| | 7 | | { |
| | 8 | | public class Environment |
| | 9 | | { |
| 1 | 10 | | public static Model i = new Model(new ServiceLocator()); |
| | 11 | |
|
| | 12 | | /// <summary> |
| | 13 | | /// Setup the environment with the configured builder funcs. |
| | 14 | | /// </summary> |
| | 15 | | public static void Setup(ServiceLocator serviceLocator) |
| | 16 | | { |
| 882 | 17 | | i.Dispose(); |
| 882 | 18 | | i = new Model(serviceLocator); |
| 882 | 19 | | serviceLocator.Initialize(); |
| 882 | 20 | | } |
| | 21 | |
|
| | 22 | | /// <summary> |
| | 23 | | /// Dispose() all the current environment systems. |
| | 24 | | /// </summary> |
| | 25 | | public static void Dispose() |
| | 26 | | { |
| 880 | 27 | | i?.Dispose(); |
| 880 | 28 | | } |
| | 29 | |
|
| | 30 | | public class Model : IDisposable |
| | 31 | | { |
| | 32 | | public readonly ServiceLocator serviceLocator; |
| | 33 | | public readonly MessagingContext messaging; |
| | 34 | | public readonly PlatformContext platform; |
| | 35 | | public readonly WorldRuntimeContext world; |
| | 36 | | public readonly HUDContext hud; |
| | 37 | |
|
| 883 | 38 | | public Model (ServiceLocator serviceLocator) |
| | 39 | | { |
| 883 | 40 | | this.serviceLocator = serviceLocator; |
| 883 | 41 | | messaging = new MessagingContext(serviceLocator); |
| 883 | 42 | | platform = new PlatformContext(serviceLocator); |
| 883 | 43 | | world = new WorldRuntimeContext(serviceLocator); |
| 883 | 44 | | hud = new HUDContext(serviceLocator); |
| 883 | 45 | | } |
| | 46 | |
|
| | 47 | | public void Dispose() |
| | 48 | | { |
| 1762 | 49 | | this.serviceLocator.Dispose(); |
| 1762 | 50 | | } |
| | 51 | | } |
| | 52 | | } |
| | 53 | | } |