< Summary

Class:DCL.ECSComponents.AvatarShapeComponentHandler
Assembly:DCL.ECSComponents.AvatarShape
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/AvatarShape/Handler/AvatarShapeComponentHandler.cs
Covered lines:19
Uncovered lines:0
Coverable lines:19
Total lines:52
Line coverage:100% (19 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AvatarShapeComponentHandler(...)0%110100%
OnComponentCreated(...)0%110100%
OnComponentRemoved(...)0%220100%
OnComponentModelUpdated(...)0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/AvatarShape/Handler/AvatarShapeComponentHandler.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.ECSRuntime;
 3using DCL.Models;
 4
 5namespace DCL.ECSComponents
 6{
 7    /// <summary>
 8    /// This class will handle the avatar shape for the global scenes and the scenes that use it
 9    /// Take into account that this component uses a pool to manage the prefabs
 10    /// </summary>
 11    public class AvatarShapeComponentHandler : IECSComponentHandler<PBAvatarShape>
 12    {
 13        internal IAvatarShape avatar;
 14        private readonly Pool pool;
 15        private readonly PoolableObject poolableObject;
 16
 17        private bool isAvatarInitialized = false;
 18
 319        public AvatarShapeComponentHandler(Pool pool)
 20        {
 321            this.pool = pool;
 322            poolableObject = pool.Get();
 323            avatar = poolableObject.gameObject.GetComponent<AvatarShape>();
 324        }
 25
 26        public void OnComponentCreated(IParcelScene scene, IDCLEntity entity)
 27        {
 528            avatar.transform.SetParent(entity.gameObject.transform, false);
 529        }
 30
 31        public void OnComponentRemoved(IParcelScene scene, IDCLEntity entity)
 32        {
 433            if (avatar == null)
 134                return;
 35
 336            avatar.Cleanup();
 337            pool.Release(poolableObject);
 338            avatar = null;
 339            isAvatarInitialized = false;
 340        }
 41
 42        public void OnComponentModelUpdated(IParcelScene scene, IDCLEntity entity, PBAvatarShape model)
 43        {
 244            if (!isAvatarInitialized)
 45            {
 246                avatar.Init();
 247                isAvatarInitialized = true;
 48            }
 249            avatar.ApplyModel(scene,entity,model);
 250        }
 51    }
 52}