| | 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 | | { |
| 0 | 14 | | public Vector2Int coords { private set; get; } |
| 0 | 15 | | public string realmServer { private set; get; } |
| 0 | 16 | | public string realmLayer { private set; get; } |
| | 17 | |
|
| 262 | 18 | | public ParcelData(Vector2Int coords, string realmServer, string realmLayer) |
| | 19 | | { |
| 262 | 20 | | this.coords = coords; |
| 262 | 21 | | this.realmServer = realmServer; |
| 262 | 22 | | this.realmLayer = realmLayer; |
| 262 | 23 | | } |
| | 24 | | } |
| | 25 | |
|
| | 26 | | internal 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 | | } |