using Cysharp.Threading.Tasks;
using UnityEngine;
using YooAsset;

public class Boot : MonoBehaviour
{
    public Camera MainCamera;
    public EPlayMode PlayMode = EPlayMode.EditorSimulateMode;
    void Awake()
    {
#if UNITY_EDITOR
        //PlayerPrefs.DeleteAll();
#endif
        Application.targetFrameRate = 60;
        Application.runInBackground = true;
        DontDestroyOnLoad(MainCamera);
    }
    async void Start()
    {
        bool updateSuccess = await PatchManager.Inst.StartOperation(PlayMode);
        if (updateSuccess)
            await EnterGame();
    }
    private async UniTask EnterGame()
    {
        Debug.Log("EnterGame");
        var assetHandle = YooAssets.TryGetPackage("Main").LoadSceneAsync("Test"); 
        await assetHandle.ToUniTask();
        if (assetHandle.Status == EOperationStatus.Succeed)
        {
            assetHandle.ActivateScene();
            PatchEvent.ClosePatchWindow();
        }
    }
}
