< Summary

Class:ECSSystems.ECSSceneBoundsCheckerSystem.ECSOutOfSceneBoundsFeedback_RedWireframe
Assembly:ECS7Plugin.Systems.ECSSceneBoundsChecker
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/Systems/SceneBoundsCheckerSystem/OutOfSceneBoundsFeedbackStyle/ECSOutOfSceneBoundsFeedback_RedWireframe.cs
Covered lines:0
Uncovered lines:27
Coverable lines:27
Total lines:72
Line coverage:0% (0 of 27)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:5
Method coverage:0% (0 of 5)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ECSOutOfSceneBoundsFeedback_RedWireframe()0%2100%
ApplyFeedback(...)0%42600%
AddInvalidMeshEffect(...)0%6200%
RemoveInvalidMeshEffect(...)0%6200%
PutWireframeAroundObject(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/Systems/SceneBoundsCheckerSystem/OutOfSceneBoundsFeedbackStyle/ECSOutOfSceneBoundsFeedback_RedWireframe.cs

#LineLine coverage
 1using DCL.ECS7.InternalComponents;
 2using DCL.Helpers;
 3using DCL.Models;
 4using System.Collections.Generic;
 5using UnityEngine;
 6
 7namespace ECSSystems.ECSSceneBoundsCheckerSystem
 8{
 9    public class ECSOutOfSceneBoundsFeedback_RedWireframe : IECSOutOfSceneBoundsFeedbackStyle
 10    {
 11        const string WIREFRAME_PREFAB_NAME = "Prefabs/WireframeCubeMesh";
 12
 013        private Dictionary<IDCLEntity, GameObject> wireframeGameObjects = new Dictionary<IDCLEntity, GameObject>();
 14
 15        public void ApplyFeedback(IDCLEntity entity, InternalSceneBoundsCheck sbcComponentModel, bool isVisible, bool is
 16        {
 017            if (isInsideBounds)
 018                RemoveInvalidMeshEffect(entity);
 19            else
 020                AddInvalidMeshEffect(entity, sbcComponentModel);
 21
 022            KeyValueSet<Collider, uint> physicsColliders = sbcComponentModel.physicsColliders;
 023            KeyValueSet<Collider, uint> pointerColliders = sbcComponentModel.pointerColliders;
 24
 025            if (physicsColliders != null)
 26            {
 027                var pairs = physicsColliders.Pairs;
 028                for (int i = 0; i < pairs.Count; i++)
 29                {
 030                    pairs[i].key.enabled = isInsideBounds;
 31                }
 32            }
 33
 034            if (pointerColliders != null)
 35            {
 036                var pairs = pointerColliders.Pairs;
 037                for (int i = 0; i < pairs.Count; i++)
 38                {
 039                    pairs[i].key.enabled = isInsideBounds;
 40                }
 41            }
 042        }
 43
 44        private void AddInvalidMeshEffect(IDCLEntity entity, InternalSceneBoundsCheck sbcComponentModel)
 45        {
 046            if (wireframeGameObjects.ContainsKey(entity)) return;
 47
 48            // Wireframe that shows the boundaries to the dev (We don't use the GameObject.Instantiate(prefab, parent)
 49            // overload because we need to set the position and scale before parenting, to deal with scaled objects)
 050            wireframeGameObjects.Add(entity, PutWireframeAroundObject(sbcComponentModel.entityLocalMeshBounds, entity.ga
 051        }
 52
 53        private void RemoveInvalidMeshEffect(IDCLEntity entity)
 54        {
 055            if (!wireframeGameObjects.ContainsKey(entity)) return;
 56
 057            Utils.SafeDestroy(wireframeGameObjects[entity]);
 058            wireframeGameObjects.Remove(entity);
 059        }
 60
 61        private GameObject PutWireframeAroundObject(Bounds target, Transform parent)
 62        {
 63            // Wireframe that shows the boundaries to the dev (We don't use the GameObject.Instantiate(prefab, parent)
 64            // overload because we need to set the position and scale before parenting, to deal with scaled objects)
 065            GameObject wireframeGO = Object.Instantiate(Resources.Load<GameObject>(WIREFRAME_PREFAB_NAME));
 066            wireframeGO.transform.localScale = target.size * 1.01f;
 067            wireframeGO.transform.SetParent(parent);
 068            wireframeGO.transform.localPosition = target.min + (target.max - target.min) * 0.5f;
 069            return wireframeGO;
 70        }
 71    }
 72}