| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using DCL; |
| | 3 | | using DCL.Providers; |
| | 4 | | using DCLServices.MapRendererV2.CoordsUtils; |
| | 5 | | using DCLServices.MapRendererV2.Culling; |
| | 6 | | using DCLServices.MapRendererV2.MapLayers; |
| | 7 | | using DCLServices.MapRendererV2.MapLayers.Favorites; |
| | 8 | | using DCLServices.PlacesAPIService; |
| | 9 | | using MainScripts.DCL.Helpers.Utils; |
| | 10 | | using System.Collections.Generic; |
| | 11 | | using System.Threading; |
| | 12 | |
|
| | 13 | | namespace DCLServices.MapRendererV2.ComponentsFactory |
| | 14 | | { |
| | 15 | | internal struct FavoritesMarkersInstaller |
| | 16 | | { |
| | 17 | | private const int PREWARM_COUNT = 60; |
| | 18 | | private const string FAVORITES_MARKER_ADDRESS = "FavoritesMarker"; |
| | 19 | |
|
| | 20 | | private Service<IAddressableResourceProvider> addressablesProvider; |
| | 21 | |
|
| | 22 | | public async UniTask Install( |
| | 23 | | Dictionary<MapLayer, IMapLayerController> writer, |
| | 24 | | List<IZoomScalingLayer> zoomScalingWriter, |
| | 25 | | MapRendererConfiguration configuration, |
| | 26 | | ICoordsUtils coordsUtils, |
| | 27 | | IMapCullingController cullingController, |
| | 28 | | IPlacesAPIService placesAPIService, |
| | 29 | | CancellationToken cancellationToken |
| | 30 | | ) |
| | 31 | | { |
| 98 | 32 | | var prefab = await GetPrefab(cancellationToken); |
| | 33 | |
|
| 96 | 34 | | var objectsPool = new UnityObjectPool<FavoriteMarkerObject>( |
| | 35 | | prefab, |
| | 36 | | configuration.FavoritesMarkersRoot, |
| | 37 | | actionOnCreate: (obj) => |
| | 38 | | { |
| 44160 | 39 | | for (var i = 0; i < obj.renderers.Length; i++) |
| 16560 | 40 | | obj.renderers[i].sortingOrder = MapRendererDrawOrder.FAVORITES; |
| | 41 | |
|
| 5520 | 42 | | obj.title.sortingOrder = MapRendererDrawOrder.FAVORITES; |
| 5520 | 43 | | coordsUtils.SetObjectScale(obj); |
| 5520 | 44 | | }, |
| | 45 | | defaultCapacity: PREWARM_COUNT); |
| | 46 | |
|
| 96 | 47 | | var controller = new FavoritesMarkerController( |
| | 48 | | placesAPIService, |
| | 49 | | objectsPool, |
| | 50 | | CreateMarker, |
| | 51 | | PREWARM_COUNT, |
| | 52 | | configuration.FavoritesMarkersRoot, |
| | 53 | | coordsUtils, |
| | 54 | | cullingController |
| | 55 | | ); |
| | 56 | |
|
| 288 | 57 | | await controller.Initialize(cancellationToken); |
| 88 | 58 | | writer.Add(MapLayer.Favorites, controller); |
| 88 | 59 | | zoomScalingWriter.Add(controller); |
| 88 | 60 | | } |
| | 61 | |
|
| | 62 | | private static IFavoritesMarker CreateMarker(IUnityObjectPool<FavoriteMarkerObject> objectsPool, IMapCullingCont |
| 0 | 63 | | new FavoritesMarker(objectsPool, cullingController); |
| | 64 | |
|
| | 65 | | internal async UniTask<FavoriteMarkerObject> GetPrefab(CancellationToken cancellationToken) => |
| 98 | 66 | | await addressablesProvider.Ref.GetAddressable<FavoriteMarkerObject>(FAVORITES_MARKER_ADDRESS, cancellationTo |
| | 67 | |
|
| | 68 | | } |
| | 69 | | } |