< Summary

Class:DCL.Emotes.EmoteAnimationLoader
Assembly:EmoteAnimationsPlugin
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/EmoteAnimations/EmoteAnimationLoader.cs
Covered lines:22
Uncovered lines:6
Coverable lines:28
Total lines:65
Line coverage:78.5% (22 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
EmoteAnimationLoader(...)0%110100%
LoadEmote()0%10.129076%
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;
 212        public AnimationClip loadedAnimationClip { get; internal set; }
 13
 1014        public EmoteAnimationLoader(IWearableRetriever retriever)
 15        {
 1016            this.retriever = retriever;
 1017        }
 18
 19        public async UniTask LoadEmote(GameObject container, WearableItem emote, string bodyShapeId, CancellationToken c
 20        {
 721            if (container == null)
 122                throw new NullReferenceException("Container cannot be null");
 23
 624            if (emote == null)
 125                throw new NullReferenceException("Emote cannot be null");
 26
 527            if (string.IsNullOrEmpty(bodyShapeId))
 228                throw new NullReferenceException("bodyShapeId cannot be null or empty");
 29
 330            ct.ThrowIfCancellationRequested();
 31
 232            WearableItem.Representation representation = emote.GetRepresentation(bodyShapeId);
 33
 334            if (representation == null) { throw new Exception($"No representation for {bodyShapeId} of emote: {emote.id}
 35
 136            Rendereable rendereable = await retriever.Retrieve(container, emote.GetContentProvider(bodyShapeId), emote.b
 37
 138            var animation = rendereable.container.GetComponentInChildren<Animation>();
 39
 140            if (animation == null)
 41            {
 042                Debug.LogError("Animation component not found in the container for emote " + emote.id);
 043                return;
 44            }
 45
 146            animation.enabled = false;
 147            var animationClip = animation.clip;
 48
 149            if (animationClip == null)
 50            {
 051                Debug.LogError("AnimationClip not found in the container for emote " + emote.id);
 052                return;
 53            }
 54
 55            //Setting animation name equal to emote id to avoid unity animation clip duplication on Animation.AddClip()
 156            this.loadedAnimationClip = animationClip;
 157            animationClip.name = emote.id;
 158        }
 59
 60        public void Dispose()
 61        {
 062            retriever?.Dispose();
 063        }
 64    }
 65}