Skip to content

Commit

Permalink
chore: moved environment selection to EntryPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
davidejensen committed Jan 22, 2025
1 parent af7e902 commit f5a2784
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions Explorer/Assets/Scenes/Main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ MonoBehaviour:
useRemoteAssetsBundles: 1
isolateSceneCommunication: 0
portableExperiencesEnsToLoadAtGameStart: []
decentralandEnvironment: 0
debugViewsCatalog:
<Widget>k__BackingField: {fileID: 9197481963319205126, guid: f3bf08b2b62097d4aa0574f7bafa4a86, type: 3}
<ControlContainer>k__BackingField: {fileID: 9197481963319205126, guid: 6da3ff28c8a87e0428fa07019c15fa2f, type: 3}
Expand Down
3 changes: 2 additions & 1 deletion Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static async UniTask<BootstrapContainer> CreateAsync(
ICompressShaders compressShaders,
IRealmUrls realmUrls,
World world,
DecentralandEnvironment decentralandEnvironment,
CancellationToken ct)
{
var browser = new UnityAppWebBrowser(decentralandUrlsSource);
Expand All @@ -98,7 +99,7 @@ public static async UniTask<BootstrapContainer> CreateAsync(
ApplicationParametersParser = applicationParametersParser,
DebugSettings = debugSettings,
WorldVolumeMacBus = new WorldVolumeMacBus(),
Environment = sceneLoaderSettings.DecentralandEnvironment
Environment = decentralandEnvironment
};

await bootstrapContainer.InitializeContainerAsync<BootstrapContainer, BootstrapSettings>(settingsContainer, ct, async container =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,8 @@ namespace Global.Dynamic
[CreateAssetMenu(fileName = "DynamicSceneLoaderSettings", menuName = "DCL/Various/Dynamic Scene LoaderSettings")]
public class DynamicSceneLoaderSettings : ScriptableObject
{
[field: SerializeField] public DecentralandEnvironment DecentralandEnvironment { get; private set; }
[field: SerializeField] public List<string> Realms { get; private set; }
[field: SerializeField] public List<string> Web3WhitelistMethods { get; private set; }

public void ApplyConfig(IAppArgs applicationParametersParser)
{
if (applicationParametersParser.TryGetValue(AppArgsFlags.ENVIRONMENT, out string? environment))
ParseEnvironment(environment!);
}

private void ParseEnvironment(string environment)
{
if (Enum.TryParse(environment, true, out DecentralandEnvironment env))
DecentralandEnvironment = env;
}
}
}
22 changes: 19 additions & 3 deletions Explorer/Assets/Scripts/Global/Dynamic/MainSceneLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using DCL.DebugUtilities;
using DCL.Diagnostics;
using DCL.Input.Component;
using DCL.Multiplayer.Connections.DecentralandUrls;
using DCL.Optimization.PerformanceBudgeting;
using DCL.Platforms;
using DCL.PluginSystem;
Expand All @@ -18,7 +19,6 @@
using DCL.Utilities.Extensions;
using DCL.Web3.Accounts.Factory;
using DCL.Web3.Identities;
using DCL.WebRequests;
using DCL.WebRequests.Analytics;
using Global.AppArgs;
using Global.Dynamic.RealmUrl;
Expand All @@ -42,6 +42,9 @@ public class MainSceneLoader : MonoBehaviour, ICoroutineRunner
[Header("Startup Config")] [SerializeField]
private RealmLaunchSettings launchSettings = null!;

[Space]
[SerializeField] private DecentralandEnvironment decentralandEnvironment;

[Space]
[SerializeField] private DebugViewsCatalog debugViewsCatalog = new ();

Expand Down Expand Up @@ -100,6 +103,18 @@ private void OnDestroy()
ReportHub.Log(ReportCategory.ENGINE, "OnDestroy successfully finished");
}

public void ApplyConfig(IAppArgs applicationParametersParser)
{
if (applicationParametersParser.TryGetValue(AppArgsFlags.ENVIRONMENT, out string? environment))
ParseEnvironment(environment!);
}

private void ParseEnvironment(string environment)
{
if (Enum.TryParse(environment, true, out DecentralandEnvironment env))
decentralandEnvironment = env;
}

private async UniTask InitializeFlowAsync(CancellationToken ct)
{
IAppArgs applicationParametersParser = new ApplicationParametersParser(
Expand Down Expand Up @@ -129,13 +144,13 @@ ITexturesFuse TextureFuseFactory() =>

ISystemMemoryCap memoryCap = new SystemMemoryCap(MemoryCapMode.MAX_SYSTEM_MEMORY); // we use max memory on the loading screen

settings.ApplyConfig(applicationParametersParser);
ApplyConfig(applicationParametersParser);
launchSettings.ApplyConfig(applicationParametersParser);

World world = World.Create();

var splashScreen = new SplashScreen(splashScreenAnimation, splashRoot, debugSettings.ShowSplash, splashScreenText);
var decentralandUrlsSource = new DecentralandUrlsSource(settings.DecentralandEnvironment, launchSettings.IsLocalSceneDevelopmentRealm);
var decentralandUrlsSource = new DecentralandUrlsSource(decentralandEnvironment, launchSettings.IsLocalSceneDevelopmentRealm);

var texturesFuse = TextureFuseFactory();

Expand All @@ -161,6 +176,7 @@ ITexturesFuse TextureFuseFactory() =>
.WithLog("Load Guard"),
realmUrls,
world,
decentralandEnvironment,
destroyCancellationToken
);

Expand Down

0 comments on commit f5a2784

Please sign in to comment.