﻿using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace ARGOEditor
{
    public static class SceneHolder
    {
        private static Scene currentScene;
        private static int markerId = -1;

        public static Scene GetScene() { return currentScene; }

        private static Deployer deployer;

        public static void CreateNewScene(int markerId)
        {
            DestroyScene();
            SceneHolder.markerId = markerId;
            currentScene = Scene.NewScene(markerId);
            deployer = new Deployer();
        }

        public static void DestroyScene()
        {
            if (currentScene != null) currentScene.DestroyScene();
        }

        public static void BuildBundles(List<BuildTarget> targets, List<GameObject> gameObjects)
        {
            if (currentScene == null)
            {
                EditorUtility.DisplayDialog("Error occurred", "Current scene is empty. Try to recreate scene using `Scene/New`", "OK");
                return;
            }
            deployer.Clean();
            deployer.Build(targets, gameObjects);
            deployer.Deploy(targets, markerId);
        }
    }
}
