< Summary

Class:DCLCharacterPosition
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/CharacterController/DCLCharacterPosition.cs
Covered lines:28
Uncovered lines:7
Coverable lines:35
Total lines:79
Line coverage:80% (28 of 35)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DCLCharacterPosition()0%110100%
CheckAndRepositionWorld()0%440100%
RepositionedWorldLastFrame()0%110100%
ToString()0%2100%

File(s)

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

#LineLine coverage
 1using DCL.Configuration;
 2using System;
 3using DCL;
 4using DCL.Helpers;
 5using UnityEngine;
 6
 7public class DCLCharacterPosition
 8{
 9    private Vector3 worldPositionValue;
 10    private Vector3 unityPositionValue;
 11    private Vector3 offset;
 12
 13    private int lastRepositionFrame = 0;
 14
 15    public Vector3 worldPosition
 16    {
 017        get { return worldPositionValue; }
 18        set
 19        {
 558820            worldPositionValue = value;
 558821            unityPositionValue = PositionUtils.WorldToUnityPosition(worldPositionValue);
 558822            CheckAndRepositionWorld();
 558823        }
 24    }
 25
 26    public Vector3 unityPosition
 27    {
 028        get { return unityPositionValue; }
 29        set
 30        {
 031            unityPositionValue = value;
 032            worldPositionValue = PositionUtils.UnityToWorldPosition(unityPositionValue);
 033            CheckAndRepositionWorld();
 034        }
 35    }
 36
 57437    public DCLCharacterPosition()
 38    {
 57439        CommonScriptableObjects.worldOffset.Set(Vector3.zero);
 57440        CommonScriptableObjects.playerWorldPosition.Set(Vector3.zero);
 57441    }
 42
 43    private void CheckAndRepositionWorld()
 44    {
 558845        bool dirty = false;
 558846        float minDistanceForReposition = PlayerSettings.WORLD_REPOSITION_MINIMUM_DISTANCE;
 47
 558848        if (Mathf.Abs(unityPositionValue.x) > minDistanceForReposition)
 49        {
 250            float dist = (int) (unityPositionValue.x / minDistanceForReposition) * minDistanceForReposition;
 251            unityPositionValue.x -= dist;
 252            offset.x += dist;
 253            dirty = true;
 54        }
 55
 558856        if (Mathf.Abs(unityPositionValue.z) > minDistanceForReposition)
 57        {
 258            float dist = (int) (unityPositionValue.z / minDistanceForReposition) * minDistanceForReposition;
 259            unityPositionValue.z -= dist;
 260            offset.z += dist;
 261            dirty = true;
 62        }
 63
 558864        if (dirty)
 65        {
 266            worldPositionValue = unityPositionValue + offset;
 67
 268            lastRepositionFrame = Time.frameCount;
 69
 270            CommonScriptableObjects.playerWorldPosition.Set(worldPositionValue);
 271            CommonScriptableObjects.worldOffset.Set(offset);
 272            DCL.Environment.i.platform.physicsSyncController.MarkDirty();
 73        }
 558874    }
 75
 5976    public bool RepositionedWorldLastFrame() { return lastRepositionFrame == Time.frameCount - 1; }
 77
 078    public override string ToString() { return $"worldPos: {worldPositionValue} - unityPos: {unityPositionValue} - offse
 79}