< 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
 100522        public UserPositionMarker(UserMarkerObject markerObject)
 23        {
 100524            this.markerObject = markerObject;
 100525            markerObject.gameObject.SetActive(false);
 100526        }
 27
 28        public void SetActive(bool active)
 29        {
 101430            if (active)
 31            {
 732                OnRealmChanged(DataStore.i.realm.playerRealm.Get(), null);
 733                DataStore.i.realm.playerRealm.OnChange -= OnRealmChanged;
 734                DataStore.i.realm.playerRealm.OnChange += OnRealmChanged;
 735            }
 36            else
 37            {
 100738                DataStore.i.realm.playerRealm.OnChange -= OnRealmChanged;
 39            }
 40
 101441            markerObject.gameObject.SetActive(active);
 101442        }
 43
 44        public void Dispose()
 45        {
 100546            DataStore.i.realm.playerRealm.OnChange -= OnRealmChanged;
 100547            UnityEngine.Object.Destroy(markerObject.gameObject);
 100548        }
 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}