< Summary

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

Metrics

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

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
 89    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    {
 30        List<ParcelData> result = new List<ParcelData>(maxMarkers);
 31        List<ParcelData> rawParcelCoords = GetRawParcelCoords(hotScenesList);
 32        float stepAmount = rawParcelCoords.Count / (float)maxMarkers;
 33        if (stepAmount < 1)
 34            stepAmount = 1;
 35
 36        float lastIndex = -1;
 37        for (float step = 0; step < rawParcelCoords.Count; step += stepAmount)
 38        {
 39            if ((step - lastIndex) >= 1)
 40            {
 41                lastIndex = step;
 42                result.Add(rawParcelCoords[(int)lastIndex]);
 43
 44                if (result.Count >= maxMarkers)
 45                    break;
 46            }
 47        }
 48
 49        return result;
 50    }
 51
 52    private List<ParcelData> GetRawParcelCoords(List<HotScenesController.HotSceneInfo> hotScenesList)
 53    {
 54        List<ParcelData> result = new List<ParcelData>();
 55
 56        HotScenesController.HotSceneInfo sceneInfo;
 57        HotScenesController.HotSceneInfo.Realm realm;
 58        int scenesCount = hotScenesList.Count;
 59
 60        for (int sceneIdx = 0; sceneIdx < scenesCount; sceneIdx++)
 61        {
 62            sceneInfo = hotScenesList[sceneIdx];
 63            if (sceneInfo.usersTotalCount <= 0)
 64                continue;
 65
 66            for (int realmIdx = 0; realmIdx < sceneInfo.realms.Length; realmIdx++)
 67            {
 68                realm = sceneInfo.realms[realmIdx];
 69                for (int parcelIdx = 0; parcelIdx < realm.userParcels.Length; parcelIdx++)
 70                {
 71                    result.Add(new ParcelData(realm.userParcels[parcelIdx], realm.serverName, realm.layer));
 72                }
 73            }
 74        }
 75        return result;
 76    }
 77}