< Summary

Class:DCL.Components.OnPointerHoverEvent
Assembly:DCL.Components.Events
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/UUIDEventComponentsPlugin/UUIDComponent/OnPointerHoverEvent.cs
Covered lines:26
Uncovered lines:2
Coverable lines:28
Total lines:87
Line coverage:92.8% (26 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Model()0%110100%
GetDataFromJSON(...)0%110100%
Initialize(...)0%220100%
SetHoverState(...)0%110100%
SetEventColliders(...)0%110100%
IsVisible()0%5.125083.33%
IsAtHoverDistance(...)0%110100%
ApplyChanges(...)0%220100%
OnDestroy()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/UUIDEventComponentsPlugin/UUIDComponent/OnPointerHoverEvent.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using DCL.Controllers;
 4using DCL.Helpers;
 5using DCL.Models;
 6using DCLPlugins.UUIDEventComponentsPlugin.UUIDComponent.Interfaces;
 7
 8namespace DCL.Components
 9{
 10    public class OnPointerHoverEvent : UUIDComponent, IPointerEvent
 11    {
 12        [Serializable]
 13        public new class Model : UUIDComponent.Model
 14        {
 6015            public float distance = 10f;
 16
 17            public override BaseModel GetDataFromJSON(string json)
 18            {
 2119                return Utils.SafeFromJson<Model>(json);
 20            }
 21        }
 22
 23        internal OnPointerEventColliders pointerEventColliders;
 24
 025        protected override string uuidComponentName { get; }
 26
 27        public override void Initialize(IParcelScene scene, IDCLEntity entity)
 28        {
 2129            base.Initialize(scene, entity);
 30
 2131            if (model == null)
 2132                model = new Model();
 33
 2134            pointerEventColliders = new OnPointerEventColliders();
 2135            SetEventColliders(entity);
 36
 2137            entity.OnShapeUpdated -= SetEventColliders;
 2138            entity.OnShapeUpdated += SetEventColliders;
 2139        }
 40
 41        public virtual void SetHoverState(bool hoverState)
 42        {
 1043        }
 44
 45        void SetEventColliders(IDCLEntity entity)
 46        {
 3347            pointerEventColliders.Initialize(entity);
 3348        }
 49
 50        public bool IsVisible()
 51        {
 852            if (entity == null)
 053                return false;
 54
 855            bool isVisible = false;
 56
 857            if (entity.meshesInfo != null &&
 58                entity.meshesInfo.renderers != null &&
 59                entity.meshesInfo.renderers.Length > 0)
 60            {
 861                isVisible = entity.meshesInfo.renderers[0].enabled;
 62            }
 63
 864            return isVisible;
 65        }
 66
 67        public bool IsAtHoverDistance(float distance)
 68        {
 869            Model model = this.model as Model;
 870            return distance <= model.distance;
 71        }
 72
 73        public override IEnumerator ApplyChanges(BaseModel newModel)
 74        {
 2175            this.model = newModel ?? new Model();
 2176            return null;
 77        }
 78
 79        void OnDestroy()
 80        {
 2181            if (entity != null)
 2182                entity.OnShapeUpdated -= SetEventColliders;
 83
 2184            pointerEventColliders.Dispose();
 2185        }
 86    }
 87}