using UnityEngine;
using UVC.Core;
namespace Sample
{
///
/// Type B 예시: MonoBehaviour 동적 생성 - 오디오 매니저
///
///
/// [ 타입 ] Type B - MonoBehaviour 동적 생성 (Prefab 없이)
/// [ 라이프사이클 ] App - 씬 전환 시에도 유지
///
/// [ 특징 ]
///
/// - 프리팹 없이 런타임에 새 GameObject가 자동 생성됨
/// - Injector가 new GameObject().AddComponent<T>()로 생성
/// - App 라이프사이클이면 DontDestroyOnLoad 자동 적용
/// - 다른 서비스([Inject] ILogService)에 대한 의존성 주입 지원
///
///
/// [ 등록 방법 ]
/// Injector.Register<IAudioManager, InjectorSampleAudioManager>(ServiceLifetime.App);
///
/// [ 사용 방법 ]
///
/// [Inject] private IAudioManager _audioManager;
/// _audioManager.PlayBGM("main_theme");
/// _audioManager.PlaySFX("button_click");
///
///
/// [ Type C(Prefab)와의 차이점 ]
///
/// - Type B: 코드로만 구성, Inspector 설정 불가
/// - Type C: 프리팹에 미리 설정된 AudioSource, AudioClip 등 활용 가능
///
///
/// [ 실제 구현 시 확장 예시 ]
///
/// private AudioSource bgmSource;
/// private AudioSource sfxSource;
///
/// private void Awake()
/// {
/// bgmSource = gameObject.AddComponent<AudioSource>();
/// sfxSource = gameObject.AddComponent<AudioSource>();
/// bgmSource.loop = true;
/// }
///
///
public class InjectorSampleAudioManager : MonoBehaviour, IAudioManager
{
[Inject] private ILogService _logger;
/// 효과음을 재생합니다.
public void PlaySFX(string clipName) => _logger?.Log($"Playing SFX: {clipName}");
/// 배경음악을 재생합니다.
public void PlayBGM(string clipName) => _logger?.Log($"Playing BGM: {clipName}");
/// 모든 오디오를 중지합니다.
public void StopAll() => _logger?.Log("Stopping all audio");
}
}