/// <summary>
        /// Searches for the shader archive file in external files, parent archive, and the global shader cache.
        /// </summary>
        /// <returns></returns>
        public virtual SHARCFB TryLoadShaderArchive(BFRES bfres, string shaderFile, string shaderModel)
        {
            //Check external files.
            bfres.UpdateExternalShaderFiles();
            foreach (var file in bfres.ShaderFiles)
            {
                if (file is SHARCFB && ((SHARCFB)file).Name.Contains(shaderFile))
                {
                    ShaderFileState = ShaderState.EmbeddedResource;
                    return((SHARCFB)file);
                }
            }

            //Check global shader cache
            foreach (var file in GlobalShaderCache.ShaderFiles.Values)
            {
                if (file is SHARCFB)
                {
                    if (((SHARCFB)file).Name.Contains(shaderFile))
                    {
                        ShaderFileState = ShaderState.Global;
                        return((SHARCFB)file);
                    }
                }
            }

            //Check external archives parenting the file.
            var archiveFile = bfres.FileInfo.ParentArchive;

            if (archiveFile == null)
            {
                return(null);
            }

            foreach (var file in archiveFile.Files)
            {
                if (!file.FileName.EndsWith(".sharcfb"))
                {
                    continue;
                }

                if (file.FileName == shaderFile || HasFileName(file.FileData, shaderFile))
                {
                    if (file.FileFormat == null)
                    {
                        file.FileFormat = file.OpenFile();
                    }

                    ShaderFileState = ShaderState.EmbeddedArchive;
                    return((SHARCFB)file.FileFormat);
                }
            }
            return(null);
        }
        /// <summary>
        /// Searches for the shader archive file in external files, parent archive, and the global shader cache.
        /// </summary>
        /// <returns></returns>
        public virtual BfshaLibrary.BfshaFile TryLoadShaderArchive(BFRES bfres, string shaderFile, string shaderModel)
        {
            //Check external files.
            bfres.UpdateExternalShaderFiles();
            foreach (var file in bfres.ShaderFiles)
            {
                if (file is BfshaLibrary.BfshaFile && ((BfshaLibrary.BfshaFile)file).Name.Contains(shaderFile))
                {
                    return((BfshaLibrary.BfshaFile)file);
                }
            }

            //Check global shader cache
            foreach (var file in GlobalShaderCache.ShaderFiles.Values)
            {
                if (file is BfshaLibrary.BfshaFile)
                {
                    if (((BfshaLibrary.BfshaFile)file).Name.Contains(shaderFile))
                    {
                        return((BfshaLibrary.BfshaFile)file);
                    }
                }
            }

            //Check external archives parenting the file.
            var archiveFile = bfres.FileInfo.ParentArchive;

            if (archiveFile == null)
            {
                return(null);
            }

            foreach (var file in archiveFile.Files)
            {
                if (file.FileName.Contains(shaderFile))
                {
                    if (file.FileFormat == null)
                    {
                        file.FileFormat = file.OpenFile();
                    }

                    return(((BFSHA)file.FileFormat).BfshaFile);
                }
            }
            return(null);
        }