using System; using System.Collections.Generic; using wf; namespace Kasizuki { public static class ManData { public static int Count { get { ManData.CreateData(); return ManData.commonIdManager.idMap.Count; } } public static bool Contains(string name) { return ManData.commonIdManager.nameMap.ContainsKey(name); } public static bool Contains(int id) { return ManData.commonIdManager.idMap.ContainsKey(id); } public static int uniqueNameToId(string uniqueName) { ManData.CreateData(); NDebug.Assert(ManData.commonIdManager.nameMap.ContainsKey(uniqueName), "傅き.男データ\nユニーク名[" + uniqueName + "]をIDに変換できませんでした"); return ManData.commonIdManager.nameMap[uniqueName]; } public static string IdToUniqueName(int id) { ManData.CreateData(); NDebug.Assert(ManData.commonIdManager.idMap.ContainsKey(id), "傅き.男データ\nID[" + id + "]をユニーク名に変換できませんでした"); return ManData.commonIdManager.idMap[id].Key; } public static ManData.Data GetData(int id) { ManData.CreateData(); NDebug.Assert(ManData.basicDatas.ContainsKey(id), "傅き.男データ\nID[" + id + "]のデータは存在しません"); return ManData.basicDatas[id]; } public static ManData.Data GetData(string uniqueName) { return ManData.GetData(ManData.uniqueNameToId(uniqueName)); } public static bool IsEnabled(string uniqueName) { ManData.CreateData(); return ManData.commonIdManager.enabledIdList.Contains(ManData.uniqueNameToId(uniqueName)); } public static bool IsEnabled(int id) { ManData.CreateData(); return ManData.commonIdManager.enabledIdList.Contains(id); } public static List GetAllDatas(bool onlyEnabled, bool checkLockNTR = true) { ManData.CreateData(); List list = new List(); if (checkLockNTR && GameMain.Instance.CharacterMgr.status.lockNTRPlay) { list.Add(ManData.GetData(10)); } else { foreach (KeyValuePair> keyValuePair in ManData.commonIdManager.idMap) { if (!onlyEnabled || ManData.commonIdManager.enabledIdList.Contains(keyValuePair.Key)) { list.Add(ManData.basicDatas[keyValuePair.Key]); } } } return list; } public static void CreateData() { if (ManData.commonIdManager != null) { return; } ManData.commonIdManager = new CsvCommonIdManager("kasizuki_man", "傅き.男データ", CsvCommonIdManager.Type.IdAndUniqueName, null); ManData.basicDatas = new Dictionary(); string[] array = new string[] { "list" }; KeyValuePair[] array2 = new KeyValuePair[array.Length]; for (int i = 0; i < array2.Length; i++) { string text = "kasizuki_man_" + array[i] + ".nei"; AFileBase afileBase = GameUty.FileSystem.FileOpen(text); CsvParser csvParser = new CsvParser(); bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, text + "\nopen failed."); array2[i] = new KeyValuePair(afileBase, csvParser); } foreach (KeyValuePair> keyValuePair in ManData.commonIdManager.idMap) { int key = keyValuePair.Key; ManData.Data value = new ManData.Data(key, array2[0].Value); ManData.basicDatas.Add(key, value); } foreach (KeyValuePair keyValuePair2 in array2) { keyValuePair2.Value.Dispose(); keyValuePair2.Key.Dispose(); } } private const string csvTopCommonName = "kasizuki_man"; private const string typeNameForErrorLog = "傅き.男データ"; private static CsvCommonIdManager commonIdManager; private static Dictionary basicDatas; public class Data { public Data(int uniqueID, CsvParser csv) { for (int i = 1; i < csv.max_cell_y; i++) { if (csv.IsCellToExistData(0, i) && csv.GetCellAsInteger(0, i) == uniqueID) { int num = 1; this.ID = uniqueID; this.uniqueName = csv.GetCellAsString(num++, i); this.drawName = csv.GetCellAsString(num++, i); this.modelResourceName = csv.GetCellAsString(num++, i); this.profileText = csv.GetCellAsString(num++, i); this.favoritePlayText = csv.GetCellAsString(num++, i); try { this.manType = (ManDataType)Enum.ToObject(typeof(ManDataType), this.ID); } catch (Exception e) { NDebug.AssertParseError("ManDataType", e); } } } } public readonly int ID; public readonly string uniqueName; public readonly string drawName; public readonly string modelResourceName; public readonly string profileText; public readonly string favoritePlayText; public readonly ManDataType manType; } } }