< Summary

Class:DCL.Controllers.SceneUtils
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/Utils/SceneUtils.cs
Covered lines:11
Uncovered lines:10
Coverable lines:21
Total lines:50
Line coverage:52.3% (11 of 21)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DuplicateEntity(...)0%11.177056%

File(s)

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

#LineLine coverage
 1using System.Collections.Generic;
 2using DCL.Components;
 3using DCL.Models;
 4
 5namespace DCL.Controllers
 6{
 7    public static class SceneUtils
 8    {
 9        public static IDCLEntity DuplicateEntity(ParcelScene scene, IDCLEntity entity)
 10        {
 311            if (!scene.entities.ContainsKey(entity.entityId))
 012                return null;
 13
 314            IDCLEntity newEntity = scene.CreateEntity(System.Guid.NewGuid().ToString());
 15
 316            if (entity.children.Count > 0)
 17            {
 018                using (var iterator = entity.children.GetEnumerator())
 19                {
 020                    while (iterator.MoveNext())
 21                    {
 022                        IDCLEntity childDuplicate = DuplicateEntity(scene, iterator.Current.Value);
 023                        childDuplicate.SetParent(newEntity);
 24                    }
 025                }
 26            }
 27
 328            if (entity.parent != null)
 029                scene.SetEntityParent(newEntity.entityId, entity.parent.entityId);
 30
 331            DCLTransform.model.position = WorldStateUtils.ConvertUnityToScenePosition(entity.gameObject.transform.positi
 332            DCLTransform.model.rotation = entity.gameObject.transform.rotation;
 333            DCLTransform.model.scale = entity.gameObject.transform.lossyScale;
 34
 835            foreach (KeyValuePair<CLASS_ID_COMPONENT, IEntityComponent> component in entity.components)
 36            {
 137                scene.EntityComponentCreateOrUpdateWithModel(newEntity.entityId, component.Key, component.Value.GetModel
 38            }
 39
 640            foreach (KeyValuePair<System.Type, ISharedComponent> component in entity.sharedComponents)
 41            {
 042                ISharedComponent sharedComponent = scene.SharedComponentCreate(System.Guid.NewGuid().ToString(), compone
 043                sharedComponent.UpdateFromModel(component.Value.GetModel());
 044                scene.SharedComponentAttach(newEntity.entityId, sharedComponent.id);
 45            }
 46
 347            return newEntity;
 48        }
 49    }
 50}