| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using Cysharp.Threading.Tasks.Linq; |
| | 3 | | using DCL; |
| | 4 | | using DCL.Providers; |
| | 5 | | using DCL.Social.Friends; |
| | 6 | | using DCLServices.MapRendererV2.CoordsUtils; |
| | 7 | | using DCLServices.MapRendererV2.Culling; |
| | 8 | | using DCLServices.MapRendererV2.MapLayers; |
| | 9 | | using DCLServices.MapRendererV2.MapLayers.UsersMarkers.Friends; |
| | 10 | | using DCLServices.MapRendererV2.MapLayers.UsersMarkers.HotArea; |
| | 11 | | using MainScripts.DCL.Helpers.Utils; |
| | 12 | | using System.Collections.Generic; |
| | 13 | | using System.Threading; |
| | 14 | | using System.Threading.Tasks; |
| | 15 | | using UnityEngine; |
| | 16 | | using UnityEngine.Pool; |
| | 17 | |
|
| | 18 | | namespace DCLServices.MapRendererV2.ComponentsFactory |
| | 19 | | { |
| | 20 | | internal struct FriendUsersMarkersInstaller |
| | 21 | | { |
| | 22 | | private const string FRIEND_USER_MARKER_ADDRESS = "FriendUserMarker"; |
| | 23 | | private const int FRIEND_USER_MARKERS_PREWARM_COUNT = 30; |
| | 24 | |
|
| | 25 | | private Service<IAddressableResourceProvider> addressablesProvider; |
| | 26 | |
|
| | 27 | | public async UniTask Install( |
| | 28 | | Dictionary<MapLayer, IMapLayerController> writer, |
| | 29 | | List<IZoomScalingLayer> zoomScalingWriter, |
| | 30 | | MapRendererConfiguration configuration, |
| | 31 | | ICoordsUtils coordsUtils, |
| | 32 | | IMapCullingController cullingController, |
| | 33 | | IUserProfileBridge userProfileBridge, |
| | 34 | | IFriendsController friendsController, |
| | 35 | | CancellationToken cancellationToken) |
| | 36 | | { |
| 98 | 37 | | var prefab = await GetPrefab(cancellationToken); |
| | 38 | |
|
| | 39 | | void OnCreate(FriendUserMarkerObject obj) |
| | 40 | | { |
| 16980 | 41 | | for (var i = 0; i < obj.spriteRenderers.Length; i++) |
| 5660 | 42 | | obj.spriteRenderers[i].sortingOrder = MapRendererDrawOrder.FRIEND_USER_MARKERS; |
| | 43 | |
|
| 2830 | 44 | | obj.profileName.sortingOrder = MapRendererDrawOrder.FRIEND_USER_MARKERS; |
| 2830 | 45 | | coordsUtils.SetObjectScale(obj); |
| 2830 | 46 | | } |
| | 47 | |
|
| 96 | 48 | | var objectsPool = new UnityObjectPool<FriendUserMarkerObject>(prefab, configuration.FriendUserMarkersRoot, a |
| | 49 | |
|
| | 50 | | IFriendUserMarker CreateWrap() => |
| 2880 | 51 | | new FriendUserMarker(objectsPool, cullingController, coordsUtils, CommonScriptableObjects.worldOffset); |
| | 52 | |
|
| 2976 | 53 | | var wrapsPool = new ObjectPool<IFriendUserMarker>(CreateWrap, actionOnRelease: m => m.Dispose(), defaultCapa |
| | 54 | |
|
| 96 | 55 | | var controller = new FriendsMarkersAreaController( |
| | 56 | | DataStore.i.player.otherPlayers, |
| | 57 | | objectsPool, |
| | 58 | | wrapsPool, |
| | 59 | | FRIEND_USER_MARKERS_PREWARM_COUNT, |
| | 60 | | configuration.HotUserMarkersRoot, |
| | 61 | | coordsUtils, cullingController, |
| | 62 | | userProfileBridge, |
| | 63 | | friendsController); |
| | 64 | |
|
| 288 | 65 | | await controller.Initialize(cancellationToken); |
| 89 | 66 | | writer.Add(MapLayer.Friends, controller); |
| 89 | 67 | | zoomScalingWriter.Add(controller); |
| 89 | 68 | | } |
| | 69 | |
|
| | 70 | | internal async Task<FriendUserMarkerObject> GetPrefab(CancellationToken cancellationToken) => |
| 98 | 71 | | await addressablesProvider.Ref.GetAddressable<FriendUserMarkerObject>(FRIEND_USER_MARKER_ADDRESS, cancellati |
| | 72 | | } |
| | 73 | | } |