< Summary

Class:DCL.Emotes.EmoteAnimationLoader
Assembly:EmoteAnimationsPlugin
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/EmoteAnimations/EmoteAnimationLoader.cs
Covered lines:18
Uncovered lines:7
Coverable lines:25
Total lines:58
Line coverage:72% (18 of 25)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
EmoteAnimationLoader(...)0%2100%
LoadEmote()0%10.279075%
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 loadedAnimationClip { 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            var animation = rendereable.container.GetComponentInChildren<Animation>();
 138            if (animation == null)
 39            {
 040                Debug.LogError("Animation component not found in the container for emote " + emote.id);
 041                return;
 42            }
 43
 144            var animationClip = animation.clip;
 145            if(animationClip == null)
 46            {
 047                Debug.LogError("AnimationClip not found in the container for emote " + emote.id);
 048                return;
 49            }
 50
 51            //Setting animation name equal to emote id to avoid unity animation clip duplication on Animation.AddClip()
 152            this.loadedAnimationClip = animationClip;
 153            animationClip.name = emote.id;
 154        }
 55
 056        public void Dispose() { retriever?.Dispose(); }
 57    }
 58}