< Summary

Class:DCLPlugins.RealmsPlugin.RealmsSkyboxModifier
Assembly:DCL.Plugins.RealmsPlugin
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/RealmsPlugin/RealmsSkyboxModifier.cs
Covered lines:19
Uncovered lines:1
Coverable lines:20
Total lines:57
Line coverage:95% (19 of 20)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RealmsSkyboxModifier(...)0%110100%
Dispose()0%2100%
OnEnteredRealm(...)0%550100%
ResetToCached()0%110100%
CacheCurrentSkyboxSettings()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/RealmsPlugin/RealmsSkyboxModifier.cs

#LineLine coverage
 1using DCL;
 2using DCL.SettingsCommon;
 3using DCLPlugins.RealmPlugin;
 4using static Decentraland.Bff.AboutResponse.Types;
 5
 6namespace DCLPlugins.RealmsPlugin
 7{
 8    /// <summary>
 9    /// Align skybox with the realm skybox settings. It allows the world creator to force specific skybox state.
 10    /// </summary>
 11    public class RealmsSkyboxModifier : IRealmModifier
 12    {
 13        private readonly DataStore_SkyboxConfig skyboxConfig;
 14
 15        private bool hasCached;
 16
 17        private SkyboxMode cachedMode;
 18        private float cachedFixedTime;
 19
 1120        public RealmsSkyboxModifier(DataStore_SkyboxConfig skyboxConfig)
 21        {
 1122            this.skyboxConfig = skyboxConfig;
 1123        }
 24
 025        public void Dispose() { }
 26
 27        public void OnEnteredRealm(bool _, AboutConfiguration realmConfiguration)
 28        {
 1129            if (realmConfiguration.Skybox is { HasFixedHour: true })
 30            {
 631                if (!hasCached)
 632                    CacheCurrentSkyboxSettings();
 33
 634                CommonSettingsScriptableObjects.SkyboxControlledByRealm.Set(true);
 635                skyboxConfig.UseFixedTimeFromSeconds(realmConfiguration.Skybox!.FixedHour, SkyboxMode.HoursFixedByWorld)
 36            }
 537            else if (hasCached)
 538                ResetToCached();
 539        }
 40
 41        private void ResetToCached()
 42        {
 543            skyboxConfig.UseFixedTimeFromHours(cachedFixedTime, cachedMode);
 544            hasCached = false;
 45
 546            CommonSettingsScriptableObjects.SkyboxControlledByRealm.Set(false);
 547        }
 48
 49        private void CacheCurrentSkyboxSettings()
 50        {
 651            cachedMode = skyboxConfig.mode.Get();
 652            cachedFixedTime = skyboxConfig.fixedTime.Get();
 53
 654            hasCached = true;
 655        }
 56    }
 57}