< Summary

Class:BIWTeleportAndEdit
Assembly:BuilderInWorldTeleportAndEdit
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/BuilderInWorldTeleportAndEdit/BIWTeleportAndEdit.cs
Covered lines:9
Uncovered lines:8
Coverable lines:17
Total lines:45
Line coverage:52.9% (9 of 17)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TeleportAndEdit(...)0%2.062075%
TeleportAndEditRoutine()0%168050%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/BuilderInWorldTeleportAndEdit/BIWTeleportAndEdit.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using DCL.Interface;
 4using UnityEngine;
 5using DataStore = DCL.DataStore;
 6
 7public static class BIWTeleportAndEdit
 8{
 9    public static event Action<Vector2Int> OnTeleportStart;
 10    public static event Action<Vector2Int> OnTeleportEnd;
 11
 12    private static bool inProgress = false;
 13
 14    public static bool TeleportAndEdit(Vector2Int targetCoords)
 15    {
 116        if (inProgress)
 017            return false;
 18
 119        CoroutineStarter.Start(TeleportAndEditRoutine(targetCoords));
 120        return true;
 21    }
 22
 23    private static IEnumerator TeleportAndEditRoutine(Vector2Int targetCoords)
 24    {
 125        inProgress = true;
 126        OnTeleportStart?.Invoke(targetCoords);
 27
 128        bool isPlayerTeleported = false;
 29
 030        void OnPlayerTeleportToNewPosition(Vector3 current, Vector3 prev) { isPlayerTeleported = true; }
 31
 132        DataStore.i.player.lastTeleportPosition.OnChange += OnPlayerTeleportToNewPosition;
 33
 134        WebInterface.GoTo(targetCoords.x, targetCoords.y);
 35
 26036        yield return new WaitUntil(() => isPlayerTeleported);
 037        DataStore.i.player.lastTeleportPosition.OnChange -= OnPlayerTeleportToNewPosition;
 38
 039        yield return new WaitUntil(() => CommonScriptableObjects.rendererState.Get());
 040        yield return null;
 41
 042        inProgress = false;
 043        OnTeleportEnd?.Invoke(targetCoords);
 044    }
 45}