< Summary

Class:OverrideCinemachineAxisInput
Assembly:Camera
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Camera/OverrideCinemachineAxisInput.cs
Covered lines:14
Uncovered lines:2
Coverable lines:16
Total lines:58
Line coverage:87.5% (14 of 16)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%440100%
OverrideGetAxis(...)0%4.594066.67%
SetInvertYAxis(...)0%110100%
OnDestroy()0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using Cinemachine;
 5using DCL;
 6using DCL.Camera;
 7using UnityEngine;
 8
 9public class OverrideCinemachineAxisInput : MonoBehaviour
 10{
 11    public const string MOUSE_Y_AXIS = "Mouse Y";
 12
 13    [Serializable]
 14    public struct AxisToMeasurableAction
 15    {
 16        public string axisName;
 17        public InputAction_Measurable measurableAction;
 18    }
 19
 20    [SerializeField] private AxisToMeasurableAction[] axisToMeasurableActions;
 21    private Dictionary<string, InputAction_Measurable> cachedAxisToMeasurableActions;
 22    private InputSpikeFixer inputSpikeFixer;
 23    private bool invertMouseY = false;
 24
 25    private void Awake()
 26    {
 298527        cachedAxisToMeasurableActions = axisToMeasurableActions.ToDictionary(x => x.axisName, x => x.measurableAction);
 59728        CinemachineCore.GetInputAxis = OverrideGetAxis;
 791029        inputSpikeFixer = new InputSpikeFixer(() => Cursor.lockState);
 59730        DataStore.i.camera.invertYAxis.OnChange += SetInvertYAxis;
 59731        invertMouseY = DataStore.i.camera.invertYAxis.Get();
 59732    }
 33
 34    private float OverrideGetAxis(string axisName)
 35    {
 671636        if (!cachedAxisToMeasurableActions.ContainsKey(axisName))
 037            return 0;
 38
 671639        float value = cachedAxisToMeasurableActions[axisName].GetValue();
 671640        if (axisName.Equals(MOUSE_Y_AXIS) && invertMouseY)
 41        {
 042            value = -value;
 43        }
 671644        return inputSpikeFixer.GetValue(value);
 45    }
 46
 47    private void SetInvertYAxis(bool current, bool previous)
 48    {
 1349        invertMouseY = current;
 1350    }
 51
 52    private void OnDestroy()
 53    {
 59754        DataStore.i.camera.invertYAxis.OnChange -= SetInvertYAxis;
 59755    }
 56
 57
 58}