< Summary

Class:DCL.Components.BaseComponent
Assembly:DCL.Runtime.Interfaces
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/Interfaces/BaseComponent.cs
Covered lines:27
Uncovered lines:5
Coverable lines:32
Total lines:83
Line coverage:84.3% (27 of 32)
Covered branches:0
Total branches:0
Covered methods:20
Total methods:23
Method coverage:86.9% (20 of 23)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
get_componentName()0%110100%
RaiseOnAppliedChanges()0%110100%
Initialize(...)0%220100%
UpdateFromJSON(...)0%110100%
UpdateFromPb(...)0%2100%
UpdateFromModel(...)0%110100%
OnEnable()0%220100%
GetModel()0%110100%
CreateUpdateHandler()0%110100%
IsValid()0%110100%
Cleanup()0%220100%
OnPoolRelease()0%110100%
OnPoolGet()0%2.152066.67%
GetTransform()0%110100%

File(s)

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

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Models;
 3using System.Collections;
 4using UnityEngine;
 5using Decentraland.Sdk.Ecs6;
 6
 7namespace DCL.Components
 8{
 9    public abstract class BaseComponent : MonoBehaviour, IEntityComponent, IDelayedComponent, IPoolLifecycleHandler, IPo
 10    {
 11        protected ComponentUpdateHandler updateHandler;
 012        public CustomYieldInstruction yieldInstruction => updateHandler.yieldInstruction;
 10213        public Coroutine routine => updateHandler.routine;
 014        public bool isRoutineRunning => updateHandler.isRoutineRunning;
 15
 29216        public IParcelScene scene { get; set; }
 17
 4707218        public IDCLEntity entity { get; set; }
 19
 75620        public IPoolableObject poolableObject { get; set; }
 21
 8122        string IComponent.componentName => componentName;
 23
 24        public abstract string componentName { get; }
 25
 26        protected BaseModel model;
 27
 15528        public void RaiseOnAppliedChanges() { }
 29
 30        public virtual void Initialize(IParcelScene scene, IDCLEntity entity)
 31        {
 11232            this.scene = scene;
 11233            this.entity = entity;
 34
 11235            if (transform.parent != entity.gameObject.transform)
 11236                transform.SetParent(entity.gameObject.transform, false);
 11237        }
 38
 31039        public virtual void UpdateFromJSON(string json) { UpdateFromModel(model.GetDataFromJSON(json)); }
 40
 41        public virtual void UpdateFromPb(ComponentBodyPayload payload)
 42        {
 043            UpdateFromModel(model.GetDataFromPb(payload));
 044        }
 45
 46        public virtual void UpdateFromModel(BaseModel newModel)
 47        {
 15748            model = newModel;
 15749            updateHandler.ApplyChangesIfModified(model);
 15750        }
 51
 52        public abstract IEnumerator ApplyChanges(BaseModel model);
 53
 54        protected void OnEnable()
 55        {
 73856            if (updateHandler == null)
 72657                updateHandler = CreateUpdateHandler();
 73858        }
 59
 260        public virtual BaseModel GetModel() => model;
 61
 72662        protected virtual ComponentUpdateHandler CreateUpdateHandler() { return new ComponentUpdateHandler(this); }
 63
 15764        public bool IsValid() { return this != null; }
 65
 66        public virtual void Cleanup()
 67        {
 70068            updateHandler?.Cleanup();
 70069        }
 70
 3871        public virtual void OnPoolRelease() { Cleanup(); }
 72
 73        public virtual void OnPoolGet()
 74        {
 1275            if (updateHandler == null)
 076                updateHandler = CreateUpdateHandler();
 1277        }
 78
 79        public abstract int GetClassId();
 80
 3181        public Transform GetTransform() => transform;
 82    }
 83}