using System;
using System.Collections.Generic;

namespace XGame.Framework.Asset
{
    public class CSharpSceneInfosManifest : ISceneInfosManifest, IDisposable
    {
        /// <summary>
        /// <sceneName, assetName>
        /// </summary>
        private Dictionary<string, string> _sceneInfoMap;

        public CSharpSceneInfosManifest(SceneInfosSo manifest)
        {
            _sceneInfoMap = new Dictionary<string, string>();
            Init(manifest);
        }
        private void Init(SceneInfosSo manifest)
        {
            if (manifest == null || manifest.sceneInfos == null)
                return;
            foreach (var info in manifest.sceneInfos)
            {
                _sceneInfoMap.Add(info.sceneName, info.assetName);
            }
        }
        public string GetSceneAssetName(string sceneName)
        {
            _sceneInfoMap.TryGetValue(sceneName, out var assetName);
            return assetName;
        }

        void IDisposable.Dispose()
        {
            _sceneInfoMap.Clear();
        }
    }
}
