| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using Cysharp.Threading.Tasks.Linq; |
| | 3 | | using DCL; |
| | 4 | | using DCL.Providers; |
| | 5 | | using DCLServices.MapRendererV2.CoordsUtils; |
| | 6 | | using DCLServices.MapRendererV2.Culling; |
| | 7 | | using DCLServices.MapRendererV2.MapLayers; |
| | 8 | | using DCLServices.MapRendererV2.MapLayers.HomePoint; |
| | 9 | | using System.Collections.Generic; |
| | 10 | | using System.Threading; |
| | 11 | | using UnityEngine; |
| | 12 | |
|
| | 13 | | namespace DCLServices.MapRendererV2.ComponentsFactory |
| | 14 | | { |
| | 15 | | internal struct HomePointMarkerInstaller |
| | 16 | | { |
| | 17 | | private const string HOME_POINT_MARKER_ADDRESS = "HomePoint"; |
| | 18 | |
|
| | 19 | | private Service<IAddressableResourceProvider> addressablesProvider; |
| | 20 | |
|
| | 21 | | public async UniTask Install( |
| | 22 | | Dictionary<MapLayer, IMapLayerController> writer, |
| | 23 | | List<IZoomScalingLayer> zoomScalingWriter, |
| | 24 | | MapRendererConfiguration configuration, |
| | 25 | | ICoordsUtils coordsUtils, |
| | 26 | | IMapCullingController cullingController, |
| | 27 | | CancellationToken cancellationToken |
| | 28 | | ) |
| | 29 | | { |
| 98 | 30 | | var prefab = await GetPrefab(cancellationToken); |
| | 31 | |
|
| | 32 | | IHomePointMarker CreateMarker(Transform parent) |
| | 33 | | { |
| 96 | 34 | | var obj = Object.Instantiate(prefab, configuration.HomePointRoot); |
| 96 | 35 | | obj.spriteRenderer.sortingOrder = MapRendererDrawOrder.HOME_POINT; |
| 96 | 36 | | coordsUtils.SetObjectScale(obj); |
| 96 | 37 | | return new HomePointMarker(obj); |
| | 38 | | } |
| | 39 | |
|
| 96 | 40 | | var controller = new HomePointMarkerController( |
| | 41 | | DataStore.i.HUDs.homePoint, |
| | 42 | | CreateMarker, |
| | 43 | | configuration.HomePointRoot, |
| | 44 | | coordsUtils, |
| | 45 | | cullingController); |
| | 46 | |
|
| 96 | 47 | | controller.Initialize(); |
| 96 | 48 | | writer.Add(MapLayer.HomePoint, controller); |
| 96 | 49 | | zoomScalingWriter.Add(controller); |
| 96 | 50 | | } |
| | 51 | |
|
| | 52 | | internal async UniTask<HomePointMarkerObject> GetPrefab(CancellationToken cancellationToken) => |
| 98 | 53 | | await addressablesProvider.Ref.GetAddressable<HomePointMarkerObject>(HOME_POINT_MARKER_ADDRESS, cancellation |
| | 54 | | } |
| | 55 | | } |