using System;
using Intrepid.Utilities;
using Unity.Cinemachine;
using UnityEngine;
using UnityEngine.Events;

namespace Intrepid.Core.Camera
{
    public class CameraStream : Identification, ICameraStreamUpdatable
    {
        [GroupInjections, SerializeField] private CinemachineCamera vCamera;
        [GroupInjections, SerializeField] private UnityEvent<ICameraStream> OnCameraUpdate;

        public CinemachineCamera VCamera => vCamera;
        public CinemachinePositionComposer PositionComposer { get; private set; }
        public CameraStreamUpdate CameraUpdate { get; private set; }

        private void Awake()
        {
            PositionComposer = VCamera.GetComponentInChildren<CinemachinePositionComposer>();
            CameraUpdate = DefaultCameraUpdate;
        }

        private void DefaultCameraUpdate(ICameraStream cs)
        {
            OnCameraUpdate?.Invoke(cs);
        }
    }
}