< Summary

Class:ScenesFilter
Assembly:GlobalUsersPositionMarker
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/MapRenderer/GlobalUsersPositionMarker/Utils/UserPositionMarkerUtils.cs
Covered lines:22
Uncovered lines:0
Coverable lines:22
Total lines:78
Line coverage:100% (22 of 22)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:2
Method coverage:100% (2 of 2)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Filter(...)0%550100%
GetRawParcelCoords(...)0%550100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/MapRenderer/GlobalUsersPositionMarker/Utils/UserPositionMarkerUtils.cs

#LineLine coverage
 1using MainScripts.DCL.Controllers.HotScenes;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5internal class ExclusionArea
 6{
 7    public Vector2Int position;
 8    public int area;
 9
 10    public bool Contains(Vector2Int coords) { return (coords - position).sqrMagnitude <= area * area; }
 11}
 12
 13internal class ParcelData
 14{
 15    public Vector2Int coords { private set; get; }
 16    public string realmServer { private set; get; }
 17    public string realmLayer { private set; get; }
 18
 19    public ParcelData(Vector2Int coords, string realmServer, string realmLayer)
 20    {
 21        this.coords = coords;
 22        this.realmServer = realmServer;
 23        this.realmLayer = realmLayer;
 24    }
 25}
 26
 27internal class ScenesFilter
 28{
 29    public List<ParcelData> Filter(List<IHotScenesController.HotSceneInfo> hotScenesList, int maxMarkers)
 30    {
 431        List<ParcelData> result = new List<ParcelData>(maxMarkers);
 432        List<ParcelData> rawParcelCoords = GetRawParcelCoords(hotScenesList);
 433        float stepAmount = rawParcelCoords.Count / (float)maxMarkers;
 434        if (stepAmount < 1)
 335            stepAmount = 1;
 36
 437        float lastIndex = -1;
 45638        for (float step = 0; step < rawParcelCoords.Count; step += stepAmount)
 39        {
 22540            if ((step - lastIndex) >= 1)
 41            {
 22542                lastIndex = step;
 22543                result.Add(rawParcelCoords[(int)lastIndex]);
 44
 22545                if (result.Count >= maxMarkers)
 46                    break;
 47            }
 48        }
 49
 450        return result;
 51    }
 52
 53    private List<ParcelData> GetRawParcelCoords(List<IHotScenesController.HotSceneInfo> hotScenesList)
 54    {
 455        List<ParcelData> result = new List<ParcelData>();
 56
 57        IHotScenesController.HotSceneInfo sceneInfo;
 58        IHotScenesController.HotSceneInfo.Realm realm;
 459        int scenesCount = hotScenesList.Count;
 60
 53261        for (int sceneIdx = 0; sceneIdx < scenesCount; sceneIdx++)
 62        {
 26263            sceneInfo = hotScenesList[sceneIdx];
 26264            if (sceneInfo.usersTotalCount <= 0)
 65                continue;
 66
 104867            for (int realmIdx = 0; realmIdx < sceneInfo.realms.Length; realmIdx++)
 68            {
 26269                realm = sceneInfo.realms[realmIdx];
 104870                for (int parcelIdx = 0; parcelIdx < realm.userParcels.Length; parcelIdx++)
 71                {
 26272                    result.Add(new ParcelData(realm.userParcels[parcelIdx], realm.serverName, realm.layer));
 73                }
 74            }
 75        }
 476        return result;
 77    }
 78}