< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ParcelData(...)0%110100%

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{
 29215    public Vector2Int coords { private set; get; }
 26716    public string realmServer { private set; get; }
 26717    public string realmLayer { private set; get; }
 18
 26219    public ParcelData(Vector2Int coords, string realmServer, string realmLayer)
 20    {
 26221        this.coords = coords;
 26222        this.realmServer = realmServer;
 26223        this.realmLayer = realmLayer;
 26224    }
 25}
 26
 27internal class ScenesFilter
 28{
 29    public List<ParcelData> Filter(List<IHotScenesController.HotSceneInfo> hotScenesList, int maxMarkers)
 30    {
 31        List<ParcelData> result = new List<ParcelData>(maxMarkers);
 32        List<ParcelData> rawParcelCoords = GetRawParcelCoords(hotScenesList);
 33        float stepAmount = rawParcelCoords.Count / (float)maxMarkers;
 34        if (stepAmount < 1)
 35            stepAmount = 1;
 36
 37        float lastIndex = -1;
 38        for (float step = 0; step < rawParcelCoords.Count; step += stepAmount)
 39        {
 40            if ((step - lastIndex) >= 1)
 41            {
 42                lastIndex = step;
 43                result.Add(rawParcelCoords[(int)lastIndex]);
 44
 45                if (result.Count >= maxMarkers)
 46                    break;
 47            }
 48        }
 49
 50        return result;
 51    }
 52
 53    private List<ParcelData> GetRawParcelCoords(List<IHotScenesController.HotSceneInfo> hotScenesList)
 54    {
 55        List<ParcelData> result = new List<ParcelData>();
 56
 57        IHotScenesController.HotSceneInfo sceneInfo;
 58        IHotScenesController.HotSceneInfo.Realm realm;
 59        int scenesCount = hotScenesList.Count;
 60
 61        for (int sceneIdx = 0; sceneIdx < scenesCount; sceneIdx++)
 62        {
 63            sceneInfo = hotScenesList[sceneIdx];
 64            if (sceneInfo.usersTotalCount <= 0)
 65                continue;
 66
 67            for (int realmIdx = 0; realmIdx < sceneInfo.realms.Length; realmIdx++)
 68            {
 69                realm = sceneInfo.realms[realmIdx];
 70                for (int parcelIdx = 0; parcelIdx < realm.userParcels.Length; parcelIdx++)
 71                {
 72                    result.Add(new ParcelData(realm.userParcels[parcelIdx], realm.serverName, realm.layer));
 73                }
 74            }
 75        }
 76        return result;
 77    }
 78}