Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ await MapRendererContainer
new CharacterPreviewPlugin(staticContainer.ComponentsContainer.ComponentPoolsRegistry, assetsProvisioner, staticContainer.CacheCleaner),
staticContainer.WebRequestsContainer.CreatePlugin(localSceneDevelopment),
new Web3AuthenticationPlugin(assetsProvisioner, dynamicWorldDependencies.CompositeWeb3Provider, debugBuilder, mvcManager, selfProfile, webBrowser, staticContainer.RealmData, identityCache, characterPreviewFactory, dynamicWorldDependencies.SplashScreen, audioMixerVolumesController, staticContainer.InputBlock, characterPreviewEventBus, backgroundMusic, globalWorld, bootstrapContainer.AppArgs, wearablesProvider, staticContainer.WebRequestsContainer.WebRequestController, bootstrapContainer.DecentralandUrlsSource),
new SkyboxPlugin(assetsProvisioner, dynamicSettings.DirectionalLight, staticContainer.ScenesCache, staticContainer.SceneRestrictionBusController),
new SkyboxPlugin(assetsProvisioner, dynamicSettings.DirectionalLight, staticContainer.ScenesCache, staticContainer.SceneRestrictionBusController, staticContainer.RealmData),
new LoadingScreenPlugin(assetsProvisioner, mvcManager, audioMixerVolumesController,
staticContainer.InputBlock, debugBuilder, staticContainer.LoadingStatus, featureFlags),
new ExternalUrlPromptPlugin(assetsProvisioner, webBrowser, mvcManager, dclCursor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ public async UniTask SetRealmAsync(URLDomain realm, CancellationToken ct)

string hostname = ResolveHostname(realm, result);

float? skyboxFixedHour = result.configurations.skybox is { fixedHour: >= 0 }
? result.configurations.skybox.fixedHour
: null;

realmData.Reconfigure(
new IpfsRealm(realm, result),
result.configurations.realmName.EnsureNotNull("Realm name not found"),
Expand All @@ -150,7 +154,8 @@ public async UniTask SetRealmAsync(URLDomain realm, CancellationToken ct)
result.comms?.protocol ?? "v3",
hostname,
isLocalSceneDevelopment,
worldManifest
worldManifest,
skyboxFixedHour
);

UnityDiagnosticsCenter.Instance.SetRealmInfo(
Expand Down
13 changes: 11 additions & 2 deletions Explorer/Assets/DCL/NetworkDefinitions/IRealmData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommunicationData.URLHelpers;
using CommunicationData.URLHelpers;
using DCL.Ipfs;
using DCL.Utilities;

Expand Down Expand Up @@ -38,7 +38,15 @@ public interface IRealmData
/// World manifest that describes the world state
/// </summary>
WorldManifest WorldManifest { get; }
bool SingleScene { get; }
bool SingleScene { get; }

/// <summary>
/// Realm-level fixed skybox hour in seconds (from server about configurations.skybox.fixedHour).
/// Null when not set, meaning the realm does not enforce a fixed time of day.
/// Measured in seconds of a day
/// </summary>
float? SkyboxFixedHour { get; }


class Fake : IRealmData
{
Expand All @@ -55,6 +63,7 @@ class Fake : IRealmData
public bool IsDirty { get; internal set; }
public WorldManifest WorldManifest { get; }
public bool SingleScene { get; }
public float? SkyboxFixedHour { get; }

public Fake(int networkId = 1, string commsAdapter = "", string realmName = "baldr", string protocol = "v3",
string hostname = "realm-provider.decentraland.org") : this(
Expand Down
5 changes: 4 additions & 1 deletion Explorer/Assets/DCL/NetworkDefinitions/RealmData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class RealmData : IRealmData
public string Hostname { get; private set; }
public bool IsLocalSceneDevelopment { get; private set; }
public bool Configured { get; private set; }
public float? SkyboxFixedHour { get; private set; }

/// <summary>
/// World manifest from asset-bundle-registry (occupied parcels, spawn coordinate, total). Null when not fetched or not applicable.
Expand Down Expand Up @@ -103,7 +104,7 @@ public RealmData(IIpfsRealm ipfsRealm)
}

public void Reconfigure(IIpfsRealm ipfsRealm, string realmName, int networkId, string commsAdapter, string protocol,
string hostname, bool isLocalSceneDevelopment, WorldManifest worldManifest)
string hostname, bool isLocalSceneDevelopment, WorldManifest worldManifest, float? skyboxFixedHour = null)
{
IsDirty = true;
Configured = true;
Expand All @@ -116,6 +117,7 @@ public void Reconfigure(IIpfsRealm ipfsRealm, string realmName, int networkId, s
Hostname = hostname;
IsLocalSceneDevelopment = isLocalSceneDevelopment;
WorldManifest = worldManifest;
SkyboxFixedHour = skyboxFixedHour;

if (isLocalSceneDevelopment)
realmType.Value = RealmKind.LocalScene;
Expand All @@ -133,6 +135,7 @@ public void Invalidate()
Configured = false;
ipfs = InvalidIpfsRealm.Instance;
WorldManifest.Dispose();
SkyboxFixedHour = null;
realmType.Value = RealmKind.Uninitialized;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@

namespace DCL.Ipfs
{
[Serializable]
public class ServerSkyboxConfig
{
// Measured in seconds of a day
public float fixedHour = -1;
}

[Serializable]
public class ServerConfiguration
{
public List<string> scenesUrn;
public string realmName;
public int networkId;
public ServerSkyboxConfig skybox;
}
}
10 changes: 7 additions & 3 deletions Explorer/Assets/DCL/PluginSystem/Global/SkyboxPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Arch.Core;
using Arch.Core;
using Arch.SystemGroups;
using Cysharp.Threading.Tasks;
using DCL.AssetsProvision;
Expand All @@ -8,6 +8,7 @@
using DCL.PluginSystem.Global;
using DCL.Prefs;
using DCL.SceneRestrictionBusController.SceneRestrictionBus;
using ECS;
using ECS.SceneLifeCycle;
using Newtonsoft.Json;
using System;
Expand All @@ -23,6 +24,7 @@ public class SkyboxPlugin : IDCLGlobalPlugin<SkyboxPlugin.SkyboxTimeSettings>
private readonly Light directionalLight;
private readonly IScenesCache scenesCache;
private readonly ISceneRestrictionBusController sceneRestrictionController;
private readonly IRealmData realmData;

private SkyboxSettings settingsJson;

Expand All @@ -32,19 +34,21 @@ public class SkyboxPlugin : IDCLGlobalPlugin<SkyboxPlugin.SkyboxTimeSettings>
public SkyboxPlugin(IAssetsProvisioner assetsProvisioner,
Light directionalLight,
IScenesCache scenesCache,
ISceneRestrictionBusController sceneRestrictionController)
ISceneRestrictionBusController sceneRestrictionController,
IRealmData realmData)
{
this.assetsProvisioner = assetsProvisioner;
this.directionalLight = directionalLight;
this.scenesCache = scenesCache;
this.sceneRestrictionController = sceneRestrictionController;
this.realmData = realmData;
}

public void Dispose() { }

public void InjectToWorld(ref ArchSystemsWorldBuilder<World> builder, in GlobalPluginArguments arguments)
{
SkyboxTimeUpdateSystem.InjectToWorld(ref builder, skyboxSettings, scenesCache, sceneRestrictionController, skyboxRenderController, arguments.SkyboxEntity);
SkyboxTimeUpdateSystem.InjectToWorld(ref builder, skyboxSettings, scenesCache, sceneRestrictionController, skyboxRenderController, realmData, arguments.SkyboxEntity);
}

public async UniTask InitializeAsync(SkyboxTimeSettings pluginSettings, CancellationToken ct)
Expand Down
73 changes: 73 additions & 0 deletions Explorer/Assets/DCL/SkyBox/RealmSkyboxState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using DCL.Ipfs;
using DCL.SceneRestrictionBusController.SceneRestriction;
using DCL.SceneRestrictionBusController.SceneRestrictionBus;
using ECS;
using UnityEngine;

namespace DCL.SkyBox
{
/// <summary>
/// Applies the realm-level fixed skybox hour from the server about response (configurations.skybox.fixedHour).
/// Takes priority over UIOverride and GlobalTime, but yields to SDK components and scene metadata.
/// </summary>
public class RealmSkyboxState : ISkyboxState
{
private readonly IRealmData realmData;
private readonly SkyboxSettingsAsset settings;
private readonly ISceneRestrictionBusController sceneRestrictionController;
private readonly InterpolateTimeOfDayState transition;

public RealmSkyboxState(
IRealmData realmData,
SkyboxSettingsAsset settings,
ISceneRestrictionBusController sceneRestrictionController,
InterpolateTimeOfDayState transition)
{
this.realmData = realmData;
this.settings = settings;
this.sceneRestrictionController = sceneRestrictionController;
this.transition = transition;
}

public bool Applies() =>
realmData.Configured && realmData.SkyboxFixedHour.HasValue;

public void Enter()
{
sceneRestrictionController.PushSceneRestriction(
SceneRestriction.CreateSkyboxTimeUILocked(SceneRestrictionsAction.APPLIED));

settings.IsDayCycleEnabled = false;
settings.TransitionMode = SceneMetadata.TransitionMode.FORWARD;
ApplyFixedHour();
transition.Enter();
}

public void Update(float dt)
{
ApplyFixedHour();
transition.Update(dt);
}

public void Exit()
{
sceneRestrictionController.PushSceneRestriction(
SceneRestriction.CreateSkyboxTimeUILocked(SceneRestrictionsAction.REMOVED));

transition.Exit();
}

private void ApplyFixedHour()
{
if (!realmData.SkyboxFixedHour.HasValue)
return;

float normalizedTime = SkyboxSettingsAsset.NormalizeTime(realmData.SkyboxFixedHour.Value);

if (Mathf.Approximately(settings.TargetTimeOfDayNormalized, normalizedTime))
return;

settings.TargetTimeOfDayNormalized = normalizedTime;
}
}
}
2 changes: 2 additions & 0 deletions Explorer/Assets/DCL/SkyBox/RealmSkyboxState.cs.meta

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

5 changes: 4 additions & 1 deletion Explorer/Assets/DCL/SkyBox/SkyboxTimeUpdateSystem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Arch.Core;
using Arch.Core;
using Arch.SystemGroups;
using Arch.SystemGroups.DefaultSystemGroups;
using DCL.SceneRestrictionBusController.SceneRestrictionBus;
using DCL.SkyBox.Components;
using ECS;
using ECS.Abstract;
using ECS.SceneLifeCycle;

Expand All @@ -23,6 +24,7 @@ private SkyboxTimeUpdateSystem(World world,
IScenesCache scenesCache,
ISceneRestrictionBusController sceneRestrictionController,
SkyboxRenderController skyboxRenderController,
IRealmData realmData,
Entity skyboxEntity) : base(world)
{
var transition = new InterpolateTimeOfDayState(skyboxSettings);
Expand All @@ -33,6 +35,7 @@ private SkyboxTimeUpdateSystem(World world,
{
new SDKComponentState(skyboxSettings, sceneRestrictionController, transition, scenesCache),
new SceneMetadataState(scenesCache, skyboxSettings, sceneRestrictionController, transition),
new RealmSkyboxState(realmData, skyboxSettings, sceneRestrictionController, transition),
new UIOverrideState(skyboxSettings, transition),
globalTimeState,
});
Expand Down
Loading