Skip to content

Commit

Permalink
resolve DynamicWorldContainer (#3022)
Browse files Browse the repository at this point in the history
* resolve DynamicWorldContainer

* fix merge

* fix dependencies
  • Loading branch information
NickKhalow authored Dec 20, 2024
1 parent ad579eb commit 8514b27
Show file tree
Hide file tree
Showing 27 changed files with 252 additions and 278 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CameraReelRemoteStorageService : ICameraReelStorageService, ICamera

public event Action<CameraReelResponse, CameraReelStorageStatus, string>? ScreenshotUploaded;

public CameraReelRemoteStorageService(ICameraReelImagesMetadataDatabase imagesMetadataDatabase, ICameraReelScreenshotsStorage screenshotsStorage, string userAddress)
public CameraReelRemoteStorageService(ICameraReelImagesMetadataDatabase imagesMetadataDatabase, ICameraReelScreenshotsStorage screenshotsStorage, string? userAddress)
{
this.imagesMetadataDatabase = imagesMetadataDatabase;
this.screenshotsStorage = screenshotsStorage;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-nullable:enable

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 5 additions & 16 deletions Explorer/Assets/DCL/LOD/Systems/LODPlugin.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -39,7 +36,6 @@ public class LODPlugin : IDCLGlobalPlugin
private TextureArrayContainer lodTextureArrayContainer;
private readonly CacheCleaner cacheCleaner;


private readonly ILODCache lodCache;
private readonly IComponentPool<LODGroup> lodGroupPool;

Expand All @@ -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<LODGroup> lodGroupPool, IDecentralandUrlsSource decentralandUrlsSource,Transform lodCacheParent, bool lodEnabled, int lodLevels)
ILODCache lodCache, IComponentPool<LODGroup> lodGroupPool, IDecentralandUrlsSource decentralandUrlsSource, Transform lodCacheParent, bool lodEnabled,
int lodLevels)
{
this.realmData = realmData;
this.decentralandUrlsSource = decentralandUrlsSource;
Expand All @@ -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<Arch.Core.World> 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()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -68,8 +65,5 @@ public void Dispose()
{
walkedDistanceAnalytics.Dispose();
}

public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) =>
UniTask.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@ namespace DCL.PluginSystem.Global
{
public interface IDCLGlobalPluginWithoutSettings : IDCLGlobalPlugin<NoExposedPluginSettings>
{
UniTask IDCLPlugin.Initialize(IPluginSettingsContainer container, CancellationToken ct) =>

// Don't even try to retrieve empty settings
UniTask.CompletedTask;

void IDisposable.Dispose() { }

UniTask IDCLPlugin<NoExposedPluginSettings>.InitializeAsync(NoExposedPluginSettings settings,
CancellationToken ct)
{
return UniTask.CompletedTask;
}
UniTask IDCLPlugin<NoExposedPluginSettings>.InitializeAsync(NoExposedPluginSettings settings, CancellationToken ct) =>
UniTask.CompletedTask;
}
}
1 change: 0 additions & 1 deletion Explorer/Assets/DCL/PluginSystem/Global/ProfilePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using ECS.LifeCycle.Systems;
using ECS.StreamableLoading.Cache;
using System.Threading;
using Utility.Multithreading;

