using System.Collections.Generic;
using Fort23.Core;

namespace Core.AssetLoadTool.Asset
{
    public class LocalAssetLoadTask : AssetLoadTaskBasic
    {
        private List<TimerEntity> timers = new List<TimerEntity>();

        protected override void StartLoadAsset<T>()
        {
#if UNITY_EDITOR
            TimerEntity timer = TimerComponent.Instance.AddTimer(100, delegate()
            {
                T objAsset = UnityEditor.AssetDatabase.LoadAssetAtPath<T>(_assetInfo.localPath);
                LoadFinish<T>(objAsset);
            });
            timers.Add(timer);
#endif                                                                                                                                                              
        }

        protected override void ProDispose()
        {
            for (int i = 0; i < timers.Count; i++)
            {
                TimerComponent.Instance.Remove(timers[i]);
            }

            timers.Clear();
        }
    }
}