using System; using System.Collections.Generic; using wf; namespace MaidStatus { public static class Propensity { public static int Count { get { Propensity.CreateData(); return Propensity.commonIdManager.idMap.Count; } } public static bool Contains(string name) { return Propensity.commonIdManager.nameMap.ContainsKey(name); } public static bool Contains(int id) { return Propensity.commonIdManager.idMap.ContainsKey(id); } public static int uniqueNameToId(string name) { Propensity.CreateData(); NDebug.Assert(Propensity.commonIdManager.nameMap.ContainsKey(name), "性癖\nユニーク名[" + name + "]をIDに変換できませんでした"); return Propensity.commonIdManager.nameMap[name]; } public static string IdToUniqueName(int id) { Propensity.CreateData(); NDebug.Assert(Propensity.commonIdManager.idMap.ContainsKey(id), "性癖\nID[" + id + "]をユニーク名に変換できませんでした"); return Propensity.commonIdManager.idMap[id].Key; } public static Propensity.Data GetData(int id) { Propensity.CreateData(); NDebug.Assert(Propensity.basicDatas.ContainsKey(id), "性癖\nID[" + id + "]のデータは存在しません"); return Propensity.basicDatas[id]; } public static Propensity.Data GetData(string uniqueName) { return Propensity.GetData(Propensity.uniqueNameToId(uniqueName)); } public static bool IsEnabled(string uniqueName) { Propensity.CreateData(); return Propensity.commonIdManager.enabledIdList.Contains(Propensity.uniqueNameToId(uniqueName)); } public static bool IsEnabled(int id) { Propensity.CreateData(); return Propensity.commonIdManager.enabledIdList.Contains(id); } public static List GetAllDatas(bool onlyEnabled) { Propensity.CreateData(); List list = new List(); foreach (KeyValuePair> keyValuePair in Propensity.commonIdManager.idMap) { if (!onlyEnabled || Propensity.commonIdManager.enabledIdList.Contains(keyValuePair.Key)) { list.Add(Propensity.basicDatas[keyValuePair.Key]); } } return list; } public static void CreateData() { if (Propensity.commonIdManager != null) { return; } Propensity.commonIdManager = new CsvCommonIdManager("maid_status_propensity", "性癖", CsvCommonIdManager.Type.IdAndUniqueName, null); Propensity.basicDatas = new Dictionary(); string[] array = new string[] { "list", "correction" }; KeyValuePair[] array2 = new KeyValuePair[array.Length]; for (int i = 0; i < array2.Length; i++) { string text = "maid_status_propensity_" + 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 Propensity.commonIdManager.idMap) { Propensity.basicDatas.Add(keyValuePair.Key, new Propensity.Data(keyValuePair.Key, array2[0].Value, array2[1].Value)); } foreach (KeyValuePair keyValuePair2 in array2) { keyValuePair2.Value.Dispose(); keyValuePair2.Key.Dispose(); } } private const string csvTopCommonName = "maid_status_propensity"; private const string typeNameForErrorLog = "性癖"; public const string termRootText = "MaidStatus/性癖タイプ/"; private static CsvCommonIdManager commonIdManager; private static Dictionary basicDatas; public class Data { public Data(int id, CsvParser basicCsv, CsvParser bonusCorrectionCsv) { for (int i = 1; i < basicCsv.max_cell_y; i++) { if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id) { int num = 1; this.id = id; this.uniqueName = basicCsv.GetCellAsString(num++, i); this.drawName = basicCsv.GetCellAsString(num++, i); break; } } for (int j = 1; j < bonusCorrectionCsv.max_cell_y; j++) { if (bonusCorrectionCsv.IsCellToExistData(0, j) && bonusCorrectionCsv.GetCellAsInteger(0, j) == id) { int num2 = 1; this.bonusCorrection = new ParametersPack(); this.bonusCorrection.Parse(bonusCorrectionCsv.GetCellAsString(num2++, j), ','); break; } } } public string termName { get { return "MaidStatus/性癖タイプ/" + this.uniqueName; } } public readonly int id; public readonly string uniqueName; public readonly string drawName; public readonly ParametersPack bonusCorrection; } } }