using XGame.Framework.Asyncs;

namespace XGame.Framework.Asset
{
    /// <summary>
    /// 资源模块接口
    /// </summary>
    public interface IAssetManager
    {
        /// <summary>
        /// 同步加载接口
        /// 使用该接口加载的资源严禁使用Object.Destroy销毁，只能使用Recycle(obj)方法回收
        /// </summary>
        /// <typeparam name="TResult">返回值类型</typeparam>
        /// <param name="addressableName">可寻址资源名字</param>
        /// <returns>返回泛型对象</returns>
        TResult LoadSync<TResult>(string addressableName);

        /// <summary>
        /// 异步加载接口
        /// 使用该接口加载的资源严禁使用Object.Destroy销毁，只能使用Recycle(obj)方法回收
        /// </summary>
        /// <typeparam name="TResult">返回对象类型</typeparam>
        /// <param name="addressableName">可寻址资源名字</param>
        /// <returns>返回异步回调</returns>
        IAssetLoadAsync<TResult> LoadAsync<TResult>(string addressableName);
        /// <summary>
        /// 回收资源
        /// </summary>
        /// <param name="obj"></param>
        void Recycle(object obj);
        /// <summary>
        /// 停止指定的异步加载
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="async"></param>
        void StopAsync<TResult>(IAssetLoadAsync<TResult> async);

        /// <summary>
        /// 卸载当前未使用的资源
        /// </summary>
        void UnloadUnusedAssets();

        /// <summary>
        /// 异步加载Scene的AssetBundle到内存
        /// </summary>
        /// <param name="sceneName"></param>
        IAsync LoadSceneBundle(string sceneName);
        /// <summary>
        /// 卸载scene的AssetBundle
        /// </summary>
        /// <param name="sceneName"></param>
        void UnLoadSceneBundle(string sceneName);

        /// <summary>
        /// 异步销毁
        /// </summary>
        /// <returns></returns>
        IAsync Dispose();

        /// <summary>
        /// 转换AddressableName
        /// 会根据游戏当前语言、品质等级返回对应的AddressableName
        /// </summary>
        /// <param name="addressableName"></param>
        /// <returns></returns>
        string ConvertAddressableName(string addressableName);
    }
}
