﻿using System;
using UnityEngine;

namespace JLGames.RocketDriver.Actions.Loaderx
{
    /// <summary>
    /// Debug Settings
    /// 调试设置
    /// </summary>
    [Serializable]
    public class BundleDebug
    {
        [Tooltip("Enable Debug?\n是否使用调试设置")] [SerializeField] 
        private bool m_EnableDebug = BundleDefaultValues.EnableDebug;
        [Tooltip("Enable Bundle Cache?\n是否启用AssetBundle缓存")] [SerializeField] 
        private bool m_EnableCache = BundleDefaultValues.EnableCache;
        [Tooltip("Debug cache directory\n调试用缓存目录")] [SerializeField] 
        private string m_CachePath;

        public bool EnableDebug => m_EnableDebug;
        public bool EnableCache => m_EnableCache;
        public string CachePath => m_CachePath;

        public bool CacheEnabled
        {
            get
            {
                if (!m_EnableDebug) return true;
                if (m_EnableCache || !string.IsNullOrWhiteSpace(m_CachePath)) return true;
                return false;
            }
        }

        public string RunningCachePath => m_EnableDebug && m_EnableCache ? m_CachePath : LoaderDefine.AssetBundleCachePath;
    }
}