< Summary

Class:DCL.Helpers.CrashPayloadPositionTracker
Assembly:CrashPayloadUtils
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/CrashPayloadUtils/CrashPayloadPositionTracker.cs
Covered lines:0
Uncovered lines:21
Coverable lines:21
Total lines:48
Line coverage:0% (0 of 21)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CrashPayloadPositionTracker()0%2100%
Dispose()0%2100%
OnTeleport(...)0%6200%
OnPositionChange(...)0%12300%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5namespace DCL.Helpers
 6{
 7    public class CrashPayloadPositionTracker : IDisposable
 8    {
 09        public List<Vector3> movePositions = new List<Vector3>();
 010        public List<Vector3> teleportPositions = new List<Vector3>();
 11
 12        private float lastPositionUpdate;
 013        private float positionUpdateInterval = 30.0f;
 014        private int maxQueueSize = 50;
 15
 016        public CrashPayloadPositionTracker ()
 17        {
 018            CommonScriptableObjects.playerWorldPosition.OnChange += OnPositionChange;
 019            DataStore.i.player.lastTeleportPosition.OnChange += OnTeleport;
 020        }
 21
 22        public void Dispose()
 23        {
 024            CommonScriptableObjects.playerWorldPosition.OnChange -= OnPositionChange;
 025            DataStore.i.player.lastTeleportPosition.OnChange -= OnTeleport;
 026        }
 27
 28        private void OnTeleport(Vector3 current, Vector3 previous)
 29        {
 030            teleportPositions.Add( current );
 31
 032            if ( teleportPositions.Count > maxQueueSize )
 033                teleportPositions.RemoveAt(0);
 034        }
 35
 36        private void OnPositionChange(Vector3 current, Vector3 previous)
 37        {
 038            if ( lastPositionUpdate + positionUpdateInterval > Time.time )
 39            {
 040                movePositions.Add( current );
 041                lastPositionUpdate = Time.time;
 42
 043                if ( movePositions.Count > maxQueueSize )
 044                    movePositions.RemoveAt(0);
 45            }
 046        }
 47    }
 48}