< Summary

Class:DCL.Components.AvatarAttachComponent
Assembly:AvatarAttach
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/AvatarAttach/AvatarAttachComponent.cs
Covered lines:10
Uncovered lines:16
Coverable lines:26
Total lines:79
Line coverage:38.4% (10 of 26)
Covered branches:0
Total branches:0
Covered methods:8
Total methods:17
Method coverage:47% (8 of 17)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetDataFromJSON(...)0%110100%
GetDataFromPb(...)0%20400%
get_scene()0%2100%
get_entity()0%2100%
get_componentName()0%110100%
AvatarAttachComponent()0%110100%
Initialize(...)0%110100%
IsValid()0%2100%
GetModel()0%2100%
GetClassId()0%110100%
UpdateFromPb(...)0%2100%
UpdateFromJSON(...)0%110100%
UpdateFromModel(...)0%2100%
DCL-Components-IComponent-ApplyChanges()0%6200%
RaiseOnAppliedChanges()0%2100%
GetTransform()0%110100%
Cleanup()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/AvatarAttach/AvatarAttachComponent.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using DCL.Controllers;
 4using DCL.Helpers;
 5using DCL.Models;
 6using UnityEngine;
 7using Decentraland.Sdk.Ecs6;
 8
 9namespace DCL.Components
 10{
 11    public class AvatarAttachComponent : IEntityComponent
 12    {
 13        [Serializable]
 14        public class Model : BaseModel
 15        {
 16            public string avatarId;
 17            public int anchorPointId;
 18
 19            public override BaseModel GetDataFromJSON(string json) =>
 120                Utils.SafeFromJson<Model>(json);
 21
 22            public override BaseModel GetDataFromPb(ComponentBodyPayload pbModel)
 23            {
 024                if (pbModel.PayloadCase != ComponentBodyPayload.PayloadOneofCase.AttachToAvatar)
 025                    return Utils.SafeUnimplemented<AvatarAttachComponent, Model>(expected: ComponentBodyPayload.PayloadO
 26
 027                var pb = new Model();
 028                if (pbModel.AttachToAvatar.HasAvatarId) pb.avatarId = pbModel.AttachToAvatar.AvatarId;
 029                if (pbModel.AttachToAvatar.HasAnchorPointId) pb.anchorPointId = (int)pbModel.AttachToAvatar.AnchorPointI
 30
 031                return pb;
 32            }
 33        }
 34
 035        IParcelScene IComponent.scene => handler.scene;
 036        IDCLEntity IEntityComponent.entity => handler.entity;
 37
 438        string IComponent.componentName => "AvatarAttach";
 39
 140        private readonly AvatarAttachHandler handler = new AvatarAttachHandler();
 41
 42        void IEntityComponent.Initialize(IParcelScene scene, IDCLEntity entity)
 43        {
 144            handler.Initialize(scene, entity, Environment.i.platform.updateEventHandler);
 145        }
 46
 047        bool IComponent.IsValid() => true;
 48
 049        BaseModel IComponent.GetModel() => handler.model;
 50
 151        int IComponent.GetClassId() => (int)CLASS_ID_COMPONENT.AVATAR_ATTACH;
 52
 53        void IComponent.UpdateFromPb(ComponentBodyPayload payload)
 54        {
 055            handler.OnModelUpdated(handler.model.GetDataFromPb(payload) as Model);
 056        }
 57
 58        void IComponent.UpdateFromJSON(string json)
 59        {
 160            handler.OnModelUpdated(json);
 161        }
 62
 63        void IComponent.UpdateFromModel(BaseModel newModel)
 64        {
 065            handler.OnModelUpdated(newModel as Model);
 066        }
 67
 68        IEnumerator IComponent.ApplyChanges(BaseModel newModel)
 69        {
 070            yield break;
 71        }
 72
 073        void IComponent.RaiseOnAppliedChanges() { }
 74
 275        Transform IMonoBehaviour.GetTransform() => null;
 76
 177        void ICleanable.Cleanup() => handler.Dispose();
 78    }
 79}