< Summary

Class:DCL.Controllers.ParcelSceneDebug.SceneDebugPlane
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneDebugPlane.cs
Covered lines:21
Uncovered lines:8
Coverable lines:29
Total lines:73
Line coverage:72.4% (21 of 29)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SceneDebugPlane(...)0%3.23072%
Dispose()0%3.023087.5%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneDebugPlane.cs

#LineLine coverage
 1using System;
 2using DCL.Configuration;
 3using DCL.Helpers;
 4using DCL.Models;
 5using UnityEngine;
 6
 7namespace DCL.Controllers.ParcelSceneDebug
 8{
 9    public class SceneDebugPlane : IDisposable
 10    {
 11        GameObject[] sceneParcelPlanes;
 12
 38613        public SceneDebugPlane(LoadParcelScenesMessage.UnityParcelScene sceneData, Transform parent)
 14        {
 38615            int sceneDataParcelsLength = sceneData.parcels.Length;
 38616            sceneParcelPlanes = new GameObject[sceneDataParcelsLength];
 17
 156018            for (int j = 0; j < sceneDataParcelsLength; j++)
 19            {
 39420                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
 39421                sceneParcelPlanes[j] = plane;
 22
 39423                UnityEngine.Object.Destroy(plane.GetComponent<MeshCollider>());
 24
 39425                plane.name = $"parcel:{sceneData.parcels[j].x},{sceneData.parcels[j].y}";
 26
 39427                plane.transform.SetParent(parent);
 28
 29                // the plane mesh with scale 1 occupies a 10 units space
 39430                plane.transform.localScale = new Vector3(ParcelSettings.PARCEL_SIZE * 0.1f, 1f,
 31                    ParcelSettings.PARCEL_SIZE * 0.1f);
 32
 39433                Vector3 position = Utils.GridToWorldPosition(sceneData.parcels[j].x, sceneData.parcels[j].y);
 34                // SET TO A POSITION RELATIVE TO basePosition
 35
 39436                position.Set(position.x + ParcelSettings.PARCEL_SIZE / 2, ParcelSettings.DEBUG_FLOOR_HEIGHT,
 37                    position.z + ParcelSettings.PARCEL_SIZE / 2);
 38
 39439                plane.transform.position = PositionUtils.WorldToUnityPosition(position);
 40
 39441                if (DCL.Configuration.ParcelSettings.VISUAL_LOADING_ENABLED)
 42                {
 043                    Material finalMaterial = Utils.EnsureResourcesMaterial("Materials/DefaultPlane");
 044                    var matTransition = plane.AddComponent<MaterialTransitionController>();
 045                    matTransition.delay = 0;
 046                    matTransition.useHologram = false;
 047                    matTransition.fadeThickness = 20;
 048                    matTransition.OnDidFinishLoading(finalMaterial);
 049                }
 50                else
 51                {
 39452                    plane.GetComponent<MeshRenderer>().sharedMaterial =
 53                        Utils.EnsureResourcesMaterial("Materials/DefaultPlane");
 54                }
 55            }
 38656        }
 57
 58        public void Dispose()
 59        {
 37760            if (sceneParcelPlanes == null)
 61            {
 062                return;
 63            }
 64
 152465            for (int i = 0; i < sceneParcelPlanes.Length; i++)
 66            {
 38567                UnityEngine.Object.Destroy(sceneParcelPlanes[i]);
 68            }
 69
 37770            sceneParcelPlanes = null;
 37771        }
 72    }
 73}