From 8514b271846f5b8dd5c58393b1e63bc50769e444 Mon Sep 17 00:00:00 2001 From: Nick Khalow <71646502+NickKhalow@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:52:34 +0800 Subject: [PATCH] resolve DynamicWorldContainer (#3022) * resolve DynamicWorldContainer * fix merge * fix dependencies --- .../CameraReelRemoteStorageService.cs | 2 +- .../CameraReelStorageService/csc.rsp | 1 + .../CameraReelStorageService/csc.rsp.meta | 3 + Explorer/Assets/DCL/LOD/Systems/LODPlugin.cs | 21 +- .../Analytics/Systems/AnalyticsPlugin.cs | 6 - .../Global/IDCLGlobalPluginWithoutSettings.cs | 12 +- .../DCL/PluginSystem/Global/ProfilePlugin.cs | 1 - .../Assets/DCL/PluginSystem/IDCLPlugin.cs | 30 +- .../PluginSystem/IPluginSettingsContainer.cs | 7 +- .../PluginSystem/NoExposedPluginSettings.cs | 5 +- .../PluginSystem/PluginContainerExtensions.cs | 6 +- .../PluginSystem/PluginSettingsContainer.cs | 9 +- .../DCL/PluginSystem/World/AnimatorPlugin.cs | 5 - .../PluginSystem/World/AssetBundlesPlugin.cs | 8 - .../PluginSystem/World/AvatarAttachPlugin.cs | 5 - .../PluginSystem/World/AvatarShapePlugin.cs | 6 - .../DCL/PluginSystem/World/BillboardPlugin.cs | 7 - .../World/IDCLWorldPluginWithoutSettings.cs | 11 +- .../PluginSystem/World/InputModifierPlugin.cs | 6 +- .../DCL/PluginSystem/World/MapPinPlugin.cs | 5 - .../PluginSystem/World/MultiplayerPlugin.cs | 8 - .../DCL/PluginSystem/World/RealmInfoPlugin.cs | 5 - .../World/TexturesLoadingPlugin.cs | 5 - .../DCL/PluginSystem/World/TweenPlugin.cs | 7 - .../Assets/DCL/Roads/Systems/RoadPlugin.cs | 7 - .../Analytics/Plugin/WebRequestsPlugin.cs | 6 - .../Global/Dynamic/DynamicWorldContainer.cs | 336 ++++++++++-------- 27 files changed, 252 insertions(+), 278 deletions(-) create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/csc.rsp create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/csc.rsp.meta diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs index 8cb417a05f..3d70ca5359 100644 --- a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs @@ -14,7 +14,7 @@ public class CameraReelRemoteStorageService : ICameraReelStorageService, ICamera public event Action? ScreenshotUploaded; - public CameraReelRemoteStorageService(ICameraReelImagesMetadataDatabase imagesMetadataDatabase, ICameraReelScreenshotsStorage screenshotsStorage, string userAddress) + public CameraReelRemoteStorageService(ICameraReelImagesMetadataDatabase imagesMetadataDatabase, ICameraReelScreenshotsStorage screenshotsStorage, string? userAddress) { this.imagesMetadataDatabase = imagesMetadataDatabase; this.screenshotsStorage = screenshotsStorage; diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/csc.rsp b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/csc.rsp new file mode 100644 index 0000000000..dcc377f897 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/csc.rsp @@ -0,0 +1 @@ +-nullable:enable \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/csc.rsp.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/csc.rsp.meta new file mode 100644 index 0000000000..471836c1a2 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/csc.rsp.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2aaf8d1cfa1247b9ad54d91336c5610d +timeCreated: 1734532743 \ No newline at end of file diff --git a/Explorer/Assets/DCL/LOD/Systems/LODPlugin.cs b/Explorer/Assets/DCL/LOD/Systems/LODPlugin.cs index c12ccb4697..37658690c9 100644 --- a/Explorer/Assets/DCL/LOD/Systems/LODPlugin.cs +++ b/Explorer/Assets/DCL/LOD/Systems/LODPlugin.cs @@ -1,7 +1,4 @@ -using System; -using System.Threading; using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.AvatarRendering.AvatarShape.Rendering.TextureArray; using DCL.DebugUtilities; using DCL.LOD; @@ -39,7 +36,6 @@ public class LODPlugin : IDCLGlobalPlugin private TextureArrayContainer lodTextureArrayContainer; private readonly CacheCleaner cacheCleaner; - private readonly ILODCache lodCache; private readonly IComponentPool lodGroupPool; @@ -51,7 +47,8 @@ public LODPlugin(RealmData realmData, IPerformanceBudget memoryBudget, IPerformanceBudget frameCapBudget, IScenesCache scenesCache, IDebugContainerBuilder debugBuilder, ISceneReadinessReportQueue sceneReadinessReportQueue, VisualSceneStateResolver visualSceneStateResolver, TextureArrayContainerFactory textureArrayContainerFactory, ILODSettingsAsset lodSettingsAsset, SceneAssetLock sceneAssetLock, IRealmPartitionSettings partitionSettings, - ILODCache lodCache, IComponentPool lodGroupPool, IDecentralandUrlsSource decentralandUrlsSource,Transform lodCacheParent, bool lodEnabled, int lodLevels) + ILODCache lodCache, IComponentPool lodGroupPool, IDecentralandUrlsSource decentralandUrlsSource, Transform lodCacheParent, bool lodEnabled, + int lodLevels) { this.realmData = realmData; this.decentralandUrlsSource = decentralandUrlsSource; @@ -72,37 +69,29 @@ public LODPlugin(RealmData realmData, IPerformanceBudget memoryBudget, this.lodLevels = lodLevels; } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) - { - return UniTask.CompletedTask; - } - public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in GlobalPluginArguments arguments) { lodTextureArrayContainer = textureArrayContainerFactory.CreateSceneLOD(SCENE_TEX_ARRAY_SHADER, lodSettingsAsset.DefaultTextureArrayResolutionDescriptors, TextureFormat.BC7, lodSettingsAsset.ArraySizeForMissingResolutions, lodSettingsAsset.CapacityForMissingResolutions); - - ResolveVisualSceneStateSystem.InjectToWorld(ref builder, lodSettingsAsset, visualSceneStateResolver, realmData); UpdateVisualSceneStateSystem.InjectToWorld(ref builder, realmData, scenesCache, lodCache, lodSettingsAsset, visualSceneStateResolver, sceneAssetLock); - + if (lodEnabled) { CalculateLODBiasSystem.InjectToWorld(ref builder); RecalculateLODDistanceSystem.InjectToWorld(ref builder, partitionSettings); + InitializeSceneLODInfoSystem.InjectToWorld(ref builder, lodCache, lodLevels, lodGroupPool, lodCacheParent, sceneReadinessReportQueue, scenesCache); + UpdateSceneLODInfoSystem.InjectToWorld(ref builder, lodSettingsAsset, scenesCache, sceneReadinessReportQueue, decentralandUrlsSource); InstantiateSceneLODInfoSystem.InjectToWorld(ref builder, frameCapBudget, memoryBudget, scenesCache, sceneReadinessReportQueue, lodTextureArrayContainer, partitionSettings); LODDebugToolsSystem.InjectToWorld(ref builder, debugBuilder, lodSettingsAsset, lodLevels); } else - { UpdateSceneLODInfoMockSystem.InjectToWorld(ref builder, sceneReadinessReportQueue, scenesCache); - } } - public void Dispose() { diff --git a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Analytics/Systems/AnalyticsPlugin.cs b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Analytics/Systems/AnalyticsPlugin.cs index 4504e48871..1af4525d8c 100644 --- a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Analytics/Systems/AnalyticsPlugin.cs +++ b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Analytics/Systems/AnalyticsPlugin.cs @@ -1,17 +1,14 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.Analytics.Systems; using DCL.AvatarRendering.AvatarShape.UnityInterface; using DCL.DebugUtilities; using DCL.InWorldCamera.CameraReelStorageService; -using DCL.InWorldCamera.Systems; using DCL.PerformanceAndDiagnostics.Analytics; using DCL.Profiling; using DCL.Utilities; using DCL.Web3.Identities; using ECS; using ECS.SceneLifeCycle; -using System.Threading; using Utility.Json; using ScreencaptureAnalyticsSystem = DCL.Analytics.Systems.ScreencaptureAnalyticsSystem; @@ -68,8 +65,5 @@ public void Dispose() { walkedDistanceAnalytics.Dispose(); } - - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; } } diff --git a/Explorer/Assets/DCL/PluginSystem/Global/IDCLGlobalPluginWithoutSettings.cs b/Explorer/Assets/DCL/PluginSystem/Global/IDCLGlobalPluginWithoutSettings.cs index 740bce959d..f3458761f9 100644 --- a/Explorer/Assets/DCL/PluginSystem/Global/IDCLGlobalPluginWithoutSettings.cs +++ b/Explorer/Assets/DCL/PluginSystem/Global/IDCLGlobalPluginWithoutSettings.cs @@ -6,17 +6,9 @@ namespace DCL.PluginSystem.Global { public interface IDCLGlobalPluginWithoutSettings : IDCLGlobalPlugin { - UniTask IDCLPlugin.Initialize(IPluginSettingsContainer container, CancellationToken ct) => - - // Don't even try to retrieve empty settings - UniTask.CompletedTask; - void IDisposable.Dispose() { } - UniTask IDCLPlugin.InitializeAsync(NoExposedPluginSettings settings, - CancellationToken ct) - { - return UniTask.CompletedTask; - } + UniTask IDCLPlugin.InitializeAsync(NoExposedPluginSettings settings, CancellationToken ct) => + UniTask.CompletedTask; } } diff --git a/Explorer/Assets/DCL/PluginSystem/Global/ProfilePlugin.cs b/Explorer/Assets/DCL/PluginSystem/Global/ProfilePlugin.cs index 14557e99eb..189f37df48 100644 --- a/Explorer/Assets/DCL/PluginSystem/Global/ProfilePlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/Global/ProfilePlugin.cs @@ -5,7 +5,6 @@ using ECS.LifeCycle.Systems; using ECS.StreamableLoading.Cache; using System.Threading; -using Utility.Multithreading; namespace DCL.PluginSystem.Global { diff --git a/Explorer/Assets/DCL/PluginSystem/IDCLPlugin.cs b/Explorer/Assets/DCL/PluginSystem/IDCLPlugin.cs index 7086120303..1098594bd8 100644 --- a/Explorer/Assets/DCL/PluginSystem/IDCLPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/IDCLPlugin.cs @@ -6,20 +6,34 @@ namespace DCL.PluginSystem { public interface IDCLPlugin : IDisposable { - // Add the reference to IAssetProvisioner to load from addressables - UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct); + UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) + { + if (this is IDCLPluginWithSettings plugin) + { + object settings = container.GetSettings(plugin.SettingsType); + return plugin.InitializeAsync(settings, ct); + } + + return UniTask.CompletedTask; + } + } + + public interface IDCLPluginWithSettings : IDCLPlugin + { + Type SettingsType { get; } + + UniTask InitializeAsync(object settings, CancellationToken ct); } /// /// Represents a plugin that can be injected into the ECS world /// - public interface IDCLPlugin : IDCLPlugin where T: IDCLPluginSettings, new() + public interface IDCLPlugin : IDCLPluginWithSettings where T: IDCLPluginSettings, new() { - UniTask IDCLPlugin.Initialize(IPluginSettingsContainer container, CancellationToken ct) - { - var settings = container.GetSettings(); - return InitializeAsync(settings, ct); - } + Type IDCLPluginWithSettings.SettingsType => typeof(T); + + UniTask IDCLPluginWithSettings.InitializeAsync(object settings, CancellationToken ct) => + InitializeAsync((T)settings, ct); UniTask InitializeAsync(T settings, CancellationToken ct); } diff --git a/Explorer/Assets/DCL/PluginSystem/IPluginSettingsContainer.cs b/Explorer/Assets/DCL/PluginSystem/IPluginSettingsContainer.cs index 570c856dbf..dde72357f6 100644 --- a/Explorer/Assets/DCL/PluginSystem/IPluginSettingsContainer.cs +++ b/Explorer/Assets/DCL/PluginSystem/IPluginSettingsContainer.cs @@ -1,3 +1,5 @@ +using System; + namespace DCL.PluginSystem { /// @@ -8,6 +10,9 @@ public interface IPluginSettingsContainer /// /// Get a typed settings object or throw an exception if it doesn't exist /// - T GetSettings() where T: IDCLPluginSettings; + T GetSettings() where T: IDCLPluginSettings => + (T)GetSettings(typeof(T)); + + object GetSettings(Type type); } } diff --git a/Explorer/Assets/DCL/PluginSystem/NoExposedPluginSettings.cs b/Explorer/Assets/DCL/PluginSystem/NoExposedPluginSettings.cs index 9b2ece66c6..70d8fc1896 100644 --- a/Explorer/Assets/DCL/PluginSystem/NoExposedPluginSettings.cs +++ b/Explorer/Assets/DCL/PluginSystem/NoExposedPluginSettings.cs @@ -3,5 +3,8 @@ namespace DCL.PluginSystem /// /// Indicates that plugin contains no serializable settings /// - public class NoExposedPluginSettings : IDCLPluginSettings { } + public class NoExposedPluginSettings : IDCLPluginSettings + { + public static NoExposedPluginSettings Instance { get; } = new (); + } } diff --git a/Explorer/Assets/DCL/PluginSystem/PluginContainerExtensions.cs b/Explorer/Assets/DCL/PluginSystem/PluginContainerExtensions.cs index 8e18669912..5b3d8845ab 100644 --- a/Explorer/Assets/DCL/PluginSystem/PluginContainerExtensions.cs +++ b/Explorer/Assets/DCL/PluginSystem/PluginContainerExtensions.cs @@ -7,7 +7,11 @@ namespace DCL.PluginSystem { public static class PluginContainerExtensions { - public static async UniTask<(TPlugin plugin, bool success)> InitializePluginAsync(this IPluginSettingsContainer pluginSettingsContainer, TPlugin plugin, CancellationToken ct) where TPlugin: class, IDCLPlugin + public static async UniTask<(TPlugin plugin, bool success)> InitializePluginAsync( + this IPluginSettingsContainer pluginSettingsContainer, + TPlugin plugin, + CancellationToken ct + ) where TPlugin: class, IDCLPlugin { try { await plugin.Initialize(pluginSettingsContainer, ct); } catch (Exception e) when (e is not OperationCanceledException) diff --git a/Explorer/Assets/DCL/PluginSystem/PluginSettingsContainer.cs b/Explorer/Assets/DCL/PluginSystem/PluginSettingsContainer.cs index 3831e34f89..b4b6fc6153 100644 --- a/Explorer/Assets/DCL/PluginSystem/PluginSettingsContainer.cs +++ b/Explorer/Assets/DCL/PluginSystem/PluginSettingsContainer.cs @@ -19,10 +19,13 @@ public class PluginSettingsContainer : ScriptableObject, IPluginSettingsContaine // ReSharper disable once CollectionNeverUpdated.Global [SerializeReference] [PluginSettingsTitle] internal List settings = new (); - public T GetSettings() where T: IDCLPluginSettings + public object GetSettings(Type type) { - try { return (T)settings.Find(x => x.GetType() == typeof(T)).EnsureNotNull(); } - catch (Exception e) { throw new NullReferenceException($"Settings not found for type {typeof(T).Name} at {this.GetType().FullName}", e); } + if (type == typeof(NoExposedPluginSettings)) + return NoExposedPluginSettings.Instance; + + try { return settings.Find(x => x.GetType() == type).EnsureNotNull(); } + catch (Exception e) { throw new NullReferenceException($"Settings not found for type {type.Name} at {this.GetType().FullName}", e); } } public async UniTask EnsureValidAsync() diff --git a/Explorer/Assets/DCL/PluginSystem/World/AnimatorPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/AnimatorPlugin.cs index acfbc08657..b8177d2970 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/AnimatorPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/AnimatorPlugin.cs @@ -1,20 +1,15 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.ECSComponents; using DCL.PluginSystem.World.Dependencies; using DCL.SDKComponents.Animator.Systems; using ECS.LifeCycle; using ECS.LifeCycle.Systems; using System.Collections.Generic; -using System.Threading; namespace DCL.PluginSystem.World { public class AnimatorPlugin : IDCLWorldPluginWithoutSettings { - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in ECSWorldInstanceSharedDependencies sharedDependencies, in PersistentEntities persistentEntities, List finalizeWorldSystems, List sceneIsCurrentListeners) { ResetDirtyFlagSystem.InjectToWorld(ref builder); diff --git a/Explorer/Assets/DCL/PluginSystem/World/AssetBundlesPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/AssetBundlesPlugin.cs index 0cefadbcc6..9f697c24cb 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/AssetBundlesPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/AssetBundlesPlugin.cs @@ -12,7 +12,6 @@ using System.Collections.Generic; using System.Threading; using UnityEngine; -using Utility.Multithreading; namespace DCL.PluginSystem.World { @@ -61,12 +60,6 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder builder, LoadGlobalAssetBundleSystem.InjectToWorld(ref builder, assetBundleCache, webRequestController, assetBundleLoadingMutex); } -#region Interface Ambiguity - UniTask IDCLPlugin.Initialize(IPluginSettingsContainer container, CancellationToken ct) => - - // Don't even try to retrieve empty settings - UniTask.CompletedTask; - UniTask IDCLPlugin.InitializeAsync(NoExposedPluginSettings settings, CancellationToken ct) => UniTask.CompletedTask; @@ -74,6 +67,5 @@ void IDisposable.Dispose() { assetBundleCache.Dispose(); } -#endregion } } diff --git a/Explorer/Assets/DCL/PluginSystem/World/AvatarAttachPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/AvatarAttachPlugin.cs index 72d4a486c2..705d888a87 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/AvatarAttachPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/AvatarAttachPlugin.cs @@ -1,5 +1,4 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.AvatarRendering.AvatarShape.UnityInterface; using DCL.ECSComponents; using DCL.Optimization.Pools; @@ -9,7 +8,6 @@ using ECS.LifeCycle; using ECS.LifeCycle.Systems; using System.Collections.Generic; -using System.Threading; using UnityEngine; namespace DCL.PluginSystem.World @@ -25,9 +23,6 @@ public AvatarAttachPlugin(ObjectProxy mainPlayerAvatarBaseProxy, ICo this.componentPoolsRegistry = componentPoolsRegistry; } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - public void Dispose() { //ignore diff --git a/Explorer/Assets/DCL/PluginSystem/World/AvatarShapePlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/AvatarShapePlugin.cs index 4d7e71220a..5cc1a8ce93 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/AvatarShapePlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/AvatarShapePlugin.cs @@ -1,13 +1,10 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.ECSComponents; using DCL.PluginSystem.World.Dependencies; -using DCL.Utilities; using ECS.LifeCycle; using ECS.LifeCycle.Systems; using ECS.Unity.AvatarShape.Systems; using System.Collections.Generic; -using System.Threading; namespace DCL.PluginSystem.World { @@ -20,9 +17,6 @@ public AvatarShapePlugin(Arch.Core.World globalWorld) this.globalWorld = globalWorld; } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - public void Dispose() { //ignore diff --git a/Explorer/Assets/DCL/PluginSystem/World/BillboardPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/BillboardPlugin.cs index 1ad4942c94..c621fbd2cf 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/BillboardPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/BillboardPlugin.cs @@ -1,10 +1,8 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.CharacterCamera; using DCL.PluginSystem.World.Dependencies; using ECS.LifeCycle; using System.Collections.Generic; -using System.Threading; using BillboardSystem = DCL.Billboard.System.BillboardSystem; namespace DCL.PluginSystem.World @@ -23,11 +21,6 @@ public void Dispose() //ignore } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) - { - return UniTask.CompletedTask; - } - public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in ECSWorldInstanceSharedDependencies sharedDependencies, in PersistentEntities persistentEntities, List finalizeWorldSystems, List sceneIsCurrentListeners) { BillboardSystem.InjectToWorld(ref builder, cameraData); diff --git a/Explorer/Assets/DCL/PluginSystem/World/IDCLWorldPluginWithoutSettings.cs b/Explorer/Assets/DCL/PluginSystem/World/IDCLWorldPluginWithoutSettings.cs index c361815686..6504835d5c 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/IDCLWorldPluginWithoutSettings.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/IDCLWorldPluginWithoutSettings.cs @@ -6,17 +6,10 @@ namespace DCL.PluginSystem.World { public interface IDCLWorldPluginWithoutSettings : IDCLWorldPlugin { - UniTask IDCLPlugin.Initialize(IPluginSettingsContainer container, CancellationToken ct) => - - // Don't even try to retrieve empty settings - UniTask.CompletedTask; - void IDisposable.Dispose() { } UniTask IDCLPlugin.InitializeAsync(NoExposedPluginSettings settings, - CancellationToken ct) - { - return UniTask.CompletedTask; - } + CancellationToken ct) => + UniTask.CompletedTask; } } diff --git a/Explorer/Assets/DCL/PluginSystem/World/InputModifierPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/InputModifierPlugin.cs index 0a065d673d..b6ba272e2a 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/InputModifierPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/InputModifierPlugin.cs @@ -1,6 +1,5 @@ using Arch.Core; using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.ECSComponents; using DCL.PluginSystem.World.Dependencies; using DCL.SceneRestrictionBusController.SceneRestrictionBus; @@ -8,11 +7,10 @@ using ECS.LifeCycle; using ECS.LifeCycle.Systems; using System.Collections.Generic; -using System.Threading; namespace DCL.PluginSystem.World { - public class InputModifierPlugin: IDCLWorldPlugin + public class InputModifierPlugin : IDCLWorldPlugin { private readonly Arch.Core.World world; private readonly Entity playerEntity; @@ -30,8 +28,6 @@ public void Dispose() // Ignore for now } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => UniTask.CompletedTask; - public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in ECSWorldInstanceSharedDependencies sharedDependencies, in PersistentEntities persistentEntities, List finalizeWorldSystems, List sceneIsCurrentListeners) { diff --git a/Explorer/Assets/DCL/PluginSystem/World/MapPinPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/MapPinPlugin.cs index 3c94f0dbcf..6845749500 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/MapPinPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/MapPinPlugin.cs @@ -1,5 +1,4 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.ECSComponents; using DCL.FeatureFlags; using DCL.PluginSystem.World.Dependencies; @@ -7,7 +6,6 @@ using ECS.LifeCycle; using ECS.LifeCycle.Systems; using System.Collections.Generic; -using System.Threading; namespace DCL.PluginSystem.World { @@ -22,9 +20,6 @@ public MapPinPlugin(Arch.Core.World globalWorld, FeatureFlagsCache featureFlagsC this.featureFlagsCache = featureFlagsCache; } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in ECSWorldInstanceSharedDependencies sharedDependencies, in PersistentEntities persistentEntities, List finalizeWorldSystems, List sceneIsCurrentListeners) { //If the Map Pins feature is enabled or if it's a global PX we allow the Map Pins systems to run in them. diff --git a/Explorer/Assets/DCL/PluginSystem/World/MultiplayerPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/MultiplayerPlugin.cs index 9e317bc020..bbcfc051eb 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/MultiplayerPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/MultiplayerPlugin.cs @@ -1,13 +1,8 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; -using DCL.Multiplayer.SDK.Components; using DCL.Multiplayer.SDK.Systems.SceneWorld; using DCL.PluginSystem.World.Dependencies; -using DCL.Profiles; using ECS.LifeCycle; -using ECS.LifeCycle.Systems; using System.Collections.Generic; -using System.Threading; using WriteAvatarEmoteCommandSystem = DCL.Multiplayer.SDK.Systems.SceneWorld.WriteAvatarEmoteCommandSystem; using WriteAvatarEquippedDataSystem = DCL.Multiplayer.SDK.Systems.SceneWorld.WriteAvatarEquippedDataSystem; using WritePlayerIdentityDataSystem = DCL.Multiplayer.SDK.Systems.SceneWorld.WritePlayerIdentityDataSystem; @@ -17,9 +12,6 @@ namespace DCL.PluginSystem.World { public class MultiplayerPlugin : IDCLWorldPluginWithoutSettings { - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - public void Dispose() { //ignore diff --git a/Explorer/Assets/DCL/PluginSystem/World/RealmInfoPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/RealmInfoPlugin.cs index 6f2056fd1e..c7137851f8 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/RealmInfoPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/RealmInfoPlugin.cs @@ -1,5 +1,4 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.Multiplayer.Connections.RoomHubs; using DCL.PluginSystem.World.Dependencies; using DCL.SDKComponents.RealmInfo; @@ -7,7 +6,6 @@ using ECS; using ECS.LifeCycle; using System.Collections.Generic; -using System.Threading; namespace DCL.PluginSystem.World { @@ -22,9 +20,6 @@ public RealmInfoPlugin(IRealmData realmData, ObjectProxy roomHubProxy) this.roomHubProxy = roomHubProxy; } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - public void Dispose() { //ignore diff --git a/Explorer/Assets/DCL/PluginSystem/World/TexturesLoadingPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/TexturesLoadingPlugin.cs index c777dd7aad..d13be0ede7 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/TexturesLoadingPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/TexturesLoadingPlugin.cs @@ -34,14 +34,9 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder builder, LoadGlobalTextureSystem.InjectToWorld(ref builder, texturesCache, webRequestController); } -#region Interface Ambiguity - UniTask IDCLPlugin.Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - UniTask IDCLPlugin.InitializeAsync(NoExposedPluginSettings settings, CancellationToken ct) => UniTask.CompletedTask; void IDisposable.Dispose() { } -#endregion } } diff --git a/Explorer/Assets/DCL/PluginSystem/World/TweenPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/TweenPlugin.cs index f66ece334e..6e5c2a2054 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/TweenPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/TweenPlugin.cs @@ -1,15 +1,11 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.ECSComponents; using DCL.PluginSystem.World.Dependencies; using DCL.SDKComponents.Tween.Systems; using ECS.LifeCycle; using ECS.LifeCycle.Systems; using System.Collections.Generic; -using System.Threading; using DCL.SDKComponents.Tween.Components; -using SceneRunner.Scene; -using UnityEngine.Pool; namespace DCL.PluginSystem.World { @@ -22,9 +18,6 @@ public TweenPlugin() tweenerPool = new TweenerPool(); } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in ECSWorldInstanceSharedDependencies sharedDependencies, in PersistentEntities persistentEntities, List finalizeWorldSystems, List sceneIsCurrentListeners) { ResetDirtyFlagSystem.InjectToWorld(ref builder); diff --git a/Explorer/Assets/DCL/Roads/Systems/RoadPlugin.cs b/Explorer/Assets/DCL/Roads/Systems/RoadPlugin.cs index 33f3cac62d..ef4c5b5db4 100644 --- a/Explorer/Assets/DCL/Roads/Systems/RoadPlugin.cs +++ b/Explorer/Assets/DCL/Roads/Systems/RoadPlugin.cs @@ -1,13 +1,9 @@ using System.Collections.Generic; -using System.Threading; using Arch.Core; using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.LOD; using DCL.Optimization.PerformanceBudgeting; -using DCL.PluginSystem; using DCL.PluginSystem.Global; -using DCL.ResourcesUnloading; using DCL.Roads.Settings; using ECS.SceneLifeCycle; using ECS.SceneLifeCycle.Reporting; @@ -37,9 +33,6 @@ public RoadPlugin(IPerformanceBudget frameCapBudget, IPerformanceBudget memoryBu this.roadAssetPool = roadAssetPool; } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in GlobalPluginArguments arguments) { RoadInstantiatorSystem.InjectToWorld(ref builder, frameCapBudget, memoryBudget, roadDataDictionary, roadAssetPool, sceneReadinessReportQueue, scenesCache); diff --git a/Explorer/Assets/DCL/WebRequests/Analytics/Plugin/WebRequestsPlugin.cs b/Explorer/Assets/DCL/WebRequests/Analytics/Plugin/WebRequestsPlugin.cs index b462de48f2..630af1eb21 100644 --- a/Explorer/Assets/DCL/WebRequests/Analytics/Plugin/WebRequestsPlugin.cs +++ b/Explorer/Assets/DCL/WebRequests/Analytics/Plugin/WebRequestsPlugin.cs @@ -1,10 +1,7 @@ using Arch.Core; using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.DebugUtilities; -using DCL.PluginSystem; using DCL.PluginSystem.Global; -using System.Threading; namespace DCL.WebRequests.Analytics { @@ -19,9 +16,6 @@ public WebRequestsPlugin(IWebRequestsAnalyticsContainer analyticsContainer, IDeb this.debugContainerBuilder = debugContainerBuilder; } - public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) => - UniTask.CompletedTask; - public void Dispose() { } public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in GlobalPluginArguments arguments) diff --git a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs index a7ef9c2f38..50610d8a2c 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs @@ -60,7 +60,6 @@ using DCL.Profiles; using DCL.Profiles.Self; using DCL.SceneLoadingScreens.LoadingScreen; -using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SidebarBus; using DCL.UI.MainUI; using DCL.StylizedSkybox.Scripts.Plugin; @@ -82,13 +81,11 @@ using LiveKit.Proto; using MVC; using MVC.PopupsController.PopupCloser; -using PortableExperiences.Controller; using SceneRunner.Debugging.Hub; using System; using System.Buffers; using System.Collections.Generic; using System.Linq; -using System.Text.RegularExpressions; using System.Threading; using UnityEngine; using UnityEngine.Audio; @@ -103,51 +100,60 @@ namespace Global.Dynamic { public class DynamicWorldContainer : DCLWorldContainer { - private ECSReloadScene? reloadSceneController; - private LocalSceneDevelopmentController? localSceneDevelopmentController; - private IWearablesProvider? wearablesProvider; + private readonly LocalSceneDevelopmentController? localSceneDevelopmentController; + private readonly IChatMessagesBus chatMessagesBus; + private readonly IProfileBroadcast profileBroadcast; - private MultiplayerMovementMessageBus? multiplayerMovementMessageBus; + public IMVCManager MvcManager { get; } - public IMVCManager MvcManager { get; private set; } = null!; + public IGlobalRealmController RealmController { get; } - public DefaultTexturesContainer DefaultTexturesContainer { get; private set; } = null!; + public GlobalWorldFactory GlobalWorldFactory { get; } - public LODContainer LODContainer { get; private set; } = null!; + public IReadOnlyList GlobalPlugins { get; } - public MapRendererContainer MapRendererContainer { get; private set; } = null!; + public IProfileRepository ProfileRepository { get; } - public IGlobalRealmController RealmController { get; private set; } = null!; + public RealUserInAppInitializationFlow UserInAppInAppInitializationFlow { get; } - public GlobalWorldFactory GlobalWorldFactory { get; private set; } = null!; + public IMessagePipesHub MessagePipesHub { get; } - public IReadOnlyList GlobalPlugins { get; private set; } = null!; + public IRemoteMetadata RemoteMetadata { get; } - public IProfileRepository ProfileRepository { get; private set; } = null!; + public IRoomHub RoomHub { get; } - public ParcelServiceContainer ParcelServiceContainer { get; private set; } = null!; - - public RealUserInAppInitializationFlow UserInAppInAppInitializationFlow { get; private set; } = null!; - - // TODO move multiplayer related dependencies to a separate container - public ICharacterDataPropagationUtility CharacterDataPropagationUtility { get; private set; } = null!; - - public IChatMessagesBus ChatMessagesBus { get; private set; } = null!; - - public IMessagePipesHub MessagePipesHub { get; private set; } = null!; - - public IRemoteMetadata RemoteMetadata { get; private set; } = null!; - - public ISceneRoomMetaDataSource SceneRoomMetaDataSource { get; private set; } = null!; - - public IProfileBroadcast ProfileBroadcast { get; private set; } = null!; - - public IRoomHub RoomHub { get; private set; } = null!; + private DynamicWorldContainer( + LocalSceneDevelopmentController? localSceneDevelopmentController, + IMVCManager mvcManager, + IGlobalRealmController realmController, + GlobalWorldFactory globalWorldFactory, + IReadOnlyList globalPlugins, + IProfileRepository profileRepository, + RealUserInAppInitializationFlow userInAppInAppInitializationFlow, + IChatMessagesBus chatMessagesBus, + IMessagePipesHub messagePipesHub, + IRemoteMetadata remoteMetadata, + IProfileBroadcast profileBroadcast, + IRoomHub roomHub) + { + MvcManager = mvcManager; + RealmController = realmController; + GlobalWorldFactory = globalWorldFactory; + GlobalPlugins = globalPlugins; + ProfileRepository = profileRepository; + UserInAppInAppInitializationFlow = userInAppInAppInitializationFlow; + MessagePipesHub = messagePipesHub; + RemoteMetadata = remoteMetadata; + RoomHub = roomHub; + this.localSceneDevelopmentController = localSceneDevelopmentController; + this.chatMessagesBus = chatMessagesBus; + this.profileBroadcast = profileBroadcast; + } public override void Dispose() { - ChatMessagesBus.Dispose(); - ProfileBroadcast.Dispose(); + chatMessagesBus.Dispose(); + profileBroadcast.Dispose(); MessagePipesHub.Dispose(); localSceneDevelopmentController?.Dispose(); } @@ -163,7 +169,6 @@ public override void Dispose() ICoroutineRunner coroutineRunner, CancellationToken ct) { - var container = new DynamicWorldContainer(); DynamicSettings dynamicSettings = dynamicWorldDependencies.DynamicSettings; StaticContainer staticContainer = dynamicWorldDependencies.StaticContainer; IWeb3IdentityCache identityCache = dynamicWorldDependencies.Web3IdentityCache; @@ -179,15 +184,49 @@ public override void Dispose() var mapPathEventBus = new MapPathEventBus(); INotificationsBusController notificationsBusController = new NotificationsBusController(); + DefaultTexturesContainer defaultTexturesContainer = null!; + LODContainer lodContainer = null!; + MapRendererContainer mapRendererContainer = null!; + async UniTask InitializeContainersAsync(IPluginSettingsContainer settingsContainer, CancellationToken ct) { - // Init itself - await settingsContainer.InitializePluginAsync(container, ct)!.ThrowOnFail(); - // Init other containers - container.DefaultTexturesContainer = await DefaultTexturesContainer.CreateAsync(settingsContainer, assetsProvisioner, ct).ThrowOnFail(); - container.LODContainer = await LODContainer.CreateAsync(assetsProvisioner, bootstrapContainer.DecentralandUrlsSource, staticContainer, settingsContainer, staticContainer.RealmData, container.DefaultTexturesContainer.TextureArrayContainerFactory, debugBuilder, dynamicWorldParams.EnableLOD, ct).ThrowOnFail(); - container.MapRendererContainer = await MapRendererContainer.CreateAsync(settingsContainer, staticContainer, bootstrapContainer.DecentralandUrlsSource, assetsProvisioner, placesAPIService, mapPathEventBus, notificationsBusController, ct); + defaultTexturesContainer = + await DefaultTexturesContainer + .CreateAsync( + settingsContainer, + assetsProvisioner, + ct + ) + .ThrowOnFail(); + + lodContainer = + await LODContainer + .CreateAsync( + assetsProvisioner, + bootstrapContainer.DecentralandUrlsSource, + staticContainer, + settingsContainer, + staticContainer.RealmData, + defaultTexturesContainer.TextureArrayContainerFactory, + debugBuilder, + dynamicWorldParams.EnableLOD, + ct + ) + .ThrowOnFail(); + + mapRendererContainer = + await MapRendererContainer + .CreateAsync( + settingsContainer, + staticContainer, + bootstrapContainer.DecentralandUrlsSource, + assetsProvisioner, + placesAPIService, + mapPathEventBus, + notificationsBusController, + ct + ); } try { await InitializeContainersAsync(dynamicWorldDependencies.SettingsContainer, ct); } @@ -214,15 +253,14 @@ async UniTask InitializeContainersAsync(IPluginSettingsContainer settingsContain var coreMvcManager = new MVCManager(new WindowStackManager(), new CancellationTokenSource(), popupCloserView); - container.MvcManager = dynamicWorldParams.EnableAnalytics + IMVCManager mvcManager = dynamicWorldParams.EnableAnalytics ? new MVCManagerAnalyticsDecorator(coreMvcManager, bootstrapContainer.Analytics!) : coreMvcManager; var loadingScreenTimeout = new LoadingScreenTimeout(); - ILoadingScreen loadingScreen = new LoadingScreen(container.MvcManager, loadingScreenTimeout); + ILoadingScreen loadingScreen = new LoadingScreen(mvcManager, loadingScreenTimeout); var parcelServiceContainer = ParcelServiceContainer.Create(staticContainer.RealmData, staticContainer.SceneReadinessReportQueue, debugBuilder, loadingScreenTimeout, loadingScreen, staticContainer.SingletonSharedDependencies.SceneAssetLock); - container.ParcelServiceContainer = parcelServiceContainer; var nftInfoAPIClient = new OpenSeaAPIClient(staticContainer.WebRequestsContainer.WebRequestController, bootstrapContainer.DecentralandUrlsSource); var wearableCatalog = new WearableStorage(); @@ -233,7 +271,7 @@ async UniTask InitializeContainersAsync(IPluginSettingsContainer settingsContain IProfileCache profileCache = new DefaultProfileCache(); - container.ProfileRepository = new LogProfileRepository( + var profileRepository = new LogProfileRepository( new RealmProfileRepository(staticContainer.WebRequestsContainer.WebRequestController, staticContainer.RealmData, profileCache) ); @@ -242,11 +280,11 @@ async UniTask InitializeContainersAsync(IPluginSettingsContainer settingsContain var satelliteView = new SatelliteFloor(); var landscapePlugin = new LandscapePlugin(satelliteView, genesisTerrain, worldsTerrain, assetsProvisioner, - debugBuilder, container.MapRendererContainer.TextureContainer, + debugBuilder, mapRendererContainer.TextureContainer, staticContainer.WebRequestsContainer.WebRequestController, dynamicWorldParams.EnableLandscape, bootstrapContainer.Environment.Equals(DecentralandEnvironment.Zone)); - IMultiPool MultiPoolFactory() => + static IMultiPool MultiPoolFactory() => new DCLMultiPool(); var memoryPool = new ArrayMemoryPool(ArrayPool.Shared!); @@ -263,18 +301,18 @@ IMultiPool MultiPoolFactory() => ParseParamsForcedEmotes(bootstrapContainer.ApplicationParametersParser, ref selfEmotes); ParseDebugForcedEmotes(bootstrapContainer.DebugSettings.EmotesToAddToUserProfile, ref selfEmotes); - var selfProfile = new SelfProfile(container.ProfileRepository, identityCache, equippedWearables, wearableCatalog, + var selfProfile = new SelfProfile(profileRepository, identityCache, equippedWearables, wearableCatalog, emotesCache, equippedEmotes, forceRender, selfEmotes); IEmoteProvider emoteProvider = new ApplicationParamsEmoteProvider(appArgs, new EcsEmoteProvider(globalWorld, staticContainer.RealmData)); - container.wearablesProvider = new ApplicationParametersWearablesProvider(appArgs, + var wearablesProvider = new ApplicationParametersWearablesProvider(appArgs, new ECSWearablesProvider(identityCache, globalWorld)); bool localSceneDevelopment = !string.IsNullOrEmpty(dynamicWorldParams.LocalSceneDevelopmentRealm); - container.RealmController = new RealmController( + var realmController = new RealmController( identityCache, staticContainer.WebRequestsContainer.WebRequestController, parcelServiceContainer.TeleportController, @@ -291,9 +329,9 @@ IMultiPool MultiPoolFactory() => localSceneDevelopment ); - container.SceneRoomMetaDataSource = new SceneRoomMetaDataSource(container.RealmController, staticContainer.CharacterContainer.Transform, globalWorld, dynamicWorldParams.IsolateScenesCommunication); + var sceneRoomMetaDataSource = new SceneRoomMetaDataSource(realmController, staticContainer.CharacterContainer.Transform, globalWorld, dynamicWorldParams.IsolateScenesCommunication); - var metaDataSource = new SceneRoomLogMetaDataSource(container.SceneRoomMetaDataSource); + var metaDataSource = new SceneRoomLogMetaDataSource(sceneRoomMetaDataSource); IGateKeeperSceneRoom gateKeeperSceneRoom = new GateKeeperSceneRoom(staticContainer.WebRequestsContainer.WebRequestController, metaDataSource, bootstrapContainer.DecentralandUrlsSource, staticContainer.ScenesCache) .AsActivatable(); @@ -308,16 +346,15 @@ IMultiPool MultiPoolFactory() => staticContainer.WebRequestsContainer.WebRequestController ); - container.reloadSceneController = new ECSReloadScene(staticContainer.ScenesCache, globalWorld, playerEntity, localSceneDevelopment); + var reloadSceneController = new ECSReloadScene(staticContainer.ScenesCache, globalWorld, playerEntity, localSceneDevelopment); - if (localSceneDevelopment) - container.localSceneDevelopmentController = new LocalSceneDevelopmentController(container.reloadSceneController, dynamicWorldParams.LocalSceneDevelopmentRealm); + var localSceneDevelopmentController = localSceneDevelopment ? new LocalSceneDevelopmentController(reloadSceneController, dynamicWorldParams.LocalSceneDevelopmentRealm) : null; - container.RoomHub = localSceneDevelopment ? NullRoomHub.INSTANCE : new RoomHub(archipelagoIslandRoom, gateKeeperSceneRoom); - container.MessagePipesHub = new MessagePipesHub(container.RoomHub, MultiPoolFactory(), MultiPoolFactory(), memoryPool); + IRoomHub roomHub = localSceneDevelopment ? NullRoomHub.INSTANCE : new RoomHub(archipelagoIslandRoom, gateKeeperSceneRoom); + var messagePipesHub = new MessagePipesHub(roomHub, MultiPoolFactory(), MultiPoolFactory(), memoryPool); var roomsStatus = new RoomsStatus( - container.RoomHub, + roomHub, //override allowed only in Editor Application.isEditor @@ -335,7 +372,7 @@ IMultiPool MultiPoolFactory() => ); var remoteEntities = new RemoteEntities( - container.RoomHub, + roomHub, entityParticipantTable, staticContainer.ComponentsContainer.ComponentPoolsRegistry, queuePoolFullMovementMessage, @@ -343,7 +380,7 @@ IMultiPool MultiPoolFactory() => ); ILandscape landscape = new Landscape( - container.RealmController, + realmController, genesisTerrain, worldsTerrain, dynamicWorldParams.EnableLandscape, @@ -351,20 +388,20 @@ IMultiPool MultiPoolFactory() => ); var realmMisc = new RealmMisc( - container.MapRendererContainer.MapRenderer, - container.LODContainer.RoadAssetsPool, + mapRendererContainer.MapRenderer, + lodContainer.RoadAssetsPool, satelliteView ); IRealmNavigator baseRealmNavigator = new RealmNavigator( loadingScreen, - container.RealmController, + realmController, parcelServiceContainer.TeleportController, - container.RoomHub, + roomHub, remoteEntities, bootstrapContainer.DecentralandUrlsSource, globalWorld, - container.LODContainer.RoadAssetsPool, + lodContainer.RoadAssetsPool, staticContainer.ExposedGlobalDataContainer.ExposedCameraData.CameraEntityProxy, exposedGlobalDataContainer.CameraSamplingData, staticContainer.LoadingStatus, @@ -382,7 +419,7 @@ IMultiPool MultiPoolFactory() => DecentralandUrl.ArchipelagoStatus, DecentralandUrl.GatekeeperStatus ), - new StartLiveKitRooms(container.RoomHub) + new StartLiveKitRooms(roomHub) ); livekitHealthCheck = dynamicWorldParams.EnableAnalytics @@ -393,11 +430,11 @@ IMultiPool MultiPoolFactory() => var chatHistory = new ChatHistory(); - container.UserInAppInAppInitializationFlow = new RealUserInAppInitializationFlow( + var userInAppInAppInitializationFlow = new RealUserInAppInitializationFlow( staticContainer.LoadingStatus, livekitHealthCheck, bootstrapContainer.DecentralandUrlsSource, - container.MvcManager, + mvcManager, selfProfile, dynamicWorldParams.StartParcel, staticContainer.MainPlayerAvatarBaseProxy, @@ -407,13 +444,13 @@ IMultiPool MultiPoolFactory() => staticContainer.FeatureFlagsProvider, staticContainer.FeatureFlagsCache, identityCache, - container.RealmController, + realmController, realmMisc, landscape, dynamicWorldParams.AppParameters, bootstrapContainer.DebugSettings, staticContainer.PortableExperiencesController, - container.RoomHub, + roomHub, bootstrapContainer.Analytics.EnsureNotNull(), bootstrapContainer.DiagnosticsContainer, chatHistory @@ -421,7 +458,7 @@ IMultiPool MultiPoolFactory() => var realmNavigator = new MainScreenFallbackRealmNavigator( baseRealmNavigator, - container.UserInAppInAppInitializationFlow, + userInAppInAppInitializationFlow, playerEntity, globalWorld ); @@ -433,10 +470,10 @@ IMultiPool MultiPoolFactory() => dynamicWorldDependencies.WorldInfoTool.Initialize(worldInfoHub); - container.CharacterDataPropagationUtility = new CharacterDataPropagationUtility(staticContainer.ComponentsContainer.ComponentPoolsRegistry.AddComponentPool()); + var characterDataPropagationUtility = new CharacterDataPropagationUtility(staticContainer.ComponentsContainer.ComponentPoolsRegistry.AddComponentPool()); var currentSceneInfo = new CurrentSceneInfo(); - var connectionStatusPanelPlugin = new ConnectionStatusPanelPlugin(container.UserInAppInAppInitializationFlow, container.MvcManager, mainUIView, roomsStatus, currentSceneInfo, container.reloadSceneController, globalWorld, playerEntity, debugBuilder); + var connectionStatusPanelPlugin = new ConnectionStatusPanelPlugin(userInAppInAppInitializationFlow, mvcManager, mainUIView, roomsStatus, currentSceneInfo, reloadSceneController, globalWorld, playerEntity, debugBuilder); var chatCommands = new List { @@ -445,29 +482,29 @@ IMultiPool MultiPoolFactory() => new DebugPanelChatCommand(debugBuilder, connectionStatusPanelPlugin), new ShowEntityInfoChatCommand(worldInfoHub), new ClearChatCommand(chatHistory), - new ReloadSceneChatCommand(container.reloadSceneController), + new ReloadSceneChatCommand(reloadSceneController), new LoadPortableExperienceChatCommand(staticContainer.PortableExperiencesController, staticContainer.FeatureFlagsCache), new KillPortableExperienceChatCommand(staticContainer.PortableExperiencesController, staticContainer.FeatureFlagsCache), }; chatCommands.Add(new HelpChatCommand(chatCommands)); - IChatMessagesBus coreChatMessageBus = new MultiplayerChatMessagesBus(container.MessagePipesHub, container.ProfileRepository, new MessageDeduplication()) - .WithSelfResend(identityCache, container.ProfileRepository) + IChatMessagesBus coreChatMessageBus = new MultiplayerChatMessagesBus(messagePipesHub, profileRepository, new MessageDeduplication()) + .WithSelfResend(identityCache, profileRepository) .WithIgnoreSymbols() .WithCommands(chatCommands) .WithDebugPanel(debugBuilder); - IChatMessagesBus chatMessagesBus = container.ChatMessagesBus = dynamicWorldParams.EnableAnalytics + IChatMessagesBus chatMessagesBus = dynamicWorldParams.EnableAnalytics ? new ChatMessagesBusAnalyticsDecorator(coreChatMessageBus, bootstrapContainer.Analytics!) : coreChatMessageBus; var minimap = new MinimapController( mainUIView.MinimapView.EnsureNotNull(), - container.MapRendererContainer.MapRenderer, - container.MvcManager, + mapRendererContainer.MapRenderer, + mvcManager, placesAPIService, - container.RealmController, + realmController, chatMessagesBus, staticContainer.ScenesCache, mapPathEventBus, @@ -478,17 +515,15 @@ IMultiPool MultiPoolFactory() => // This is a lazy reference to avoid circular dependencies in DynamicWorldContainer, evil hack should be redesigned realmMisc.Inject(minimap); - var minimapPlugin = new MinimapPlugin(container.MvcManager, minimap); - var coreBackpackEventBus = new BackpackEventBus(); IBackpackEventBus backpackEventBus = dynamicWorldParams.EnableAnalytics ? new BackpackEventBusAnalyticsDecorator(coreBackpackEventBus, bootstrapContainer.Analytics!) : coreBackpackEventBus; - container.ProfileBroadcast = new DebounceProfileBroadcast( + var profileBroadcast = new DebounceProfileBroadcast( new EnsureSelfPublishedProfileBroadcast( - new ProfileBroadcast(container.MessagePipesHub, selfProfile), + new ProfileBroadcast(messagePipesHub, selfProfile), selfProfile, staticContainer.RealmData ) @@ -497,23 +532,23 @@ IMultiPool MultiPoolFactory() => var notificationsRequestController = new NotificationsRequestController(staticContainer.WebRequestsContainer.WebRequestController, notificationsBusController, bootstrapContainer.DecentralandUrlsSource, identityCache); notificationsRequestController.StartGettingNewNotificationsOverTimeAsync(ct).SuppressCancellationThrow().Forget(); - var multiplayerEmotesMessageBus = new MultiplayerEmotesMessageBus(container.MessagePipesHub, multiplayerDebugSettings); + var multiplayerEmotesMessageBus = new MultiplayerEmotesMessageBus(messagePipesHub, multiplayerDebugSettings); - container.RemoteMetadata = new DebounceRemoteMetadata(new RemoteMetadata(container.RoomHub, staticContainer.RealmData)); + var remoteMetadata = new DebounceRemoteMetadata(new RemoteMetadata(roomHub, staticContainer.RealmData)); var characterPreviewEventBus = new CharacterPreviewEventBus(); var sidebarBus = new SidebarBus(); AudioMixer generalAudioMixer = (await assetsProvisioner.ProvideMainAssetAsync(dynamicSettings.GeneralAudioMixer, ct)).Value; var audioMixerVolumesController = new AudioMixerVolumesController(generalAudioMixer); - container.multiplayerMovementMessageBus = new MultiplayerMovementMessageBus(container.MessagePipesHub, entityParticipantTable, globalWorld); + var multiplayerMovementMessageBus = new MultiplayerMovementMessageBus(messagePipesHub, entityParticipantTable, globalWorld); var badgesAPIClient = new BadgesAPIClient(staticContainer.WebRequestsContainer.WebRequestController, bootstrapContainer.DecentralandUrlsSource); ICameraReelImagesMetadataDatabase cameraReelImagesMetadataDatabase = new CameraReelImagesMetadataRemoteDatabase(staticContainer.WebRequestsContainer.WebRequestController, bootstrapContainer.DecentralandUrlsSource); ICameraReelScreenshotsStorage cameraReelScreenshotsStorage = new CameraReelS3BucketScreenshotsStorage(staticContainer.WebRequestsContainer.WebRequestController); - CameraReelRemoteStorageService cameraReelStorageService = new CameraReelRemoteStorageService(cameraReelImagesMetadataDatabase, cameraReelScreenshotsStorage, identityCache?.Identity?.Address); + CameraReelRemoteStorageService cameraReelStorageService = new CameraReelRemoteStorageService(cameraReelImagesMetadataDatabase, cameraReelScreenshotsStorage, identityCache.Identity?.Address); ISystemClipboard clipboard = new UnityClipboard(); @@ -525,31 +560,31 @@ IMultiPool MultiPoolFactory() => assetsProvisioner, archipelagoIslandRoom, gateKeeperSceneRoom, - container.RoomHub, + roomHub, roomsStatus, - container.ProfileRepository, - container.ProfileBroadcast, + profileRepository, + profileBroadcast, debugBuilder, staticContainer.LoadingStatus, entityParticipantTable, - container.MessagePipesHub, - container.RemoteMetadata, + messagePipesHub, + remoteMetadata, staticContainer.CharacterContainer.CharacterObject, staticContainer.RealmData, remoteEntities, staticContainer.ScenesCache, emotesCache, - container.CharacterDataPropagationUtility, + characterDataPropagationUtility, staticContainer.ComponentsContainer.ComponentPoolsRegistry ), new WorldInfoPlugin(worldInfoHub, debugBuilder, chatHistory), new CharacterMotionPlugin(assetsProvisioner, staticContainer.CharacterContainer.CharacterObject, debugBuilder, staticContainer.ComponentsContainer.ComponentPoolsRegistry, staticContainer.SceneReadinessReportQueue), - new InputPlugin(dclInput, dclCursor, unityEventSystem, assetsProvisioner, dynamicWorldDependencies.CursorUIDocument, multiplayerEmotesMessageBus, container.MvcManager, debugBuilder, dynamicWorldDependencies.RootUIDocument, dynamicWorldDependencies.CursorUIDocument, exposedGlobalDataContainer.ExposedCameraData), - new GlobalInteractionPlugin(dclInput, dynamicWorldDependencies.RootUIDocument, assetsProvisioner, staticContainer.EntityCollidersGlobalCache, exposedGlobalDataContainer.GlobalInputEvents, dclCursor, unityEventSystem, container.MvcManager), + new InputPlugin(dclInput, dclCursor, unityEventSystem, assetsProvisioner, dynamicWorldDependencies.CursorUIDocument, multiplayerEmotesMessageBus, mvcManager, debugBuilder, dynamicWorldDependencies.RootUIDocument, dynamicWorldDependencies.CursorUIDocument, exposedGlobalDataContainer.ExposedCameraData), + new GlobalInteractionPlugin(dclInput, dynamicWorldDependencies.RootUIDocument, assetsProvisioner, staticContainer.EntityCollidersGlobalCache, exposedGlobalDataContainer.GlobalInputEvents, dclCursor, unityEventSystem, mvcManager), new CharacterCameraPlugin(assetsProvisioner, realmSamplingData, exposedGlobalDataContainer.ExposedCameraData, debugBuilder, dynamicWorldDependencies.CommandLineArgs, dclInput), new WearablePlugin(assetsProvisioner, staticContainer.WebRequestsContainer.WebRequestController, staticContainer.RealmData, assetBundlesURL, staticContainer.CacheCleaner, wearableCatalog), new EmotePlugin(staticContainer.WebRequestsContainer.WebRequestController, emotesCache, staticContainer.RealmData, multiplayerEmotesMessageBus, debugBuilder, - assetsProvisioner, selfProfile, container.MvcManager, dclInput, staticContainer.CacheCleaner, identityCache, entityParticipantTable, assetBundlesURL, mainUIView, dclCursor, staticContainer.InputBlock, globalWorld, playerEntity), + assetsProvisioner, selfProfile, mvcManager, dclInput, staticContainer.CacheCleaner, identityCache, entityParticipantTable, assetBundlesURL, mainUIView, dclCursor, staticContainer.InputBlock, globalWorld, playerEntity), new ProfilingPlugin(staticContainer.Profiler, staticContainer.RealmData, staticContainer.SingletonSharedDependencies.MemoryBudget, debugBuilder, staticContainer.ScenesCache), new AvatarPlugin( staticContainer.ComponentsContainer.ComponentPoolsRegistry, @@ -563,35 +598,35 @@ IMultiPool MultiPoolFactory() => chatEntryConfiguration, new DefaultFaceFeaturesHandler(wearableCatalog), nametagsData, - container.DefaultTexturesContainer.TextureArrayContainerFactory, + defaultTexturesContainer.TextureArrayContainerFactory, wearableCatalog, remoteEntities, staticContainer.CharacterContainer.Transform), - new MainUIPlugin(container.MvcManager, sidebarBus, mainUIView), - new ProfilePlugin(container.ProfileRepository, profileCache, staticContainer.CacheCleaner, new ProfileIntentionCache()), - new MapRendererPlugin(container.MapRendererContainer.MapRenderer), + new MainUIPlugin(mvcManager, sidebarBus, mainUIView), + new ProfilePlugin(profileRepository, profileCache, staticContainer.CacheCleaner, new ProfileIntentionCache()), + new MapRendererPlugin(mapRendererContainer.MapRenderer), new SidebarPlugin( assetsProvisioner, - container.MvcManager, + mvcManager, mainUIView, notificationsBusController, notificationsRequestController, identityCache, - container.ProfileRepository, + profileRepository, staticContainer.WebRequestsContainer.WebRequestController, webBrowser, dynamicWorldDependencies.Web3Authenticator, - container.UserInAppInAppInitializationFlow, + userInAppInAppInitializationFlow, profileCache, sidebarBus, chatEntryConfiguration, globalWorld, playerEntity, includeCameraReel), - new ErrorPopupPlugin(container.MvcManager, assetsProvisioner), + new ErrorPopupPlugin(mvcManager, assetsProvisioner), connectionStatusPanelPlugin, - minimapPlugin, - new ChatPlugin(assetsProvisioner, container.MvcManager, container.ChatMessagesBus, chatHistory, entityParticipantTable, nametagsData, dclInput, unityEventSystem, mainUIView, staticContainer.InputBlock, globalWorld, playerEntity), + new MinimapPlugin(mvcManager, minimap), + new ChatPlugin(assetsProvisioner, mvcManager, chatMessagesBus, chatHistory, entityParticipantTable, nametagsData, dclInput, unityEventSystem, mainUIView, staticContainer.InputBlock, globalWorld, playerEntity), new ExplorePanelPlugin( assetsProvisioner, - container.MvcManager, - container.MapRendererContainer, + mvcManager, + mapRendererContainer, placesAPIService, staticContainer.WebRequestsContainer.WebRequestController, identityCache, @@ -601,9 +636,9 @@ IMultiPool MultiPoolFactory() => bootstrapContainer.DecentralandUrlsSource, wearableCatalog, characterPreviewFactory, - container.ProfileRepository, + profileRepository, dynamicWorldDependencies.Web3Authenticator, - container.UserInAppInAppInitializationFlow, + userInAppInAppInitializationFlow, selfProfile, equippedWearables, equippedEmotes, @@ -621,44 +656,44 @@ IMultiPool MultiPoolFactory() => chatEntryConfiguration, backpackEventBus, thirdPartyNftProviderSource, - container.wearablesProvider, + wearablesProvider, dclCursor, staticContainer.InputBlock, emoteProvider, globalWorld, playerEntity, - container.ChatMessagesBus, + chatMessagesBus, staticContainer.MemoryCap, bootstrapContainer.WorldVolumeMacBus, includeCameraReel ), new CharacterPreviewPlugin(staticContainer.ComponentsContainer.ComponentPoolsRegistry, assetsProvisioner, staticContainer.CacheCleaner), new WebRequestsPlugin(staticContainer.WebRequestsContainer.AnalyticsContainer, debugBuilder), - new Web3AuthenticationPlugin(assetsProvisioner, dynamicWorldDependencies.Web3Authenticator, debugBuilder, container.MvcManager, selfProfile, webBrowser, staticContainer.RealmData, identityCache, characterPreviewFactory, dynamicWorldDependencies.SplashScreen, audioMixerVolumesController, staticContainer.FeatureFlagsCache, characterPreviewEventBus, globalWorld), + new Web3AuthenticationPlugin(assetsProvisioner, dynamicWorldDependencies.Web3Authenticator, debugBuilder, mvcManager, selfProfile, webBrowser, staticContainer.RealmData, identityCache, characterPreviewFactory, dynamicWorldDependencies.SplashScreen, audioMixerVolumesController, staticContainer.FeatureFlagsCache, characterPreviewEventBus, globalWorld), new StylizedSkyboxPlugin(assetsProvisioner, dynamicSettings.DirectionalLight, debugBuilder, staticContainer.FeatureFlagsCache), - new LoadingScreenPlugin(assetsProvisioner, container.MvcManager, audioMixerVolumesController, + new LoadingScreenPlugin(assetsProvisioner, mvcManager, audioMixerVolumesController, staticContainer.InputBlock, debugBuilder, staticContainer.LoadingStatus), - new ExternalUrlPromptPlugin(assetsProvisioner, webBrowser, container.MvcManager, dclCursor), + new ExternalUrlPromptPlugin(assetsProvisioner, webBrowser, mvcManager, dclCursor), new TeleportPromptPlugin( assetsProvisioner, - container.MvcManager, + mvcManager, staticContainer.WebRequestsContainer.WebRequestController, placesAPIService, dclCursor, - container.ChatMessagesBus + chatMessagesBus ), new ChangeRealmPromptPlugin( assetsProvisioner, - container.MvcManager, + mvcManager, dclCursor, - realmUrl => container.ChatMessagesBus.Send($"/{ChatCommandsUtils.COMMAND_GOTO} {realmUrl}", "RestrictedActionAPI")), - new NftPromptPlugin(assetsProvisioner, webBrowser, container.MvcManager, nftInfoAPIClient, staticContainer.WebRequestsContainer.WebRequestController, dclCursor), + realmUrl => chatMessagesBus.Send($"/{ChatCommandsUtils.COMMAND_GOTO} {realmUrl}", "RestrictedActionAPI")), + new NftPromptPlugin(assetsProvisioner, webBrowser, mvcManager, nftInfoAPIClient, staticContainer.WebRequestsContainer.WebRequestController, dclCursor), staticContainer.CharacterContainer.CreateGlobalPlugin(), staticContainer.QualityContainer.CreatePlugin(), landscapePlugin, new MultiplayerMovementPlugin( assetsProvisioner, - container.multiplayerMovementMessageBus, + multiplayerMovementMessageBus, debugBuilder, remoteEntities, staticContainer.CharacterContainer.Transform, @@ -666,23 +701,23 @@ IMultiPool MultiPoolFactory() => appArgs, entityParticipantTable, staticContainer.RealmData, - container.RemoteMetadata, + remoteMetadata, staticContainer.FeatureFlagsCache), - container.LODContainer.LODPlugin, - container.LODContainer.RoadPlugin, + lodContainer.LODPlugin, + lodContainer.RoadPlugin, new AudioPlaybackPlugin(genesisTerrain, assetsProvisioner, dynamicWorldParams.EnableLandscape), new RealmDataDirtyFlagPlugin(staticContainer.RealmData), new NotificationPlugin( assetsProvisioner, - container.MvcManager, + mvcManager, staticContainer.WebRequestsContainer.WebRequestController, notificationsBusController), - new RewardPanelPlugin(container.MvcManager, assetsProvisioner, notificationsBusController, staticContainer.WebRequestsContainer.WebRequestController), + new RewardPanelPlugin(mvcManager, assetsProvisioner, notificationsBusController, staticContainer.WebRequestsContainer.WebRequestController), new PassportPlugin( assetsProvisioner, - container.MvcManager, + mvcManager, dclCursor, - container.ProfileRepository, + profileRepository, characterPreviewFactory, chatEntryConfiguration, staticContainer.RealmData, @@ -695,7 +730,7 @@ IMultiPool MultiPoolFactory() => badgesAPIClient, notificationsBusController, staticContainer.InputBlock, - container.RemoteMetadata, + remoteMetadata, cameraReelStorageService, cameraReelStorageService, globalWorld, @@ -717,19 +752,19 @@ IMultiPool MultiPoolFactory() => coroutineRunner, cameraReelStorageService, cameraReelStorageService, - container.MvcManager, + mvcManager, clipboard, bootstrapContainer.DecentralandUrlsSource, webBrowser, staticContainer.WebRequestsContainer.WebRequestController, - container.ProfileRepository, + profileRepository, realmNavigator, assetsProvisioner, wearableCatalog, - container.wearablesProvider, + wearablesProvider, assetBundlesURL, dclCursor, - mainUIView.SidebarView.InWorldCameraButton, + mainUIView.SidebarView.EnsureNotNull().InWorldCameraButton, globalWorld, debugBuilder)); @@ -746,7 +781,7 @@ IMultiPool MultiPoolFactory() => ) ); - container.GlobalWorldFactory = new GlobalWorldFactory( + var globalWorldFactory = new GlobalWorldFactory( in staticContainer, exposedGlobalDataContainer.CameraSamplingData, realmSamplingData, @@ -757,20 +792,37 @@ IMultiPool MultiPoolFactory() => staticContainer.ScenesCache, dynamicWorldParams.HybridSceneParams, currentSceneInfo, - container.LODContainer.LodCache, + lodContainer.LodCache, multiplayerEmotesMessageBus, globalWorld, staticContainer.SceneReadinessReportQueue, localSceneDevelopment ); - container.GlobalPlugins = globalPlugins; + staticContainer.RoomHubProxy.SetObject(roomHub); + + var container = new DynamicWorldContainer( + localSceneDevelopmentController, + mvcManager, + realmController, + globalWorldFactory, + globalPlugins, + profileRepository, + userInAppInAppInitializationFlow, + chatMessagesBus, + messagePipesHub, + remoteMetadata, + profileBroadcast, + roomHub + ); + + // Init itself + await dynamicWorldDependencies.SettingsContainer.InitializePluginAsync(container, ct)!.ThrowOnFail(); - staticContainer.RoomHubProxy.SetObject(container.RoomHub); return (container, true); } - private static void ParseDebugForcedEmotes(IReadOnlyList? debugEmotes, ref List parsedEmotes) + private static void ParseDebugForcedEmotes(IReadOnlyCollection? debugEmotes, ref List parsedEmotes) { if (debugEmotes?.Count > 0) parsedEmotes.AddRange(debugEmotes.Select(emote => new URN(emote))); @@ -778,8 +830,8 @@ private static void ParseDebugForcedEmotes(IReadOnlyList? debugEmotes, r private static void ParseParamsForcedEmotes(IAppArgs appParams, ref List parsedEmotes) { - if (appParams.TryGetValue(AppArgsFlags.FORCED_EMOTES, out string? csv) && !string.IsNullOrEmpty(csv)) - parsedEmotes.AddRange(csv.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(emote => new URN(emote))); + if (appParams.TryGetValue(AppArgsFlags.FORCED_EMOTES, out string? csv) && !string.IsNullOrEmpty(csv!)) + parsedEmotes.AddRange(csv.Split(',', StringSplitOptions.RemoveEmptyEntries)?.Select(emote => new URN(emote)) ?? ArraySegment.Empty); } } }