using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace NHSE.Core { /// /// Stores references for all files in the Villager () folder. /// public sealed class Player : IEnumerable { public readonly Personal Personal; public readonly PhotoStudioIsland Photo; public readonly PostBox PostBox; public readonly Profile Profile; /// /// Directory Name where the player data was loaded from. Not the full path. /// public readonly string DirectoryName; #region Override Implementations public IEnumerator GetEnumerator() => new EncryptedFilePair[] {Personal, Photo, PostBox, Profile}.AsEnumerable().GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public override string ToString() => Personal.PlayerName; #endregion /// /// Imports Player data from the requested . /// /// Folder that contains the Player Villager sub-folders. /// Player object array loaded from the . public static Player[] ReadMany(string folder) { var dirs = Directory.GetDirectories(folder, "Villager*", SearchOption.TopDirectoryOnly); var result = new Player[dirs.Length]; for (int i = 0; i < result.Length; i++) result[i] = new Player(dirs[i]); return result; } private Player(string folder) { DirectoryName = new DirectoryInfo(folder).Name; Personal = new Personal(folder); Photo = new PhotoStudioIsland(folder); PostBox = new PostBox(folder); Profile = new Profile(folder); } } }