The container for the ARK data.
Beispiel #1
0
        /// <summary>
        /// Instantiates the ArkDataContainer and parses all the user-data files
        /// </summary>
        /// <param name="directory">The directory containing the profile and tribe files.</param>
        /// <returns>The async task context containing the resulting container.</returns>
        public static async Task <ArkDataContainer> CreateAsync(string directory)
        {
            if (!Directory.Exists(directory))
            {
                throw new DirectoryNotFoundException("The ARK data directory couldn't be found.");
            }

            var playerFiles = Directory.GetFiles(directory).Where(p => p.ToLower().Contains(".arkprofile")).ToArray();
            var tribeFiles  = Directory.GetFiles(directory).Where(p => p.ToLower().Contains(".arktribe")).ToArray();

            if (playerFiles.Length == 0 && tribeFiles.Length == 0)
            {
                throw new FileLoadException("The directory did not contain any of the parseable files.");
            }

            var container = new ArkDataContainer();

            for (var i = 0; i < playerFiles.Length; i++)
            {
                container.Players.Add(await Parser.ParsePlayerAsync(playerFiles[i]));
            }

            for (var i = 0; i < tribeFiles.Length; i++)
            {
                container.Tribes.Add(await Parser.ParseTribeAsync(tribeFiles[i]));
            }

            container.LinkPlayerTribe();

            return(container);
        }
        /// <summary>
        /// Instantiates the ArkDataContainer and parses all the user-data files
        /// </summary>
        /// <param name="directory">The directory containing the profile and tribe files.</param>
        /// <returns>The async task context containing the resulting container.</returns>
        public static async Task<ArkDataContainer> CreateAsync(string directory)
        {
            if (!Directory.Exists(directory))
                throw new DirectoryNotFoundException("The ARK data directory couldn't be found.");

            var playerFiles = Directory.GetFiles(directory).Where(p => p.ToLower().Contains(".arkprofile")).ToArray();
            var tribeFiles = Directory.GetFiles(directory).Where(p => p.ToLower().Contains(".arktribe")).ToArray();

            if (playerFiles.Length == 0 && tribeFiles.Length == 0)
                throw new FileLoadException("The directory did not contain any of the parseable files.");

            var container = new ArkDataContainer();

            for (var i = 0; i < playerFiles.Length; i++)
                container.Players.Add(await Parser.ParsePlayerAsync(playerFiles[i]));

            for (var i = 0; i < tribeFiles.Length; i++)
                container.Tribes.Add(await Parser.ParseTribeAsync(tribeFiles[i]));

            container.LinkPlayerTribe();

            return container;
        }
 public ArkDataContainer GetDataIncludingOnline()
 {
     _container = ArkDataContainer.Create(_settings.ArkDataDirectory);
     LoadOnlinePlayers();
     return _container;
 }