< Summary

Class:DCL.Components.DCLTransform
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Transform/DCLTransform.cs
Covered lines:24
Uncovered lines:7
Coverable lines:31
Total lines:72
Line coverage:77.4% (24 of 31)
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%330100%
ApplyChanges(...)0%2100%
RaiseOnAppliedChanges()0%2100%
IsValid()0%2100%
GetModel()0%110100%
GetClassId()0%2100%

File(s)

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

#LineLine coverage
 1using System.Collections;
 2using System.Net.Configuration;
 3using DCL.Controllers;
 4using DCL.Models;
 5using UnityEngine;
 6
 7namespace DCL.Components
 8{
 9    public class DCLTransform : IEntityComponent
 10    {
 11        [System.Serializable]
 12        public class Model : BaseModel
 13        {
 6614            public Vector3 position = Vector3.zero;
 6615            public Quaternion rotation = Quaternion.identity;
 6616            public Vector3 scale = Vector3.one;
 17
 18            public override BaseModel GetDataFromJSON(string json)
 19            {
 23020                MessageDecoder.DecodeTransform(json, ref DCLTransform.model);
 23021                return DCLTransform.model;
 22            }
 23        }
 24
 125        public static Model model = new Model();
 26
 6027        public void Cleanup() { }
 28
 20429        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        {
 20436            this.scene = scene;
 20437            this.entity = entity;
 20438        }
 39
 40        public void UpdateFromJSON(string json)
 41        {
 23042            model.GetDataFromJSON(json);
 23043            UpdateFromModel(model);
 23044        }
 45
 46        public void UpdateFromModel(BaseModel model)
 47        {
 26248            DCLTransform.model = model as Model;
 49
 26250            if (entity.OnTransformChange != null) // AvatarShape interpolation hack
 51            {
 152                entity.OnTransformChange.Invoke(DCLTransform.model);
 153            }
 54            else
 55            {
 26156                entity.gameObject.transform.localPosition = DCLTransform.model.position;
 26157                entity.gameObject.transform.localRotation = DCLTransform.model.rotation;
 26158                entity.gameObject.transform.localScale = DCLTransform.model.scale;
 59
 26160                DCL.Environment.i.world.sceneBoundsChecker?.AddEntityToBeChecked(entity);
 61            }
 26162        }
 63
 064        public IEnumerator ApplyChanges(BaseModel model) { return null; }
 65
 066        public void RaiseOnAppliedChanges() { }
 67
 068        public bool IsValid() => true;
 169        public BaseModel GetModel() => DCLTransform.model;
 070        public int GetClassId() => (int) CLASS_ID_COMPONENT.TRANSFORM;
 71    }
 72}