< Summary

Class:DCL.Components.DCLTransform
Assembly:DCL.Components.Transform
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Transform/DCLTransform.cs
Covered lines:24
Uncovered lines:8
Coverable lines:32
Total lines:77
Line coverage:75% (24 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Model()0%110100%
GetDataFromJSON(...)0%110100%
DCLTransform()0%110100%
Cleanup()0%110100%
DCLTransform()0%110100%
GetTransform()0%2100%
Initialize(...)0%110100%
UpdateFromJSON(...)0%110100%
UpdateFromModel(...)0%220100%
ApplyChanges(...)0%2100%
RaiseOnAppliedChanges()0%2100%
IsValid()0%2100%
GetModel()0%110100%
GetClassId()0%2100%
UpdateOutOfBoundariesState(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Transform/DCLTransform.cs

#LineLine coverage
 1using System.Collections;
 2using DCL.Controllers;
 3using DCL.Helpers;
 4using DCL.Models;
 5using UnityEngine;
 6
 7namespace DCL.Components
 8{
 9    public class DCLTransform : IEntityComponent, IOutOfSceneBoundariesHandler
 10    {
 11        [System.Serializable]
 12        public class Model : BaseModel
 13        {
 8514            public Vector3 position = Vector3.zero;
 8515            public Quaternion rotation = Quaternion.identity;
 8516            public Vector3 scale = Vector3.one;
 17
 18            public override BaseModel GetDataFromJSON(string json)
 19            {
 24620                DCLTransformUtils.DecodeTransform(json, ref DCLTransform.model);
 24621                return DCLTransform.model;
 22            }
 23        }
 24
 125        public static Model model = new Model();
 26
 18127        public void Cleanup() { }
 28
 23429        public string componentName { get; } = "Transform";
 030        public IParcelScene scene { get; private set; }
 031        public IDCLEntity entity { get; private set; }
 032        public Transform GetTransform() => null;
 33
 34        public void Initialize(IParcelScene scene, IDCLEntity entity)
 35        {
 21936            this.scene = scene;
 21937            this.entity = entity;
 21938        }
 39
 40        public void UpdateFromJSON(string json)
 41        {
 24642            model.GetDataFromJSON(json);
 24643            UpdateFromModel(model);
 24644        }
 45
 46        public void UpdateFromModel(BaseModel model)
 47        {
 27848            DCLTransform.model = model as Model;
 49
 50            // AvatarShape interpolation hack: we don't apply avatars position and rotation directly to the transform
 51            // and those values are used for the interpolation.
 27852            if (entity.OnTransformChange != null)
 53            {
 154                entity.OnTransformChange.Invoke(DCLTransform.model);
 155            }
 56            else
 57            {
 27758                entity.gameObject.transform.localPosition = DCLTransform.model.position;
 27759                entity.gameObject.transform.localRotation = DCLTransform.model.rotation;
 60            }
 61
 27862            entity.gameObject.transform.localScale = DCLTransform.model.scale;
 27863            entity.gameObject.transform.CapGlobalValuesToMax();
 27864        }
 65
 066        public IEnumerator ApplyChanges(BaseModel model) { return null; }
 67
 068        public void RaiseOnAppliedChanges() { }
 69
 070        public bool IsValid() => true;
 171        public BaseModel GetModel() => DCLTransform.model;
 072        public int GetClassId() => (int) CLASS_ID_COMPONENT.TRANSFORM;
 073        public void UpdateOutOfBoundariesState(bool enable) { }
 74
 75
 76    }
 77}