< Summary

Class:DCL.StickersController
Assembly:StickersController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/StickersController/StickersController.cs
Covered lines:4
Uncovered lines:13
Coverable lines:17
Total lines:50
Line coverage:23.5% (4 of 17)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
PlaySticker(...)0%2100%
PlaySticker(...)0%21.196025%
ToggleHideArea(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/StickersController/StickersController.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL
 4{
 5    public class StickersController : MonoBehaviour
 6    {
 7        private StickersFactory stickersFactory;
 8        private bool isInHideArea;
 9
 201210        private void Awake() { stickersFactory = Resources.Load<StickersFactory>("StickersFactory"); }
 11
 12        public void PlaySticker(string id)
 13        {
 014            PlaySticker(id, transform.position, Vector3.zero, true);
 015        }
 16
 17        /// <summary>
 18        /// Play a sticker
 19        /// </summary>
 20        /// <param name="id"></param>
 21        /// <param name="position"> if following transform, position must be an offset from the target. Otherwise, it's 
 22        /// <param name="direction"></param>
 23        /// <param name="followTransform"></param>
 24        public void PlaySticker(string id, Vector3 position, Vector3 direction, bool followTransform)
 25        {
 2226            if (stickersFactory == null || !stickersFactory.TryGet(id, out GameObject prefab) || isInHideArea)
 027                return;
 28
 29            // TODO(Brian): Mock this system properly through our service locators or plugin system
 2230            if (DCL.Configuration.EnvironmentSettings.RUNNING_TESTS)
 2231                return;
 32
 033            GameObject emoteGameObject = Instantiate(prefab);
 034            emoteGameObject.transform.position += position;
 035            emoteGameObject.transform.rotation = Quaternion.Euler(prefab.transform.rotation.eulerAngles + direction);
 36
 037            if (followTransform)
 38            {
 039                FollowObject emoteFollow = emoteGameObject.AddComponent<FollowObject>();
 040                emoteFollow.target = transform;
 041                emoteFollow.offset = position;
 42            }
 043        }
 44
 45        public void ToggleHideArea(bool entered)
 46        {
 047            isInHideArea = entered;
 048        }
 49    }
 50}