< 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:77
Line coverage:100% (22 of 22)
Covered branches:0
Total branches:0

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 System.Collections.Generic;
 2using UnityEngine;
 3
 4internal class ExclusionArea
 5{
 6    public Vector2Int position;
 7    public int area;
 8
 9    public bool Contains(Vector2Int coords) { return (coords - position).sqrMagnitude <= area * area; }
 10}
 11
 12internal class ParcelData
 13{
 14    public Vector2Int coords { private set; get; }
 15    public string realmServer { private set; get; }
 16    public string realmLayer { private set; get; }
 17
 18    public ParcelData(Vector2Int coords, string realmServer, string realmLayer)
 19    {
 20        this.coords = coords;
 21        this.realmServer = realmServer;
 22        this.realmLayer = realmLayer;
 23    }
 24}
 25
 26internal class ScenesFilter
 27{
 28    public List<ParcelData> Filter(List<HotScenesController.HotSceneInfo> hotScenesList, int maxMarkers)
 29    {
 430        List<ParcelData> result = new List<ParcelData>(maxMarkers);
 431        List<ParcelData> rawParcelCoords = GetRawParcelCoords(hotScenesList);
 432        float stepAmount = rawParcelCoords.Count / (float)maxMarkers;
 433        if (stepAmount < 1)
 334            stepAmount = 1;
 35
 436        float lastIndex = -1;
 45637        for (float step = 0; step < rawParcelCoords.Count; step += stepAmount)
 38        {
 22539            if ((step - lastIndex) >= 1)
 40            {
 22541                lastIndex = step;
 22542                result.Add(rawParcelCoords[(int)lastIndex]);
 43
 22544                if (result.Count >= maxMarkers)
 45                    break;
 46            }
 47        }
 48
 449        return result;
 50    }
 51
 52    private List<ParcelData> GetRawParcelCoords(List<HotScenesController.HotSceneInfo> hotScenesList)
 53    {
 454        List<ParcelData> result = new List<ParcelData>();
 55
 56        HotScenesController.HotSceneInfo sceneInfo;
 57        HotScenesController.HotSceneInfo.Realm realm;
 458        int scenesCount = hotScenesList.Count;
 59
 53260        for (int sceneIdx = 0; sceneIdx < scenesCount; sceneIdx++)
 61        {
 26262            sceneInfo = hotScenesList[sceneIdx];
 26263            if (sceneInfo.usersTotalCount <= 0)
 64                continue;
 65
 104866            for (int realmIdx = 0; realmIdx < sceneInfo.realms.Length; realmIdx++)
 67            {
 26268                realm = sceneInfo.realms[realmIdx];
 104869                for (int parcelIdx = 0; parcelIdx < realm.userParcels.Length; parcelIdx++)
 70                {
 26271                    result.Add(new ParcelData(realm.userParcels[parcelIdx], realm.serverName, realm.layer));
 72                }
 73            }
 74        }
 475        return result;
 76    }
 77}