< Summary

Class:DCL.Emotes.EmoteAnimationLoader
Assembly:EmoteAnimationsPlugin
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/EmoteAnimations/EmoteAnimationLoader.cs
Covered lines:14
Uncovered lines:3
Coverable lines:17
Total lines:45
Line coverage:82.3% (14 of 17)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
EmoteAnimationLoader(...)0%2100%
LoadEmote()0%9.169087.5%
Dispose()0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/EmoteAnimations/EmoteAnimationLoader.cs

#LineLine coverage
 1using System;
 2using System.Threading;
 3using AvatarSystem;
 4using Cysharp.Threading.Tasks;
 5using UnityEngine;
 6
 7namespace DCL.Emotes
 8{
 9    public class EmoteAnimationLoader : IEmoteAnimationLoader
 10    {
 11        private readonly IWearableRetriever retriever;
 012        public AnimationClip animation { get; internal set; }
 13
 014        public EmoteAnimationLoader(IWearableRetriever retriever) { this.retriever = retriever; }
 15
 16        public async UniTask LoadEmote(GameObject container, WearableItem emote, string bodyShapeId, CancellationToken c
 17        {
 718            if (container == null)
 119                throw new NullReferenceException("Container cannot be null");
 20
 621            if (emote == null)
 122                throw new NullReferenceException("Emote cannot be null");
 23
 524            if (string.IsNullOrEmpty(bodyShapeId))
 225                throw new NullReferenceException("bodyShapeId cannot be null or empty");
 26
 327            ct.ThrowIfCancellationRequested();
 28
 229            WearableItem.Representation representation = emote.GetRepresentation(bodyShapeId);
 230            if (representation == null)
 31            {
 132                throw new Exception($"No representation for {bodyShapeId} of emote: {emote.id}");
 33            }
 34
 135            Rendereable rendereable = await retriever.Retrieve(container, emote.GetContentProvider(bodyShapeId), emote.b
 36
 137            animation = rendereable.container.GetComponentInChildren<Animation>()?.clip;
 38
 39            //Setting animation name equal to emote id to avoid unity animation clip duplication on Animation.AddClip()
 140            animation.name = emote.id;
 141        }
 42
 043        public void Dispose() { retriever?.Dispose(); }
 44    }
 45}