using UnityEngine;
using System;
using System.IO;
using System.Collections.Generic;

namespace mgaia.Utils
{
    /// <summary>
    /// Classe que auxilia no tratamento de caminhos de arquivos em projetos da Unity
    /// </summary>
    /// <owner>Victor</owner>
    public static class PathHelper
    {
        private static string _mAssetsFolderName = Constants.ASSETS_FOLDER_NAME;

        /// <summary>
        /// Nome da pasta de assets get/set
        /// </summary>
        public static string AssetsFolderName
        {
            get { return _mAssetsFolderName; }
            set { _mAssetsFolderName = value; }
        }

        /// <summary>
        /// Retorna o caminho completo de outro caminho considerando a pasta de assets
        /// </summary>
        public static string CompletePathToAsset(string path, string extension = "", string addition = "")
        {
            string subPath = path;

            if (extension != "")
            {
                subPath = subPath.WithExtension(extension);
            }

            if (addition != "")
            {
                subPath = Path.Combine(addition, subPath);
            }

            if (!Application.isPlaying)
            {
                return Path.Combine(AssetsFolderName, subPath);
            }
            else
            {
                //Sem a pasta Assets
                return subPath;
            }
        }

        /// <summary>
        /// Retorna o caminho completo de outro caminho considerando a pasta de assets
        /// </summary>
        public static string CompletePathToAsset(string path, string extension = "", params string[] additions)
        {
            string additionsString = "";

            additions.ForEach(addition => additionsString = Path.Combine(additionsString, addition));

            return CompletePathToAsset(path, extension, additionsString);
        }
    }
}