-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logic to load global PX as part of startup operations (#2199)
- Loading branch information
Showing
17 changed files
with
245 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...nAppInitializationFlow/StartupOperations/LoadGlobalPortableExperiencesStartupOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using Arch.Core; | ||
using CommunicationData.URLHelpers; | ||
using Cysharp.Threading.Tasks; | ||
using DCL.AsyncLoadReporting; | ||
using DCL.Diagnostics; | ||
using DCL.FeatureFlags; | ||
using DCL.Multiplayer.Connections.DecentralandUrls; | ||
using DCL.Profiles; | ||
using DCL.Profiles.Self; | ||
using DCL.Utilities.Extensions; | ||
using ECS.SceneLifeCycle.Realm; | ||
using Global.AppArgs; | ||
using Global.Dynamic; | ||
using Global.Dynamic.DebugSettings; | ||
using PortableExperiences.Controller; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using Utility.Types; | ||
|
||
namespace DCL.UserInAppInitializationFlow.StartupOperations | ||
{ | ||
public class LoadGlobalPortableExperiencesStartupOperation : IStartupOperation | ||
{ | ||
private readonly RealFlowLoadingStatus loadingStatus; | ||
private readonly ISelfProfile selfProfile; | ||
private readonly FeatureFlagsCache featureFlagsCache; | ||
private readonly IDebugSettings debugSettings; | ||
private readonly IPortableExperiencesController portableExperiencesController; | ||
|
||
public LoadGlobalPortableExperiencesStartupOperation( | ||
RealFlowLoadingStatus loadingStatus, | ||
ISelfProfile selfProfile, | ||
FeatureFlagsCache featureFlagsCache, | ||
IDebugSettings debugSettings, | ||
IPortableExperiencesController portableExperiencesController) | ||
{ | ||
this.loadingStatus = loadingStatus; | ||
this.selfProfile = selfProfile; | ||
this.featureFlagsCache = featureFlagsCache; | ||
this.debugSettings = debugSettings; | ||
this.portableExperiencesController = portableExperiencesController; | ||
} | ||
|
||
public async UniTask<Result> ExecuteAsync(AsyncLoadProcessReport report, CancellationToken ct) | ||
{ | ||
await CheckGlobalPxLoadingConditionsAsync(ct); | ||
|
||
report.SetProgress(loadingStatus.SetStage(RealFlowLoadingStatus.Stage.LoadGlobalPXs)); | ||
return Result.SuccessResult(); | ||
} | ||
|
||
private async UniTask CheckGlobalPxLoadingConditionsAsync(CancellationToken ct) | ||
{ | ||
var ownProfile = await selfProfile.ProfileAsync(ct); | ||
|
||
//If we havent completed the tutorial, we won't load the GlobalPX as it will interfere with the onboarding. | ||
if (ownProfile is not { TutorialStep: > 0 }) | ||
return; | ||
|
||
LoadDebugPortableExperiences(ct); | ||
LoadRemotePortableExperiences(ct); | ||
} | ||
|
||
private void LoadRemotePortableExperiences(CancellationToken ct) | ||
{ | ||
//This allows us to disable loading the global px on debug builds or when using the editor in case we wanted to load a cleaner experience. | ||
if (!debugSettings.EnableRemotePortableExperiences) return; | ||
|
||
if (featureFlagsCache.Configuration.IsEnabled(FeatureFlagsStrings.GLOBAL_PORTABLE_EXPERIENCE, FeatureFlagsStrings.CSV_VARIANT)) | ||
{ | ||
if (!featureFlagsCache.Configuration.TryGetCsvPayload(FeatureFlagsStrings.GLOBAL_PORTABLE_EXPERIENCE, FeatureFlagsStrings.CSV_VARIANT, out List<List<string>>? csv)) return; | ||
|
||
if (csv?[0] == null) return; | ||
|
||
foreach (string value in csv[0]) { portableExperiencesController. | ||
CreatePortableExperienceByEnsAsync(new ENS(value), ct, true, true). | ||
SuppressAnyExceptionWithFallback(new IPortableExperiencesController.SpawnResponse(), ReportCategory.PORTABLE_EXPERIENCE).Forget(); } | ||
} | ||
} | ||
|
||
private void LoadDebugPortableExperiences(CancellationToken ct) | ||
{ | ||
if (debugSettings.PortableExperiencesEnsToLoad == null) return; | ||
|
||
foreach (string pxEns in debugSettings.PortableExperiencesEnsToLoad) | ||
{ | ||
portableExperiencesController. | ||
CreatePortableExperienceByEnsAsync(new ENS(pxEns), ct, true, true). | ||
SuppressAnyExceptionWithFallback(new IPortableExperiencesController.SpawnResponse(), ReportCategory.PORTABLE_EXPERIENCE).Forget(); | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...nitializationFlow/StartupOperations/LoadGlobalPortableExperiencesStartupOperation.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
Explorer/Assets/Scripts/Global/Dynamic/DebugSettings/DebugSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using LiveKit.Proto; | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace Global.Dynamic.DebugSettings | ||
{ | ||
[Serializable] | ||
public class DebugSettings : IDebugSettings | ||
{ | ||
private static readonly DebugSettings RELEASE_SETTINGS = Release(); | ||
|
||
[SerializeField] | ||
private bool showSplash; | ||
[SerializeField] | ||
private bool showAuthentication; | ||
[SerializeField] | ||
private bool showLoading; | ||
[SerializeField] | ||
private bool enableLandscape; | ||
[SerializeField] | ||
private bool enableLOD; | ||
[SerializeField] private bool enableVersionUpdateGuard; | ||
[SerializeField] | ||
private bool enableEmulateNoLivekitConnection; | ||
[SerializeField] [Tooltip("Enable Portable Experiences obtained from Feature Flags from loading at the start of the game")] | ||
private bool enableRemotePortableExperiences; | ||
[SerializeField] [Tooltip("Make sure the ENS put here will be loaded as a GlobalPX (format must be something.dcl.eth)")] | ||
internal string[]? portableExperiencesEnsToLoad; | ||
[SerializeField] | ||
internal string[]? emotesToAddToUserProfile; | ||
[Space] | ||
[SerializeField] | ||
private bool overrideConnectionQuality; | ||
[SerializeField] | ||
private ConnectionQuality connectionQuality; | ||
|
||
public static DebugSettings Release() => | ||
new () | ||
{ | ||
showSplash = true, | ||
showAuthentication = true, | ||
showLoading = true, | ||
enableLandscape = true, | ||
enableLOD = true, | ||
enableVersionUpdateGuard = true, | ||
portableExperiencesEnsToLoad = null, | ||
enableEmulateNoLivekitConnection = false, | ||
overrideConnectionQuality = false, | ||
connectionQuality = ConnectionQuality.QualityExcellent, | ||
enableRemotePortableExperiences = true, | ||
emotesToAddToUserProfile = null, | ||
}; | ||
|
||
// To avoid configuration issues, force full flow on build (Application.isEditor is always true in Editor, but in profile builds (i.e. when set to Development) we will have the expected release flow too. | ||
public string[]? EmotesToAddToUserProfile => Application.isEditor ? this.emotesToAddToUserProfile : RELEASE_SETTINGS.emotesToAddToUserProfile; | ||
public string[]? PortableExperiencesEnsToLoad => Application.isEditor ? this.portableExperiencesEnsToLoad : RELEASE_SETTINGS.portableExperiencesEnsToLoad; | ||
public bool EnableRemotePortableExperiences => Application.isEditor ? this.enableRemotePortableExperiences : RELEASE_SETTINGS.enableRemotePortableExperiences; | ||
public bool ShowSplash => Application.isEditor ? this.showSplash : RELEASE_SETTINGS.showSplash; | ||
public bool ShowAuthentication => Application.isEditor ? this.showAuthentication : RELEASE_SETTINGS.showAuthentication; | ||
public bool ShowLoading => Application.isEditor ? this.showLoading : RELEASE_SETTINGS.showLoading; | ||
public bool EnableLandscape => Application.isEditor ? this.enableLandscape : RELEASE_SETTINGS.enableLandscape; | ||
public bool EnableLOD => Application.isEditor ? this.enableLOD : RELEASE_SETTINGS.enableLOD; | ||
public bool EnableVersionUpdateGuard => Application.isEditor ? this.enableVersionUpdateGuard : RELEASE_SETTINGS.enableVersionUpdateGuard; | ||
public bool EnableEmulateNoLivekitConnection => Application.isEditor? this.enableEmulateNoLivekitConnection : RELEASE_SETTINGS.enableEmulateNoLivekitConnection; | ||
public bool OverrideConnectionQuality => Application.isEditor ? this.overrideConnectionQuality : RELEASE_SETTINGS.overrideConnectionQuality; | ||
public ConnectionQuality ConnectionQuality => Application.isEditor ? this.connectionQuality : RELEASE_SETTINGS.connectionQuality; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Explorer/Assets/Scripts/Global/Dynamic/DebugSettings/DebugSettings.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
Explorer/Assets/Scripts/Global/Dynamic/DebugSettings/Global.Dynamic.DebugSettings.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "Global.Dynamic.DebugSettings", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:702f733b4deb246808c6ce84d93b5c9c" | ||
], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
7 changes: 7 additions & 0 deletions
7
...orer/Assets/Scripts/Global/Dynamic/DebugSettings/Global.Dynamic.DebugSettings.asmdef.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
Explorer/Assets/Scripts/Global/Dynamic/DebugSettings/IDebugSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using LiveKit.Proto; | ||
|
||
namespace Global.Dynamic.DebugSettings | ||
{ | ||
public interface IDebugSettings | ||
{ | ||
string[]? PortableExperiencesEnsToLoad { get; } | ||
string[]? EmotesToAddToUserProfile { get; } | ||
bool ShowSplash { get; } | ||
bool ShowAuthentication { get; } | ||
bool ShowLoading { get; } | ||
bool EnableLandscape { get; } | ||
bool EnableLOD { get; } | ||
bool EnableVersionUpdateGuard { get; } | ||
bool EnableEmulateNoLivekitConnection { get; } | ||
bool OverrideConnectionQuality { get; } | ||
ConnectionQuality ConnectionQuality { get; } | ||
bool EnableRemotePortableExperiences { get; } | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Explorer/Assets/Scripts/Global/Dynamic/DebugSettings/IDebugSettings.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.