< Summary

Class:DCL.WorldState
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/WorldState.cs
Covered lines:22
Uncovered lines:9
Coverable lines:31
Total lines:84
Line coverage:70.9% (22 of 31)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
WorldState()0%110100%
GetScene(...)0%2.152066.67%
Contains(...)0%3.333066.67%
TryGetScene(...)0%330100%
TryGetScene[T](...)0%12300%
GetAllLoadedScenesCoords()0%330100%
Dispose()0%110100%
Initialize()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/WorldState.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Helpers;
 3using System.Collections.Generic;
 4using UnityEngine;
 5
 6namespace DCL
 7{
 8    public class WorldState : IWorldState
 9    {
 112310        public HashSet<string> readyScenes { get; set; } = new HashSet<string>();
 565911        public Dictionary<string, IParcelScene> loadedScenes { get; set; } = new Dictionary<string, IParcelScene>();
 409312        public List<IParcelScene> scenesSortedByDistance { get; set; } = new List<IParcelScene>();
 117713        public List<string> globalSceneIds { get; set; } = new List<string>();
 310314        public string currentSceneId { get; set; } = null;
 15
 16        public IParcelScene GetScene(string id)
 17        {
 1718            if (!Contains(id))
 019                return null;
 20
 1721            return loadedScenes[id];
 22        }
 23
 24        public bool Contains(string id)
 25        {
 43026            if (string.IsNullOrEmpty(id) || !loadedScenes.ContainsKey(id))
 027                return false;
 28
 43029            return true;
 30        }
 31
 32        public bool TryGetScene(string id, out IParcelScene scene)
 33        {
 1534            scene = null;
 35
 1536            if (string.IsNullOrEmpty(id) || !loadedScenes.ContainsKey(id))
 737                return false;
 38
 839            scene = loadedScenes[id];
 840            return true;
 41        }
 42
 43        public bool TryGetScene<T>(string id, out T scene)
 44            where T : class, IParcelScene
 45        {
 046            scene = default(T);
 047            bool result = TryGetScene(id, out IParcelScene baseScene);
 48
 049            if (result)
 050                scene = baseScene as T;
 51
 052            if (scene == null)
 053                result = false;
 54
 055            return result;
 56        }
 57
 58        public HashSet<Vector2Int> GetAllLoadedScenesCoords()
 59        {
 74460            HashSet<Vector2Int> allLoadedParcelCoords = new HashSet<Vector2Int>();
 61
 62            // Create fast (hashset) collection of loaded parcels coords
 174263            foreach (var element in loadedScenes)
 64            {
 12765                ParcelScene scene = element.Value as ParcelScene;
 66
 12767                if (!scene.sceneLifecycleHandler.isReady)
 68                    continue;
 69
 270                allLoadedParcelCoords.UnionWith(scene.parcels);
 71            }
 72
 74473            return allLoadedParcelCoords;
 74        }
 75
 76        public void Dispose()
 77        {
 73478        }
 79
 80        public void Initialize()
 81        {
 73482        }
 83    }
 84}