< Summary

Class:DCL.Camera.CameraStateFreeBuildingMovement
Assembly:Camera
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Camera/CameraStateFreeBuildingMovement.cs
Covered lines:0
Uncovered lines:20
Coverable lines:20
Total lines:54
Line coverage:0% (0 of 20)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
OnUpdate()0%2100%
OnGetRotation()0%6200%
OnSetRotation(...)0%12300%

File(s)

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

#LineLine coverage
 1using Cinemachine;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5
 6namespace DCL.Camera
 7{
 8    public class CameraStateFreeBuildingMovement : CameraStateBase
 9    {
 010        protected Vector3Variable cameraForward => CommonScriptableObjects.cameraForward;
 011        protected Vector3NullableVariable characterForward => CommonScriptableObjects.characterForward;
 12
 13        float localCameraDistForward;
 14        float localCameraDistY;
 15        bool hasLocalCameraUnselectValues = false;
 16
 17        public override void OnUpdate()
 18        {
 019            var xzPlaneForward = Vector3.Scale(cameraTransform.forward, new Vector3(1, 0, 1));
 020            characterForward.Set(xzPlaneForward);
 021        }
 22
 23        public override Vector3 OnGetRotation()
 24        {
 025            if (defaultVirtualCamera is CinemachineVirtualCamera vcamera)
 26            {
 027                var pov = vcamera.GetCinemachineComponent<CinemachinePOV>();
 028                return new Vector3(pov.m_VerticalAxis.Value, pov.m_HorizontalAxis.Value, 0);
 29            }
 30
 031            return Vector3.zero;
 32        }
 33
 34        public override void OnSetRotation(CameraController.SetRotationPayload payload)
 35        {
 036            var eulerDir = Vector3.zero;
 37
 038            if (payload.cameraTarget.HasValue)
 39            {
 040                var newPos = new Vector3(payload.x, payload.y, payload.z);
 041                var cameraTarget = payload.cameraTarget.GetValueOrDefault();
 042                var dirToLook = (cameraTarget - newPos);
 043                eulerDir = Quaternion.LookRotation(dirToLook).eulerAngles;
 44            }
 45
 046            if (defaultVirtualCamera is CinemachineVirtualCamera vcamera)
 47            {
 048                var pov = vcamera.GetCinemachineComponent<CinemachinePOV>();
 049                pov.m_HorizontalAxis.Value = eulerDir.y;
 050                pov.m_VerticalAxis.Value = eulerDir.x;
 51            }
 052        }
 53    }
 54}