< Summary

Class:DCL.ReleaseParticlesOnFinish
Assembly:PoolManager
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PoolManager/Components/ReleaseParticlesOnFinish.cs
Covered lines:0
Uncovered lines:15
Coverable lines:15
Total lines:42
Line coverage:0% (0 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize(...)0%6200%
FixedUpdate()0%30500%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PoolManager/Components/ReleaseParticlesOnFinish.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL
 4{
 5    public class ReleaseParticlesOnFinish : MonoBehaviour
 6    {
 7        private const int INDEX_AMOUNT = 10;
 8
 9        [SerializeField] private ParticleSystem particles;
 10        private PoolableObject poolable = null;
 11        private int index;
 12        private bool initialized;
 13
 14
 15        public void Initialize(PoolableObject poolableObject)
 16        {
 017            if (particles == null)
 18            {
 019                Debug.LogError($"The script: {nameof(ReleaseParticlesOnFinish)}, " +
 20                    $"should never be initialized without particles attached: Aborting initialization");
 021                Destroy(this);
 022                return;
 23            }
 24
 025            poolable = poolableObject;
 026            index = Random.Range(0, INDEX_AMOUNT);
 027            initialized = false;
 028        }
 29
 30        public void FixedUpdate()
 31        {
 032            if (initialized && Time.frameCount % INDEX_AMOUNT != index)
 033                return;
 34
 035            if (particles == null || particles.IsAlive())
 036                return;
 37
 038            poolable.Release();
 039            initialized = false;
 040        }
 41    }
 42}