< Summary

Class:DCLServices.MapRendererV2.MapLayers.HomePoint.HomePointMarkerController
Assembly:MapRendererV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/MapRendererV2/MapLayers/HomePoint/HomePointMarkerController.cs
Covered lines:10
Uncovered lines:12
Coverable lines:22
Total lines:77
Line coverage:45.4% (10 of 22)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:8
Method coverage:37.5% (3 of 8)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
HomePointMarkerController(...)0%110100%
ApplyCameraZoom(...)0%2100%
ResetToBaseScale()0%2100%
Initialize()0%110100%
SetMarkerPosition(...)0%2100%
Enable(...)0%2100%
Disable(...)0%110100%
OnHomePointCoordinatesChange(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/MapRendererV2/MapLayers/HomePoint/HomePointMarkerController.cs

#LineLine coverage
 1using Cysharp.Threading.Tasks;
 2using DCLServices.MapRendererV2.CoordsUtils;
 3using DCLServices.MapRendererV2.Culling;
 4using DCLServices.MapRendererV2.MapCameraController;
 5using System;
 6using System.Threading;
 7using UnityEngine;
 8
 9namespace DCLServices.MapRendererV2.MapLayers.HomePoint
 10{
 11    internal class HomePointMarkerController : MapLayerControllerBase, IMapLayerController, IZoomScalingLayer
 12    {
 13        internal delegate IHomePointMarker HomePointMarkerBuilder(Transform parent);
 14
 15        private readonly BaseVariable<Vector2Int> homePointCoordinates;
 16        private readonly HomePointMarkerBuilder builder;
 17
 18        private IHomePointMarker marker;
 19
 20        public HomePointMarkerController(
 21            BaseVariable<Vector2Int> homePointCoordinates,
 22            HomePointMarkerBuilder builder,
 23            Transform instantiationParent,
 24            ICoordsUtils coordsUtils,
 25            IMapCullingController cullingController)
 9626            : base(instantiationParent, coordsUtils, cullingController)
 27        {
 9628            this.homePointCoordinates = homePointCoordinates;
 9629            this.builder = builder;
 9630        }
 31
 32        public void ApplyCameraZoom(float baseZoom, float zoom)
 33        {
 034            marker.SetZoom(baseZoom, zoom);
 035        }
 36
 37        public void ResetToBaseScale()
 38        {
 039            marker.ResetToBaseScale();
 040        }
 41
 42        public void Initialize()
 43        {
 9644            marker = builder(instantiationParent);
 9645            marker.SetActive(false);
 9646        }
 47
 48        private void SetMarkerPosition(Vector2Int position)
 49        {
 050            marker.SetPosition(coordsUtils.CoordsToPosition(position));
 051        }
 52
 53        public UniTask Enable(CancellationToken cancellationToken)
 54        {
 055            marker.SetActive(true);
 056            SetMarkerPosition(homePointCoordinates.Get());
 57
 058            homePointCoordinates.OnChange += OnHomePointCoordinatesChange;
 59
 060            return UniTask.CompletedTask;
 61        }
 62
 63        public UniTask Disable(CancellationToken cancellationToken)
 64        {
 8865            marker.SetActive(false);
 66
 8867            homePointCoordinates.OnChange -= OnHomePointCoordinatesChange;
 68
 8869            return UniTask.CompletedTask;
 70        }
 71
 72        private void OnHomePointCoordinatesChange(Vector2Int current, Vector2Int previous)
 73        {
 074            SetMarkerPosition(current);
 075        }
 76    }
 77}