#nullable enable
using UnityEngine;
using UVC.Core;
using UVC.UI.Menu;
using UVC.Util;
using UVC.Studio.Config;
using Cysharp.Threading.Tasks;
namespace UVC.Studio
{
public class StudioAppContext : InjectorAppContext
{
///
/// App 라이프사이클 서비스들을 동기적으로 등록합니다.
///
///
/// 비동기 로드가 필요 없는 서비스들만 여기서 등록합니다.
/// 비동기 로드가 필요한 서비스는 RegisterServicesAsync()에서 등록하세요.
///
protected override void RegisterServices()
{
base.RegisterServices();
// 비동기 로드가 필요 없는 싱글톤 서비스 등록
Injector.RegisterSingleton();
Injector.RegisterSingleton();
}
///
/// App 라이프사이클 서비스들을 비동기적으로 등록합니다.
///
/// 비동기 등록 완료 UniTask
///
/// 이 메서드는 RegisterServices() 완료 후 await되어 호출됩니다.
/// 완료될 때까지 IsInitialized가 false로 유지되므로 안전하게 비동기 로드를 수행할 수 있습니다.
///
protected override async UniTask RegisterServicesAsync()
{
await base.RegisterServicesAsync();
// Setting과 Library를 병렬로 로드
var setting = new Setting();
var library = new Library();
await UniTask.WhenAll(
setting.LoadAsync(),
library.LoadAllParallelAsync()
);
// 로드 완료 후 인스턴스 등록
Injector.RegisterInstance(setting);
Injector.RegisterInstance(library);
}
}
}