< Summary

Class:FirstPersonCameraEntityReference
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/CharacterController/FirstPersonCameraEntityReference.cs
Covered lines:18
Uncovered lines:0
Coverable lines:18
Total lines:47
Line coverage:100% (18 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%220100%
OnDestroy()0%110100%
UpdateForward(...)0%110100%
OnCameraModeChange(...)0%330100%

File(s)

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

#LineLine coverage
 1using UnityEngine;
 2
 3public class FirstPersonCameraEntityReference : MonoBehaviour
 4{
 5
 6    public Transform cameraPosition;
 7
 8    private void Awake()
 9    {
 10        // Assign the camera position to the game object
 12211        if (cameraPosition != null)
 12        {
 11613            transform.position = cameraPosition.position;
 14        }
 15
 16        // Listen to changes on the camera mode
 12217        CommonScriptableObjects.cameraMode.OnChange += OnCameraModeChange;
 18
 19        // Trigger the initial camera set
 12220        OnCameraModeChange(CommonScriptableObjects.cameraMode, CommonScriptableObjects.cameraMode);
 12221    }
 22
 23    private void OnDestroy()
 24    {
 12125        CommonScriptableObjects.cameraMode.OnChange -= OnCameraModeChange;
 12126        CommonScriptableObjects.cameraForward.OnChange -= UpdateForward;
 12127    }
 28
 6629    private void UpdateForward(Vector3 newForward, Vector3 prev) { transform.forward = newForward; }
 30
 31    private void OnCameraModeChange(CameraMode.ModeId newMode, CameraMode.ModeId prev)
 32    {
 13233        if (newMode == CameraMode.ModeId.ThirdPerson)
 34        {
 135            CommonScriptableObjects.cameraForward.OnChange -= UpdateForward;
 136            transform.forward = transform.parent.forward;
 137        }
 13138        else if (newMode == CameraMode.ModeId.BuildingToolGodMode)
 39        {
 1040            CommonScriptableObjects.cameraForward.OnChange -= UpdateForward;
 1041        }
 42        else
 43        {
 12144            CommonScriptableObjects.cameraForward.OnChange += UpdateForward;
 45        }
 12146    }
 47}