using System;
using System.Linq;
using Assets.Source.General;
using Assets.Source.Misc;
using UnityEngine;

namespace Assets.Source.Settings
{
    [Serializable]
    public enum GameSceneType
    {
        Undefined = 0,
        Topdown = 1,
        Sidescroller = 2,
        LevelConstruct = 3
    }

    [Serializable]
    public class SceneShell
    {
        public int SceneIndex;
        public GameSceneType SceneType;
    }

    public class CoreSettings : ResourceScriptableObject<CoreSettings>
    {
        public ScriptableObject[] CommonScriptableWorkers;

        public GameObject MainCore;

        public SceneShell[] SceneShells;
        
        public AnimationSettings AnimationSettings;
        public ArtSettings ArtSettings;
        public DebugSettings DebugSettings;
        public IconSettings IconSettings;
        public MechanicSettings MechanicSettings;
        public PrefabSettings PrefabSettings;
        public UISettings UISettings;

        public int GetSceneByType(GameSceneType type)
        {
            return SceneShells.First(shell => shell.SceneType == type).SceneIndex;
        }
        public GameSceneType GetSceneByIndex(int index)
        {
            var shell = SceneShells.FirstOrDefault(s => s.SceneIndex == index);
            return shell?.SceneType ?? GameSceneType.Undefined;
        }
    }
}