namespace DCL.PluginSystem.Global
{
Expand Down
30 changes: 22 additions & 8 deletions Explorer/Assets/DCL/PluginSystem/IDCLPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>
/// Represents a plugin that can be injected into the ECS world
/// </summary>
public interface IDCLPlugin<in T> : IDCLPlugin where T: IDCLPluginSettings, new()
public interface IDCLPlugin<in T> : IDCLPluginWithSettings where T: IDCLPluginSettings, new()
{
UniTask IDCLPlugin.Initialize(IPluginSettingsContainer container, CancellationToken ct)
{
var settings = container.GetSettings<T>();
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);
}
Expand Down
7 changes: 6 additions & 1 deletion Explorer/Assets/DCL/PluginSystem/IPluginSettingsContainer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;

namespace DCL.PluginSystem
{
/// <summary>
Expand All @@ -8,6 +10,9 @@ public interface IPluginSettingsContainer
/// <summary>
/// Get a typed settings object or throw an exception if it doesn't exist
/// </summary>
T GetSettings<T>() where T: IDCLPluginSettings;
T GetSettings<T>() where T: IDCLPluginSettings =>
(T)GetSettings(typeof(T));

object GetSettings(Type type);
}
}
5 changes: 4 additions & 1 deletion Explorer/Assets/DCL/PluginSystem/NoExposedPluginSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ namespace DCL.PluginSystem
/// <summary>
/// Indicates that plugin contains no serializable settings
/// </summary>
public class NoExposedPluginSettings : IDCLPluginSettings { }
public class NoExposedPluginSettings : IDCLPluginSettings
{
public static NoExposedPluginSettings Instance { get; } = new ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ namespace DCL.PluginSystem
{
public static class PluginContainerExtensions
{
public static async UniTask<(TPlugin plugin, bool success)> InitializePluginAsync<TPlugin>(this IPluginSettingsContainer pluginSettingsContainer, TPlugin plugin, CancellationToken ct) where TPlugin: class, IDCLPlugin
public static async UniTask<(TPlugin plugin, bool success)> InitializePluginAsync<TPlugin>(
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)
Expand Down
9 changes: 6 additions & 3 deletions Explorer/Assets/DCL/PluginSystem/PluginSettingsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ public class PluginSettingsContainer : ScriptableObject, IPluginSettingsContaine
// ReSharper disable once CollectionNeverUpdated.Global
[SerializeReference] [PluginSettingsTitle] internal List<IDCLPluginSettings> settings = new ();

public T GetSettings<T>() 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()
Expand Down
5 changes: 0 additions & 5 deletions Explorer/Assets/DCL/PluginSystem/World/AnimatorPlugin.cs
Original file line number Diff line number Diff line change
@@ -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<Arch.Core.World> builder, in ECSWorldInstanceSharedDependencies sharedDependencies, in PersistentEntities persistentEntities, List<IFinalizeWorldSystem> finalizeWorldSystems, List<ISceneIsCurrentListener> sceneIsCurrentListeners)
{
ResetDirtyFlagSystem<PBAnimator>.InjectToWorld(ref builder);
Expand Down
8 changes: 0 additions & 8 deletions Explorer/Assets/DCL/PluginSystem/World/AssetBundlesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using Utility.Multithreading;

namespace DCL.PluginSystem.World
{
Expand Down Expand Up @@ -61,19 +60,12 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder<Arch.Core.World> 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<NoExposedPluginSettings>.InitializeAsync(NoExposedPluginSettings settings, CancellationToken ct) =>
UniTask.CompletedTask;

void IDisposable.Dispose()
{
assetBundleCache.Dispose();
}
#endregion
}
}
5 changes: 0 additions & 5 deletions Explorer/Assets/DCL/PluginSystem/World/AvatarAttachPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Arch.SystemGroups;
using Cysharp.Threading.Tasks;
using DCL.AvatarRendering.AvatarShape.UnityInterface;
using DCL.ECSComponents;
using DCL.Optimization.Pools;
Expand All @@ -9,7 +8,6 @@
using ECS.LifeCycle;
using ECS.LifeCycle.Systems;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;

namespace DCL.PluginSystem.World
Expand All @@ -25,9 +23,6 @@ public AvatarAttachPlugin(ObjectProxy<AvatarBase> mainPlayerAvatarBaseProxy, ICo
this.componentPoolsRegistry = componentPoolsRegistry;
}

public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) =>
UniTask.CompletedTask;

public void Dispose()
{
//ignore
Expand Down
6 changes: 0 additions & 6 deletions Explorer/Assets/DCL/PluginSystem/World/AvatarShapePlugin.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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
Expand Down
7 changes: 0 additions & 7 deletions Explorer/Assets/DCL/PluginSystem/World/BillboardPlugin.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,11 +21,6 @@ public void Dispose()
//ignore
}

public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct)
{
return UniTask.CompletedTask;
}

public void InjectToWorld(ref ArchSystemsWorldBuilder<Arch.Core.World> builder, in ECSWorldInstanceSharedDependencies sharedDependencies, in PersistentEntities persistentEntities, List<IFinalizeWorldSystem> finalizeWorldSystems, List<ISceneIsCurrentListener> sceneIsCurrentListeners)
{
BillboardSystem.InjectToWorld(ref builder, cameraData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@ namespace DCL.PluginSystem.World
{
public interface IDCLWorldPluginWithoutSettings : IDCLWorldPlugin<NoExposedPluginSettings>
{
UniTask IDCLPlugin.Initialize(IPluginSettingsContainer container, CancellationToken ct) =>

// Don't even try to retrieve empty settings
UniTask.CompletedTask;

void IDisposable.Dispose() { }

UniTask IDCLPlugin<NoExposedPluginSettings>.InitializeAsync(NoExposedPluginSettings settings,
CancellationToken ct)
{
return UniTask.CompletedTask;
}
CancellationToken ct) =>
UniTask.CompletedTask;
}
}
Loading

0 comments on commit 8514b27

Please sign in to comment.