| | 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.PlayerMarker; |
| | 8 | | using System.Collections.Generic; |
| | 9 | | using System.Threading; |
| | 10 | | using UnityEngine; |
| | 11 | |
|
| | 12 | | namespace DCLServices.MapRendererV2.ComponentsFactory |
| | 13 | | { |
| | 14 | | internal struct PlayerMarkerInstaller |
| | 15 | | { |
| | 16 | | private const string PLAYER_MARKER_ADDRESS = "PlayerMarker"; |
| | 17 | |
|
| | 18 | | private Service<IAddressableResourceProvider> addressablesProvider; |
| | 19 | |
|
| | 20 | | public async UniTask Install( |
| | 21 | | Dictionary<MapLayer, IMapLayerController> writer, |
| | 22 | | List<IZoomScalingLayer> zoomScalingWriter, |
| | 23 | | MapRendererConfiguration configuration, |
| | 24 | | ICoordsUtils coordsUtils, |
| | 25 | | IMapCullingController cullingController, |
| | 26 | | CancellationToken cancellationToken) |
| | 27 | | { |
| 98 | 28 | | PlayerMarkerObject prefab = await GetPrefab(cancellationToken); |
| | 29 | |
|
| 96 | 30 | | var controller = new PlayerMarkerController( |
| | 31 | | CreateMarker, |
| | 32 | | DataStore.i.player.playerWorldPosition, |
| | 33 | | CommonScriptableObjects.cameraForward, |
| | 34 | | configuration.PlayerMarkerRoot, |
| | 35 | | coordsUtils, |
| | 36 | | cullingController |
| | 37 | | ); |
| | 38 | |
|
| 96 | 39 | | controller.Initialize(); |
| | 40 | |
|
| 96 | 41 | | writer.Add(MapLayer.PlayerMarker, controller); |
| 96 | 42 | | zoomScalingWriter.Add(controller); |
| 96 | 43 | | return; |
| | 44 | |
|
| | 45 | | IPlayerMarker CreateMarker(Transform parent) |
| | 46 | | { |
| 96 | 47 | | PlayerMarkerObject pmObject = Object.Instantiate(prefab, parent); |
| 96 | 48 | | coordsUtils.SetObjectScale(pmObject); |
| 96 | 49 | | pmObject.SetSortingOrder(MapRendererDrawOrder.PLAYER_MARKER); |
| | 50 | |
|
| 96 | 51 | | if (DataStore.i.featureFlags.flags.Get().IsInitialized) |
| 0 | 52 | | pmObject.SetAnimatedCircleVisibility(DataStore.i.featureFlags.flags.Get().IsFeatureEnabled("map_focu |
| | 53 | | else |
| 616 | 54 | | DataStore.i.featureFlags.flags.OnChange += (current, previous) => { pmObject.SetAnimatedCircleVisibi |
| | 55 | |
|
| 96 | 56 | | return new PlayerMarker(pmObject); |
| | 57 | | } |
| 96 | 58 | | } |
| | 59 | |
|
| | 60 | | internal async UniTask<PlayerMarkerObject> GetPrefab(CancellationToken cancellationToken) => |
| 98 | 61 | | await addressablesProvider.Ref.GetAddressable<PlayerMarkerObject>(PLAYER_MARKER_ADDRESS, cancellationToken); |
| | 62 | | } |
| | 63 | | } |