Esempio n. 1
0
        //File Handling. Methods for getting files from the game and parsing them.
        /// <summary>
        /// Gets a parsed file from the game and caches it. If it exists in the cache already then that is returned.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="path"></param>
        /// <returns></returns>
        public object GetParsedFile <T>(string path, bool fromCpk, bool raiseEx = true) where T : new()
        {
            if (fromCpk)
            {
                return(Install.GetParsedFileFromGame(path, FileIO, fromCpk, raiseEx));
            }

            var cachedFile = fileManager.GetParsedFile <T>(path);

            if (cachedFile != null)
            {
                //File is already cached. Return that instance.
                return(cachedFile);
            }
            else
            {
                //File is not cached. So parse it, add it and then return it.
                var file = Install.GetParsedFileFromGame(path, FileIO, fromCpk, raiseEx);
                if (file != null)
                {
                    fileManager.AddParsedFile(path, file);
                }
                return(file);
            }
        }