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