using System;
using UnityEngine;
using Cinemachine;

public class ScreenShake : MonoBehaviour {
    public static ScreenShake Instance { get; private set; }
    private CinemachineImpulseSource cinemachineImpulseSource;

    private void Awake() {
        if (Instance is not null) {
            Debug.LogError($"There is more than one UnitActionSystem! {transform} - {Instance}");
            Destroy(gameObject);
            return;
        }

        Instance = this;
        cinemachineImpulseSource = GetComponent<CinemachineImpulseSource>();
    }


    public void Shake(float intensity = 1f) => cinemachineImpulseSource.GenerateImpulse(intensity);
}
