< Summary

Class:DCLServices.MapRendererV2.MapLayers.Favorites.FavoritesMarker
Assembly:MapRendererV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/MapRendererV2/MapLayers/Favorites/FavoritesMarker.cs
Covered lines:0
Uncovered lines:29
Coverable lines:29
Total lines:75
Line coverage:0% (0 of 29)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:12
Method coverage:0% (0 of 12)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FavoritesMarker(...)0%2100%
SetData(...)0%12300%
OnBecameVisible()0%6200%
OnBecameInvisible()0%2100%
SetZoom(...)0%6200%
ResetScale(...)0%6200%
Dispose()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/MapRendererV2/MapLayers/Favorites/FavoritesMarker.cs

#LineLine coverage
 1using DCLServices.MapRendererV2.CommonBehavior;
 2using DCLServices.MapRendererV2.Culling;
 3using MainScripts.DCL.Helpers.Utils;
 4using System;
 5using UnityEngine;
 6
 7namespace DCLServices.MapRendererV2.MapLayers.Favorites
 8{
 9    internal class FavoritesMarker : IFavoritesMarker
 10    {
 11        internal const int MAX_TITLE_LENGTH = 29;
 12        private float currentBaseScale;
 13        private float currentNewScale;
 14
 015        public Vector3 CurrentPosition => poolableBehavior.currentPosition;
 16
 017        public bool IsVisible => poolableBehavior.isVisible;
 18
 019        public Vector2 Pivot => poolableBehavior.objectsPool.Prefab.pivot;
 20
 021        internal string title { get; private set; }
 22
 23        private MapMarkerPoolableBehavior<FavoriteMarkerObject> poolableBehavior;
 24
 25        private readonly IMapCullingController cullingController;
 26
 027        public FavoritesMarker(IUnityObjectPool<FavoriteMarkerObject> objectsPool, IMapCullingController cullingControll
 28        {
 029            poolableBehavior = new MapMarkerPoolableBehavior<FavoriteMarkerObject>(objectsPool);
 030            this.cullingController = cullingController;
 031        }
 32
 33        public void SetData(string title, Vector3 position)
 34        {
 035            poolableBehavior.SetCurrentPosition(position);
 036            this.title = title.Length > MAX_TITLE_LENGTH ? title.Substring(0, MAX_TITLE_LENGTH) : title;
 037        }
 38
 39        public void OnBecameVisible()
 40        {
 041            poolableBehavior.OnBecameVisible().title.text = title;
 42
 043            if(currentBaseScale != 0)
 044                poolableBehavior.instance.SetScale(currentBaseScale, currentNewScale);
 045        }
 46
 47        public void OnBecameInvisible()
 48        {
 049            poolableBehavior.OnBecameInvisible();
 050        }
 51
 52        public void SetZoom(float baseScale, float baseZoom, float zoom)
 53        {
 054            currentBaseScale = baseScale;
 055            currentNewScale = Math.Max(zoom / baseZoom * baseScale, baseScale);
 56
 057            if (poolableBehavior.instance != null)
 058                poolableBehavior.instance.SetScale(currentBaseScale, currentNewScale);
 059        }
 60
 61        public void ResetScale(float scale)
 62        {
 063            currentNewScale = scale;
 64
 065            if (poolableBehavior.instance != null)
 066                poolableBehavior.instance.SetScale(scale, scale);
 067        }
 68
 69        public void Dispose()
 70        {
 071            OnBecameInvisible();
 072            cullingController.StopTracking(this);
 073        }
 74    }
 75}