< Summary

Class:DCL.ECSComponents.ECSTransformHandler
Assembly:DCL.ECSComponents.Transform.Handler
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/Transform/Handler/ECSTransformHandler.cs
Covered lines:17
Uncovered lines:3
Coverable lines:20
Total lines:49
Line coverage:85% (17 of 20)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ECSTransformHandler()0%110100%
OnComponentCreated(...)0%2100%
OnComponentRemoved(...)0%2.262060%
OnComponentModelUpdated(...)0%440100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/Transform/Handler/ECSTransformHandler.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.ECSRuntime;
 3using DCL.Models;
 4using UnityEngine;
 5
 6namespace DCL.ECSComponents
 7{
 8    public class ECSTransformHandler : IECSComponentHandler<ECSTransform>
 9    {
 810        public ECSTransformHandler()
 11        {
 812            ECSTransformUtils.orphanEntities = new KeyValueSet<IDCLEntity, ECSTransformUtils.OrphanEntity>(10);
 813        }
 14
 015        public void OnComponentCreated(IParcelScene scene, IDCLEntity entity) { }
 16
 17        public void OnComponentRemoved(IParcelScene scene, IDCLEntity entity)
 18        {
 119            if (entity.parentId != (long)SpecialEntityId.SCENE_ROOT_ENTITY)
 20            {
 021                entity.parentId = (long)SpecialEntityId.SCENE_ROOT_ENTITY;
 022                ECSTransformUtils.SetParent(scene, entity, (long)SpecialEntityId.SCENE_ROOT_ENTITY);
 23            }
 124            ECSTransformUtils.orphanEntities.Remove(entity);
 125        }
 26
 27        public void OnComponentModelUpdated(IParcelScene scene, IDCLEntity entity, ECSTransform model)
 28        {
 1029            Transform transform = entity.gameObject.transform;
 1030            transform.localPosition = model.position;
 1031            transform.localRotation = model.rotation;
 1032            transform.localScale = model.scale;
 33
 1034            if (entity.parentId != model.parentId)
 35            {
 636                entity.parentId = model.parentId;
 637                ECSTransformUtils.orphanEntities.Remove(entity);
 38
 39                // if `parentId` does not exist yet, we added to `orphanEntities` so system `ECSTransformParentingSystem
 40                // can retry parenting later
 641                long parentId = model.parentId != entity.entityId? model.parentId : (long)SpecialEntityId.SCENE_ROOT_ENT
 642                if (!ECSTransformUtils.SetParent(scene, entity, parentId))
 43                {
 344                    ECSTransformUtils.orphanEntities[entity] = new ECSTransformUtils.OrphanEntity(scene, entity, parentI
 45                }
 46            }
 1047        }
 48    }
 49}