< Summary

Class:DCL.UserPositionMarker
Assembly:GlobalUsersPositionMarker
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/MapRenderer/GlobalUsersPositionMarker/Utils/UserPositionMarker.cs
Covered lines:19
Uncovered lines:6
Coverable lines:25
Total lines:60
Line coverage:76% (19 of 25)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
UserPositionMarker(...)0%110100%
SetActive(...)0%220100%
Dispose()0%110100%
OnRealmChanged(...)0%64050%
SetColor(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/MapRenderer/GlobalUsersPositionMarker/Utils/UserPositionMarker.cs

#LineLine coverage
 1using UnityEngine;
 2using System;
 3using Variables.RealmsInfo;
 4
 5namespace DCL
 6{
 7    /// <summary>
 8    /// Wrapper class to handle user's marker GameObject
 9    /// </summary>
 10    internal class UserPositionMarker : IDisposable
 11    {
 012        public Vector2Int coords { set; get; }
 013        public string realmServer { set; get; }
 014        public string realmLayer { set; get; }
 15
 1016        public string name { set { markerObject.name = value; } }
 17
 1018        public Vector3 localPosition { set { markerObject.transform.localPosition = value; } }
 19
 20        private UserMarkerObject markerObject;
 21
 1110522        public UserPositionMarker(UserMarkerObject markerObject)
 23        {
 1110524            this.markerObject = markerObject;
 1110525            markerObject.gameObject.SetActive(false);
 1110526        }
 27
 28        public void SetActive(bool active)
 29        {
 1111430            if (active)
 31            {
 732                OnRealmChanged(DataStore.i.playerRealm.Get(), null);
 733                DataStore.i.playerRealm.OnChange -= OnRealmChanged;
 734                DataStore.i.playerRealm.OnChange += OnRealmChanged;
 735            }
 36            else
 37            {
 1110738                DataStore.i.playerRealm.OnChange -= OnRealmChanged;
 39            }
 40
 1111441            markerObject.gameObject.SetActive(active);
 1111442        }
 43
 44        public void Dispose()
 45        {
 1110546            DataStore.i.playerRealm.OnChange -= OnRealmChanged;
 1110547            GameObject.Destroy(markerObject.gameObject);
 1110548        }
 49
 50        private void OnRealmChanged(CurrentRealmModel current, CurrentRealmModel prev)
 51        {
 752            if (current == null)
 753                return;
 54
 055            SetColor(current.Equals(realmServer, realmLayer) ? markerObject.sameRealmColor : markerObject.otherRealmColo
 056        }
 57
 058        private void SetColor(Color color) { markerObject.color = color; }
 59    }
 60}